Suppress the fetch of an archive member via --defsym (glibc/elf/librtld.map.o)
Florian Weimer
fw@deneb.enyo.de
Sat Apr 11 17:04:30 GMT 2020
* Michael Matz:
> On Mon, 16 Mar 2020, Fangrui Song via Binutils wrote:
>> I am concerned that the --defsym's order dependence with archive files is not
>> so obvious, given -u's behavior:
>>
>> # -u inserts an undefined which fetches b.a(b.o)
>> ld.bfd -u foo b.a # b.a(b.o) is fetched. free is present
>> # This can't be order dependent because b.a (not in a group) should have been
>> dropped when we saw -u
>> ld.bfd b.a -u foo # b.a(b.o) is fetched. free is present
>>
>> Some observations:
>>
>>
>> # GNU ld --defsym interacts with an archive
>> ld.bfd a.o b.a --defsym foo=0 # b.a(b.o) is fetched. free is present
>> ld.bfd --defsym foo=0 a.o b.a # b.a(b.o) is not fetched. free is absent
>
> I consider this the correct linker behaviour. In that sense I would
> consider the inconsistency with -u and -T to be the problems of those, not
> a problem of --defsym (but not necessarily problems we can fix anymore, as
> people might rely on that). (i.e. I think the second -u command above
> should result in an 'undefined foo' output/error, not in b.a(b.o) being
> fetched).
I agree, the ld.bfd behavior seems the most reasonable one to me.
More information about the Binutils
mailing list