Surprising result with ld -r

Cary Coutant ccoutant@gmail.com
Mon Apr 16 17:21:00 GMT 2018
> One would think that ld -r would resolve the global symbols it can resolve
> at each step, rather than waiting for the final link to resolve globals that
> are defined early.

They're still global symbols, so if there's a pre-empting definition
in a subsequent link, we need to bind the references to the
pre-empting definition. We can't bind the reference during the -r link
unless you make the symbol local. Some older Unix linkers had a -h
option do this, but the Gnu linkers don't have such an option (-h
means something else now). You can, however, use "objcopy
--localize-symbol=foo" after the -r link to localize the symbol, which
will force the binding.

-cary



More information about the Binutils mailing list