Get rid of weak symbols in static objects

Ian Lance Taylor ian@wasabisystems.com
Wed Nov 26 16:42:00 GMT 2003


Momchil Velikov <velco@fadata.bg> writes:

> >> I find useful to maintain the following invariant:
> >> 
> >> "Statically linked executables do not contain undefined symbols
> >> (unless --noinhibit-exec is given)."
> 
> Ian> Why is that useful?
> 
>   It roughly useful by the same reasons dead code elimination is
> useful.

Well, no.  Dead code elimination saves space in the executable and may
save space in the instruction cache.  Changing the handle of
unresolved weak undefined symbols has no comparable effect.

> Besides the generally good idea of being permissive in what
> you accept, but strict in what you output.

Well, it does depend upon your definition of what the proper strict
output is.

> >> From my point of view a weak undefined symbol which never sees a
> Ian> definition really is undefined.  The linker resolves it as though it
> Ian> has the value zero, but the linker never defines it in the usual
> Ian> sense.
> 
>   IMHO, it defines them exactly in the usual sense -- having a value
> to perform relocations with.

But the usual sense does include a symbol, which is absent in this
case.

Ian



More information about the Binutils mailing list