[Dwarf-discuss] DW_AT_MIPS_linkage_name

Chris Quenelle Chris.Quenelle
Thu Mar 24 17:15:54 GMT 2005

> If I understand you, you're talking about referencing the symbol name via
> DW_AT_low_pc, and then marking the symbol as weak so that it would use the
> value 0 if not encountered in any other objects in the linked executable.

yup, that's what my thought is.
I hate using weak symbols, I always get burned in strange ways.
But it's one of the mechanisms at my disposal, so I have to consider it.

> We tried doing that for a different situation, and the results were
> unpleasant.  If the symbol appears anywhere in a library, Gnu ld prefers the
> "strong" version from the library over the weak version.  As a result, you
> end up with routines being pulled into the executable when they aren't needed
> for execution, but simply are referenced by Dwarf.

The Sun linker won't do that unless you turn on -z weakextract or -z allextract.
By default it won't do that.

> We concluded that to do this, we needed an indication on the reference itself
> (as opposed to the symbol) that meant something like:
>    This reference never should imply that the referenced symbol should be
>    included in the application.  But if it ends up in the application for
>    some other reason (e.g. it was in an explicitly-named object file, there
>    was a normal reference that did require it, etc.), reference it.  And if
>    not, just reference 0.

This sounds exactly like what 'weak' symbol references are supposed to do for you.

> And that no such indication existed.
> But, hey, if you find a way to do what you're talking about without having to
> change ld, I'd sure like to hear about it.  :)

I tried a simple test of weak symbol extract from archive libraries and
gcc 3.4.3 seems to act like I expect, it works the same way on Solaris
using the Sun linker.


More information about the Dwarf-discuss mailing list