[uClibc] Proposal adding -z defs by default

Joakim Tjernlund joakim.tjernlund at lumentis.se
Thu Nov 4 12:26:46 UTC 2004


> 
> > On Wed Nov 03, 2004 at 06:02:59PM +0100, Joakim Tjernlund wrote:
> > 
> > > > but sadly it does
> > > > indeed whine about missing main, and we can't add even a weak
> > > > main to libc or badness will ensue.  Might be possible to link
> > > 
> > > Badness being ld NOT complaining about missing main when it should?
> > 
> > yep.
> 
> hmm, making main a proteced(.protected main) symbol in crt* files fixes that.
> 

Here is a patch for ppc and x86(the other archs will be done if this OK)


Index: Makefile
===================================================================
RCS file: /var/cvs/uClibc/libc/Makefile,v
retrieving revision 1.36
diff -u -p -r1.36 Makefile
--- Makefile	14 Oct 2004 07:44:43 -0000	1.36
+++ Makefile	4 Nov 2004 12:23:33 -0000
@@ -49,7 +49,7 @@ $(LIBNAME): subdirs ar-target
 
 
 shared: $(TOPDIR)lib/$(LIBNAME)
-	$(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) -o $(SHARED_FULLNAME) \
+	$(LD) $(LDFLAGS) -z defs $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) -o $(SHARED_FULLNAME) \
 		--whole-archive $(LIBNAME) \
 		$(TOPDIR)libc/misc/internals/interp.o --no-whole-archive \
 		-init __uClibc_init $(LIBGCC) $(LDADD_LIBFLOAT)
Index: misc/internals/__uClibc_main.c
===================================================================
RCS file: /var/cvs/uClibc/libc/misc/internals/__uClibc_main.c,v
retrieving revision 1.43
diff -u -p -r1.43 __uClibc_main.c
--- misc/internals/__uClibc_main.c	27 Oct 2004 09:44:00 -0000	1.43
+++ misc/internals/__uClibc_main.c	4 Nov 2004 12:23:34 -0000
@@ -32,7 +32,7 @@ extern void __guard_setup(void);
 /*
  * Prototypes.
  */
-extern int  main(int argc, char **argv, char **envp);
+extern int  main(int argc, char **argv, char **envp) weak_function;
 extern void weak_function _stdio_init(void);
 extern int *weak_const_function __errno_location(void);
 extern int *weak_const_function __h_errno_location(void);
Index: sysdeps/linux/i386/crt0.S
===================================================================
RCS file: /var/cvs/uClibc/libc/sysdeps/linux/i386/crt0.S,v
retrieving revision 1.24
diff -u -p -r1.24 crt0.S
--- sysdeps/linux/i386/crt0.S	21 Aug 2004 21:19:26 -0000	1.24
+++ sysdeps/linux/i386/crt0.S	4 Nov 2004 12:23:36 -0000
@@ -49,6 +49,7 @@ Cambridge, MA 02139, USA.  */
  * is linking when the main() function is in a static library (.a)
  * we can be sure that main() actually gets linked in */
 	.type	main,%function
+	.protected	main
 
 _start:
 	/* locate the start of the environment variables */
Index: sysdeps/linux/powerpc/crt0.S
===================================================================
RCS file: /var/cvs/uClibc/libc/sysdeps/linux/powerpc/crt0.S,v
retrieving revision 1.11
diff -u -p -r1.11 crt0.S
--- sysdeps/linux/powerpc/crt0.S	30 Aug 2004 11:37:47 -0000	1.11
+++ sysdeps/linux/powerpc/crt0.S	4 Nov 2004 12:23:37 -0000
@@ -46,6 +46,7 @@
  * is linking when the main() function is in a static library (.a)
  * we can be sure that main() actually gets linked in */
 	.type	main,%function
+	.protected	main
 
 _start:
 	/* Save the stack pointer, in case we're statically linked under Linux.  */




More information about the uClibc mailing list