Browse Source

Work from Stefan Allius which allows superH to use the common
method for building crti.o and crtn.o

Eric Andersen 23 years ago
parent
commit
d7643439eb

+ 8 - 2
extra/scripts/initfini.pl

@@ -11,6 +11,7 @@ my($endp)	    = 0;
 my($end)	    = 0;
 my($omitcrti)	    = 0;
 my($omitcrtn)	    = 0;
+my($discard)	    = 0;
 my($line);
 
 # Get commandline parameters
@@ -83,6 +84,10 @@ while(<INITFINI>) {
 	$omitcrtn = 0;
 	next;
     }
+    if (/^i_am_not_a_leaf/) {
+	$discard = 1;
+	next;
+    }
     if (/^_init:/ || /^_fini:/) {
 	$omitcrtn = 1;
     }
@@ -140,12 +145,13 @@ while(<INITFINI>) {
 	    s/ALIGN//;
 	}
     }
-    if (!$omitcrti) {
+    if (!$omitcrti && !$discard) {
 	print CRTI;
     }
-    if (!$omitcrtn) {
+    if (!$omitcrtn && !$discard) {
 	print CRTN;
     }
+    $discard = 0;
 }
 close(INITFINI);
 close(CRTI);

+ 1 - 1
libc/sysdeps/linux/common/Makefile

@@ -1,7 +1,7 @@
 # Makefile for uClibc
 #
 # Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2002 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

+ 6 - 0
libc/sysdeps/linux/common/initfini.c

@@ -42,6 +42,10 @@
    easier to insert the necessary directives into crtn.S. */
 #define SECTION(x) asm (".section " x )
 
+/* Declare symbols as hidden. Hidden symbols are only seen by
+ * the link editor and not by the dynamic loader. */
+#define HIDDEN(func)  asm (".hidden  " #func )
+
 /* The initial common code ends here. */
 asm ("\n/*@HEADER_ENDS*/");
 
@@ -72,6 +76,7 @@ call_gmon_start(void)
 #endif
 
 SECTION (".init");
+HIDDEN(_init);
 extern void _init (void);
 void
 _init (void)
@@ -108,6 +113,7 @@ asm ("\n/*@_init_EPILOG_ENDS*/");
 asm ("\n/*@_fini_PROLOG_BEGINS*/");
 
 SECTION (".fini");
+HIDDEN(_fini);
 extern void _fini (void);
 void
 _fini (void)

+ 1 - 15
libc/sysdeps/linux/sh/Makefile

@@ -45,7 +45,7 @@ all: $(OBJS) $(LIBC)
 
 $(LIBC): ar-target 
 
-ar-target: $(OBJS) $(CRT0_OBJ) $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
+ar-target: $(OBJS) $(CRT0_OBJ)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 	cp $(CRT0_OBJ) $(TOPDIR)lib/$(CRT0_OBJ)
 
@@ -53,20 +53,6 @@ $(CRT0_OBJ): %.o : %.S
 	$(CC) $(SFLAGS) -c $< -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
-crti.o: crti.S
-	$(CC) $(SAFECFLAGS) -c crti.S -o crti.o
-
-$(TOPDIR)lib/crti.o: crti.o
-	mkdir -p $(TOPDIR)lib/
-	cp crti.o $(TOPDIR)lib/
-
-crtn.o: crtn.S
-	$(CC) $(SAFECFLAGS) -c crtn.S -o crtn.o
-
-$(TOPDIR)lib/crtn.o: crtn.o
-	mkdir -p $(TOPDIR)lib/
-	cp crtn.o $(TOPDIR)lib/
-
 $(SOBJS): %.o : %.S
 	$(CC) $(SFLAGS) -c $< -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $*.o

+ 0 - 22
libc/sysdeps/linux/sh/crti.S

@@ -1,22 +0,0 @@
-	.file	"crti.S"
-
-	.section .init
-	.align	2
-	.global	_init
-	.hidden _init
-	.type	_init,@function
-_init:
-	mov.l	r14,@-r15
-	sts.l	pr,@-r15
-	mov	r15,r14
-
-	.section .fini
-	.align	2
-	.global	_fini
-	.hidden _fini
-	.type	_fini,@function
-_fini:
-	mov.l	r14,@-r15
-	sts.l	pr,@-r15
-	mov	r15,r14
-

+ 0 - 17
libc/sysdeps/linux/sh/crtn.S

@@ -1,17 +0,0 @@
-	.file	"crtn.S"
-
-	.section .init
-	mov	r14,r15
-	lds.l	@r15+,pr
-	rts	
-	mov.l	@r15+,r14
-.Lfe1:
-	.size	_init,.Lfe1-_init
-
-	.section .fini
-	mov	r14,r15
-	lds.l	@r15+,pr
-	rts	
-	mov.l	@r15+,r14
-.Lfe2:
-	.size	_fini,.Lfe2-_fini