Linker plugins should be aware of --defsym during symbol resolution

Cary Coutant
Wed Feb 14 00:04:00 GMT 2018

>> Do you have a real-world example? I'm having trouble imagining a case
>> where --defsym would be used to override a symbol that's subject to
>> the ODR and yet remain a valid program.
> I just concocted one:
> ...
> With defsym:
> $ ~/llvm/llvm_8_build/bin/clang++ hello[12].cc  -fuse-ld=gold
> -Wl,--defsym,_Z3barv=_Z3bazv

To me, this is the same as providing an overriding definition of bar()
that prints "in baz", which clearly violates the one-definition rule.
On what basis do you consider this a valid thing to do, to the extent
that you want to preserve the unoptimized behavior across LTO?

Is there a real-world example where someone would want to do this in
production code? I'm afraid I'd have zero sympathy for them. If they
want something like that to work, they should just turn off
cross-module inlining.

I need a lot more justification to extend the plugin API.


More information about the Binutils mailing list