diff options
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r-- | libc/sysdeps/linux/arm/crt0.S | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/Makefile | 15 | ||||
-rw-r--r-- | libc/sysdeps/linux/i386/crt0.S | 9 | ||||
-rw-r--r-- | libc/sysdeps/linux/mips/crt0.S | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/sh/crt0.S | 38 |
5 files changed, 60 insertions, 10 deletions
diff --git a/libc/sysdeps/linux/arm/crt0.S b/libc/sysdeps/linux/arm/crt0.S index ad4865cc1..a930ff3f2 100644 --- a/libc/sysdeps/linux/arm/crt0.S +++ b/libc/sysdeps/linux/arm/crt0.S @@ -80,6 +80,7 @@ _start: ldr r2,[sp, #8] #endif +#ifdef __UCLIBC_CTOR_DTOR__ /* Store the address of _init in r3 as an argument to main() */ ldr r3, =_init @@ -89,6 +90,9 @@ _start: /* Ok, now run uClibc's main() -- shouldn't return */ bl __uClibc_start_main +#else + bl __uClibc_main +#endif /* Crash if somehow `exit' returns anyways. */ bl abort diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile index f66c09f31..8e0ed9485 100644 --- a/libc/sysdeps/linux/common/Makefile +++ b/libc/sysdeps/linux/common/Makefile @@ -24,11 +24,6 @@ TOPDIR=../../../../ include $(TOPDIR)Rules.mak -SAFECFLAGS=$(WARNINGS) $(CPU_CFLAGS-y) $(OPTIMIZATION) -fno-builtin -ifeq ($(strip $(DOPIC)),y) -SAFECFLAGS+=-fPIC -endif - CSRC= waitpid.c getdnnm.c gethstnm.c getcwd.c \ mkfifo.c setegid.c wait.c getpagesize.c seteuid.c \ wait3.c setpgrp.c getdtablesize.c create_module.c ptrace.c \ @@ -44,13 +39,21 @@ COBJS=$(patsubst %.c,%.o, $(CSRC)) MSRC=syscalls.c MOBJ=$(shell ./list_syscalls.sh) +ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) +CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o +SAFECFLAGS=$(WARNINGS) $(CPU_CFLAGS-y) $(OPTIMIZATION) -fno-builtin +ifeq ($(strip $(DOPIC)),y) +SAFECFLAGS+=-fPIC +endif +endif + OBJ=$(COBJS) $(MOBJ) all: $(STR_SYSCALLS) $(OBJ) $(LIBC) $(LIBC): ar-target -ar-target: $(OBJ) $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o +ar-target: $(OBJ) $(CTOR_TARGETS) $(AR) $(ARFLAGS) $(LIBC) $(OBJ) (cd $(TOPDIR)lib/; ln -fs crt0.o crt1.o) diff --git a/libc/sysdeps/linux/i386/crt0.S b/libc/sysdeps/linux/i386/crt0.S index 97f1fde63..be66b9a2d 100644 --- a/libc/sysdeps/linux/i386/crt0.S +++ b/libc/sysdeps/linux/i386/crt0.S @@ -61,6 +61,7 @@ _start: pushl %ebp /* callers %ebp (frame pointer) */ movl %esp,%ebp /* mark callers stack frame as invalid */ +#ifdef __UCLIBC_CTOR_DTOR__ /* Push .init and .fini arguments to __uClibc_start_main() on the stack */ pushl $_fini pushl $_init @@ -72,6 +73,14 @@ _start: /* Ok, now run uClibc's main() -- shouldn't return */ call __uClibc_start_main +#else + /* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */ + pushl %eax /* Environment pointer */ + pushl %ebx /* Argument pointer */ + pushl %ecx /* And the argument count */ + + call __uClibc_main +#endif /* Crash if somehow `exit' returns anyways. */ hlt diff --git a/libc/sysdeps/linux/mips/crt0.S b/libc/sysdeps/linux/mips/crt0.S index fd1f4b9d4..052229819 100644 --- a/libc/sysdeps/linux/mips/crt0.S +++ b/libc/sysdeps/linux/mips/crt0.S @@ -30,6 +30,7 @@ __start: addu a2, a0, 1 /* argv[0] program name (ordinal->cardinal) */ sll a2, a2, 2 /* multiple by 4 */ add a2, a2, a1 /* a2 now points to start of envp */ +#ifdef __UCLIBC_CTOR_DTOR__ la a3, _init /* a3 is address of _init */ addiu sp, sp, -24 /* 16 + 4 rounded up to multiple of 8 */ /* multiple of 8 for longlong/double support */ @@ -38,6 +39,9 @@ __start: /* Ok, now run uClibc's main() -- shouldn't return */ jal __uClibc_start_main +#else + jal __uClibc_main +#endif addiu sp, sp, 24 /* undo stack argument */ diff --git a/libc/sysdeps/linux/sh/crt0.S b/libc/sysdeps/linux/sh/crt0.S index e74ae86c4..a27775ed0 100644 --- a/libc/sysdeps/linux/sh/crt0.S +++ b/libc/sysdeps/linux/sh/crt0.S @@ -48,6 +48,34 @@ _start: mov.l @r15+,r4 mov r15, r5 +#if ! defined __UCLIBC_CTOR_DTOR__ + /* + * Setup the value for the environment pointer: + * r6 = (argc + 1) * 4 + * r6 += argv (in delay slot) + */ + mov r4,r6 + add #1,r6 + shll2 r6 + add r5, r6 + + /* jump to __uClibc_main (argc, argv, envp) */ + mov.l L_main, r0 + jsr @r0 + nop /* delay slot */ + + /* We should not get here. */ + mov.l L_abort, r0 + jmp @r0 + nop + +_start_end: + .align 2 + +L_main: + .long __uClibc_main /* in libuClibc.*.so */ + +#else /* __UCLIBC_CTOR_DTOR__ */ /* Push the finip argument to __uClibc_start_main() onto the stack */ mov.l L_fini,r6 mov.l r6,@-r15 @@ -72,10 +100,12 @@ _start: mov.l L_abort, r0 jmp @r0 nop - _start_end: .align 2 +L_main: + .long __uClibc_start_main /* in libuClibc.*.so */ + .weak _init .type _init,@function _init: @@ -87,13 +117,13 @@ _init: .weak _fini .set _fini,_init -L_main: - .long __uClibc_start_main /* in libuClibc.*.so */ - L_init: .long _init L_fini: .long _fini + +#endif + L_abort: .long abort |