Surprising result with ld -r

Douglas B Rupp rupp@adacore.com
Tue Apr 17 06:45:00 GMT 2018



On 04/16/2018 07:21 PM, Cary Coutant wrote:
>> 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
> 

A switch to localize all symbols can be resolved in a partial link would 
be a welcome enhancement to Gnu ld for us.

Would such an enhancement, if submitted, but considered for inclusion in 
ld, do you think?

--Doug



More information about the Binutils mailing list