summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-12-12 10:14:19 +0000
committerEric Andersen <andersen@codepoet.org>2002-12-12 10:14:19 +0000
commit3628edc05e5b439aad08191ab220360f9d9f54bd (patch)
treeff8aaa7216e50019a7852d367bae3bae34fdb92d /libc
parentf329b6fe2f16e16000bb648aa678c2a947258e87 (diff)
Based on discussions with Stefan Allius, change it so that we always
build a crt0.o and a crt1.o. crt1.o will support ctors and dtors if such support is enabled. One more gratuitous toolchain support issue is thereby removed... -Erik
Diffstat (limited to 'libc')
-rw-r--r--libc/sysdeps/linux/arm/Makefile12
-rw-r--r--libc/sysdeps/linux/arm/crt0.S2
-rw-r--r--libc/sysdeps/linux/common/Makefile1
-rw-r--r--libc/sysdeps/linux/i386/Makefile22
-rw-r--r--libc/sysdeps/linux/i386/crt0.S2
-rw-r--r--libc/sysdeps/linux/i386/crt0.c43
-rw-r--r--libc/sysdeps/linux/mips/Makefile11
-rw-r--r--libc/sysdeps/linux/mips/crt0.S2
-rw-r--r--libc/sysdeps/linux/sh/Makefile14
-rw-r--r--libc/sysdeps/linux/sh/crt0.S7
10 files changed, 26 insertions, 90 deletions
diff --git a/libc/sysdeps/linux/arm/Makefile b/libc/sysdeps/linux/arm/Makefile
index 62facd47d..8cd0efa47 100644
--- a/libc/sysdeps/linux/arm/Makefile
+++ b/libc/sysdeps/linux/arm/Makefile
@@ -25,10 +25,8 @@ TOPDIR=../../../../
include $(TOPDIR)Rules.mak
ASFLAGS=$(CFLAGS)
-TARGET_MACHINE_TYPE=$(shell $(CC) -dumpmachine)
-
-CRT0=crt0.S
-CRT0_OBJ=crt0.o
+CRT0_SRC = crt0.S
+CRT0_OBJ = crt0.o crt1.o
SSRC=__longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S bsd-_setjmp.S
SOBJS=$(patsubst %.S,%.o, $(SSRC))
@@ -45,10 +43,10 @@ $(LIBC): ar-target
ar-target: $(OBJS) $(CRT0_OBJ)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
- cp $(CRT0_OBJ) $(TOPDIR)lib/$(CRT0_OBJ)
+ cp $(CRT0_OBJ) $(TOPDIR)lib/
-$(CRT0_OBJ): $(CRT0)
- $(CC) $(CFLAGS) -c $< -o $@
+$(CRT0_OBJ): $(CRT0_SRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(SOBJS): %.o : %.S
diff --git a/libc/sysdeps/linux/arm/crt0.S b/libc/sysdeps/linux/arm/crt0.S
index a930ff3f2..ad0995a6a 100644
--- a/libc/sysdeps/linux/arm/crt0.S
+++ b/libc/sysdeps/linux/arm/crt0.S
@@ -80,7 +80,7 @@ _start:
ldr r2,[sp, #8]
#endif
-#ifdef __UCLIBC_CTOR_DTOR__
+#if defined L_crt1 && defined __UCLIBC_CTOR_DTOR__
/* Store the address of _init in r3 as an argument to main() */
ldr r3, =_init
diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile
index 8e0ed9485..e6828cd17 100644
--- a/libc/sysdeps/linux/common/Makefile
+++ b/libc/sysdeps/linux/common/Makefile
@@ -55,7 +55,6 @@ $(LIBC): ar-target
ar-target: $(OBJ) $(CTOR_TARGETS)
$(AR) $(ARFLAGS) $(LIBC) $(OBJ)
- (cd $(TOPDIR)lib/; ln -fs crt0.o crt1.o)
$(MOBJ): $(MSRC)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
diff --git a/libc/sysdeps/linux/i386/Makefile b/libc/sysdeps/linux/i386/Makefile
index aa7b2cd28..77c8c815d 100644
--- a/libc/sysdeps/linux/i386/Makefile
+++ b/libc/sysdeps/linux/i386/Makefile
@@ -21,20 +21,12 @@
# other sundry sources. Files within this library are copyright by their
# respective copyright holders.
-USE_CRT0_C=false
-
TOPDIR=../../../../
include $(TOPDIR)Rules.mak
ASFLAGS=$(CFLAGS)
-ifeq ($(USE_CRT0_C),true)
-CRT0=crt0.c
-CRT0_OBJ=$(patsubst %.c,%.o, $(CRT0))
-else
-CRT0=crt0.S
-CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0))
-endif
-
+CRT0_SRC = crt0.S
+CRT0_OBJ = crt0.o crt1.o
SSRC=__longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S \
bsd-_setjmp.S syscall.S
@@ -52,14 +44,10 @@ $(LIBC): ar-target
ar-target: $(OBJS) $(CRT0_OBJ)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
- cp $(CRT0_OBJ) $(TOPDIR)lib/$(CRT0_OBJ)
+ cp $(CRT0_OBJ) $(TOPDIR)lib/
-ifeq ($(USE_CRT0_C),true)
-$(CRT0_OBJ): %.o : %.c
-else
-$(CRT0_OBJ): %.o : %.S
-endif
- $(CC) $(CFLAGS) -c $< -o $@
+$(CRT0_OBJ): $(CRT0_SRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(SOBJS): %.o : %.S
diff --git a/libc/sysdeps/linux/i386/crt0.S b/libc/sysdeps/linux/i386/crt0.S
index 88e034ad6..dab5426ff 100644
--- a/libc/sysdeps/linux/i386/crt0.S
+++ b/libc/sysdeps/linux/i386/crt0.S
@@ -63,7 +63,7 @@ _start:
pushl %ebp /* callers %ebp (frame pointer) */
movl %esp,%ebp /* mark callers stack frame as invalid */
-#ifdef __UCLIBC_CTOR_DTOR__
+#if defined L_crt1 && defined __UCLIBC_CTOR_DTOR__
/* Push .init and .fini arguments to __uClibc_start_main() on the stack */
pushl $_fini
pushl $_init
diff --git a/libc/sysdeps/linux/i386/crt0.c b/libc/sysdeps/linux/i386/crt0.c
deleted file mode 100644
index 3fe00ec04..000000000
--- a/libc/sysdeps/linux/i386/crt0.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/* uClibc/sysdeps/linux/i386/crt0.S
- * Pull stuff off the stack and get uClibc moving.
- *
- * Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org>
- *
- * This program 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.
- *
- * This program 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.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Stick in a dummy reference to main(), so that if an application
- * is linking when the main() function is in a static library (.a)
- * we can be sure that main() actually gets linked in */
-extern void main(int argc,void *argv,void *envp);
-void (*mainp)(int argc,void *argv,void *envp) = main;
-
-extern void __uClibc_main(int argc,void *argv,void *envp);
-
-void _start(unsigned int first_arg)
-{
- unsigned int argc;
- char **argv, **envp;
- unsigned long *stack;
-
- stack = (unsigned long*) &first_arg;
- argc = *(stack - 1);
- argv = (char **) stack;
- envp = (char **)stack + argc + 1;
-
- __uClibc_main(argc, argv, envp);
-}
-
diff --git a/libc/sysdeps/linux/mips/Makefile b/libc/sysdeps/linux/mips/Makefile
index 080f04394..1fba4ef74 100644
--- a/libc/sysdeps/linux/mips/Makefile
+++ b/libc/sysdeps/linux/mips/Makefile
@@ -25,10 +25,8 @@ TOPDIR=../../../../
include $(TOPDIR)Rules.mak
ASFLAGS=$(CFLAGS)
-TARGET_MACHINE_TYPE=$(shell $(CC) -dumpmachine)
-
-CRT0=crt0.S
-CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0))
+CRT0_SRC = crt0.S
+CRT0_OBJ = crt0.o crt1.o
SSRC=bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S fork.S syscall.S
SOBJS=$(patsubst %.S,%.o, $(SSRC))
@@ -47,9 +45,8 @@ ar-target: $(OBJS) $(CRT0_OBJ)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
cp $(CRT0_OBJ) $(TOPDIR)lib/
-
-$(CRT0_OBJ): %.o : %.S
- $(CC) $(CFLAGS) -c $< -o $@
+$(CRT0_OBJ): $(CRT0_SRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(SOBJS): %.o : %.S
diff --git a/libc/sysdeps/linux/mips/crt0.S b/libc/sysdeps/linux/mips/crt0.S
index 052229819..fdb997b73 100644
--- a/libc/sysdeps/linux/mips/crt0.S
+++ b/libc/sysdeps/linux/mips/crt0.S
@@ -30,7 +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__
+#if defined L_crt1 && defined __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 */
diff --git a/libc/sysdeps/linux/sh/Makefile b/libc/sysdeps/linux/sh/Makefile
index e17838db9..f43c83096 100644
--- a/libc/sysdeps/linux/sh/Makefile
+++ b/libc/sysdeps/linux/sh/Makefile
@@ -25,12 +25,10 @@ TOPDIR=../../../../
include $(TOPDIR)Rules.mak
CFLAGS+= -I../
-SFLAGS= $(CFLAGS) -D__ASSEMBLER__ -DASM_GLOBAL_DIRECTIVE=.globl
+SFLAGS= $(CFLAGS) -D__ASSEMBLER__
-TARGET_MACHINE_TYPE=$(shell $(CC) -dumpmachine)
-
-CRT0=crt0.S
-CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0))
+CRT0_SRC = crt0.S
+CRT0_OBJ = crt0.o crt1.o
SSRC=setjmp.S __longjmp.S vfork.S clone.S
SOBJS=$(patsubst %.S,%.o, $(SSRC))
@@ -47,10 +45,10 @@ $(LIBC): ar-target
ar-target: $(OBJS) $(CRT0_OBJ)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
- cp $(CRT0_OBJ) $(TOPDIR)lib/$(CRT0_OBJ)
+ cp $(CRT0_OBJ) $(TOPDIR)lib/
-$(CRT0_OBJ): %.o : %.S
- $(CC) $(SFLAGS) -c $< -o $@
+$(CRT0_OBJ): $(CRT0_SRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(SOBJS): %.o : %.S
diff --git a/libc/sysdeps/linux/sh/crt0.S b/libc/sysdeps/linux/sh/crt0.S
index cf2b7a6a3..90fba8d34 100644
--- a/libc/sysdeps/linux/sh/crt0.S
+++ b/libc/sysdeps/linux/sh/crt0.S
@@ -49,7 +49,7 @@ _start:
mov.l @r15+,r4
mov r15, r5
-#if ! defined __UCLIBC_CTOR_DTOR__
+#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__
/*
* Setup the value for the environment pointer:
* r6 = (argc + 1) * 4
@@ -58,12 +58,11 @@ _start:
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 */
+ add r5, r6 /* delay slot */
/* We should not get here. */
mov.l L_abort, r0
@@ -76,7 +75,7 @@ _start_end:
L_main:
.long __uClibc_main /* in libuClibc.*.so */
-#else /* __UCLIBC_CTOR_DTOR__ */
+#else /* L_crt1 && __UCLIBC_CTOR_DTOR__ */
/* Push the finip argument to __uClibc_start_main() onto the stack */
mov.l L_fini,r6
mov.l r6,@-r15