[uClibc] Proposal adding -z defs by default

Joakim Tjernlund joakim.tjernlund at lumentis.se
Wed Nov 3 08:38:43 UTC 2004


> On Wed, 3 Nov 2004, Joakim Tjernlund wrote:
> 
> > > On Tue, 2 Nov 2004, Joakim Tjernlund wrote:
> > > 
> > > > > Hello!
> > > > > 
> > > > > My proposal is to add -z defs to all relevant locations Rules.mak and some 
> > > > > subdir Makefiles that do not inherit LDFLAGS from Rules.mak to be sure 
> > > > > that we don't end up w/ some undefined symbols. To have this work there is 
> > > > > only one issue how to get -z defs resolve __uClibc_main (reported in an 
> > > > > earlier mail).
> > > > > I can provide a patch to add -z defs to all (less libc.so) lib builds,  
> > > > > the current implementation does not allow to use it generically.
> > > > > It helped me for ex. to catch a failure in the relro patch, w/o it libdl 
> > > > > would have been unusable.
> > > > > The question is only were to add some dummy entry (extern ... attribute 
> > > > > weak) to the sources, so that -z defs will be happy w/ __uClibc_main.
> > > > > 
> > > > > Peter
> > > > 
> > > > Adding "weak_function" to main, "extern int  main(int argc, char **argv, char **envp) weak_function;",
> > > > in libc/misc/internals/__uClibc_main.c would probaly do it.
> > > 
> > > main is undefined, would it work than?
> > > 
> > > Peter
> > 
> > Yes, unless I am mistaken, ld complain that main is undefined in __uClibc_main.c. Making it weak
> > will shut up ld and resolve to NULL iff no main function is found elsewere. That would also mean that
> > if you try ty build an exec and forget to define main, you will probably NOT get a compliant from ld
> > about missing main function.
> 
> Then I wouldn't add that ;-(, it would introduce probably more trouble.
> 
> Would you accept a patch that ignores libc, but adds -z defs to LDFLAGS to 
> all other libs?
> 
> Peter

This is a system wide change and I don't know if there are other side effects, you
better ask Erik.

 Jocke



More information about the uClibc mailing list