From 31e36a1498a8edcc3db48dc4c5a5f8e7cae276ec Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 16 Jan 2001 19:00:46 +0000 Subject: Fix arm so it actually works. --- libc/sysdeps/linux/arm/crt0.S | 122 ++++++++++++++++++++++++++++-------------- 1 file changed, 82 insertions(+), 40 deletions(-) (limited to 'libc/sysdeps/linux') diff --git a/libc/sysdeps/linux/arm/crt0.S b/libc/sysdeps/linux/arm/crt0.S index 90478fa59..115650f98 100644 --- a/libc/sysdeps/linux/arm/crt0.S +++ b/libc/sysdeps/linux/arm/crt0.S @@ -1,61 +1,103 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* When we enter this piece of code, the program stack looks like this: + argc argument counter (integer) + argv[0] program name (pointer) + argv[1...N] program args (pointers) + argv[argc-1] end of args (integer) + env[0...N] environment variables (pointers) + NULL + +This file now uses the register naming from the ARM Procedure Calling Standard + + Name Number APCS Role + + a1 0 argument 1 / integer result / scratch register / argc + a2 1 argument 2 / scratch register / argv + a3 2 argument 3 / scratch register / envp + a4 3 argument 4 / scratch register + v1 4 register variable + v2 5 register variable + v3 6 register variable + v4 7 register variable + v5 8 register variable + sb/v6 9 static base / register variable + sl/v7 10 stack limit / stack chunk handle / reg. variable + fp 11 frame pointer + ip 12 scratch register / new-sb in inter-link-unit calls + sp 13 lower end of current stack frame + lr 14 link address / scratch register + pc 15 program counter +*/ -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. +.text + .align 2 + .global __environ + .global _start + .global exit + .global main + .global __libc_init + .global __init_stdio + .global __stdio_close_all + .global _void_void_null_func + + .type _start,%function + .type exit,%function + .type main,%function + .type __libc_init,%function + .type __init_stdio,%function + .type __stdio_close_all,%function + .type _void_void_null_func,%function -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ +.text +_start: + /* clear the frame pointer */ + mov fp, #0 -#define BASEREG r9 + /* Load argc into a1 -- its final resting place */ + ldr a1, [sp], #4 -@ r0 = argc -@ r1 = argv -@ r2 = envp -@ sl = data segment + /* Load argv into a2 -- which its final resting place */ + mov a2, sp + /* Set up environ, skip to the end of argv, and put + * a pointer to whatever we find there (hopefully the + environment) in a3 */ + ldr a4, .L3 + add a3, a2, a1, lsl #2 + add a3, a3, #4 + str a3, [a4, #0] + /* Tell libc to initialize whatever it needs */ + bl __libc_init + bl __init_stdio + bl main + bl exit - .text - .align 2 - .global _start, exit, main - .type _start,%function +_void_void_null_func: + nop -.text -_start: - @ adjust the data sgement base pointer - ldr r3,=__data_start - sub sl,sl,r3 - mov BASEREG,sl +.weak __libc_init +__libc_init = _void_void_null_func - ldr r3, .L3 - str r2,[BASEREG,r3] - ldr r0,[sp, #0] - ldr r1,[sp, #4] - ldr r2,[sp, #8] - bl main - ldr r0,=0 - bl exit +.weak __init_stdio +__init_stdio = _void_void_null_func +.weak __stdio_close_all +__stdio_close_all = _void_void_null_func -.L3: .word environ +.align 2 +.L3: + .word environ - .data +.data .align 2 .global __environ -__environ: .long 0 +__environ: + .long 0 + .weak environ environ = __environ -- cgit v1.2.3