OSDN Git Service

Based on discussions with Stefan Allius, change it so that we always
authorEric Andersen <andersen@codepoet.org>
Thu, 12 Dec 2002 10:14:19 +0000 (10:14 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 12 Dec 2002 10:14:19 +0000 (10:14 -0000)
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

libc/sysdeps/linux/arm/Makefile
libc/sysdeps/linux/arm/crt0.S
libc/sysdeps/linux/common/Makefile
libc/sysdeps/linux/i386/Makefile
libc/sysdeps/linux/i386/crt0.S
libc/sysdeps/linux/i386/crt0.c [deleted file]
libc/sysdeps/linux/mips/Makefile
libc/sysdeps/linux/mips/crt0.S
libc/sysdeps/linux/sh/Makefile
libc/sysdeps/linux/sh/crt0.S

index 62facd4..8cd0efa 100644 (file)
@@ -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
index a930ff3..ad0995a 100644 (file)
@@ -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
 
index 8e0ed94..e6828cd 100644 (file)
@@ -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
index aa7b2cd..77c8c81 100644 (file)
 # 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
index 88e034a..dab5426 100644 (file)
@@ -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 (file)
index 3fe00ec..0000000
+++ /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);
-}
-
index 080f043..1fba4ef 100644 (file)
@@ -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
index 0522298..fdb997b 100644 (file)
@@ -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 */
index e17838d..f43c830 100644 (file)
@@ -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
index cf2b7a6..90fba8d 100644 (file)
@@ -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