ld: rebinding refs to A to symbol B
Richard Earnshaw (lists)
Richard.Earnshaw@arm.com
Fri Jan 31 18:31:51 GMT 2025
On 29/01/2025 12:26, Alan Modra wrote:
> On Wed, Jan 29, 2025 at 10:45:56AM +0000, Richard Earnshaw (lists) wrote:
>> I guess what I'm looking for is something like --rename=A=B, which would operate very much like defsym but would be ignored if A is never referenced in the link set.
>>
>> Do we have anything like that?
>
> Perhaps something along the lines of --defsym 'PROVIDE ( A = B )'
>
Thanks for the suggestion, Alan.
I gave this a try, but I can't get it to work. Firstly I had to change my gcc specs script to
%rename link sync_sync_link
*link:
%{!nostdlib|lgcc: %:find-file(sync-none.ld)} %(sync_sync_link)
and then add yet another file (sync-none.ld) containing:
PROVIDE ( __sync_synchronize = __sync_synchronize_none );
But this still has no effect (I know it's picking it up because I was getting errors before correcting something) and I can see in the linker map
LOAD /work/rearnsha/scratch/gnu/gcc/arm/master/gcc/testsuite/gfortran/../../sync-none.ld
[!provide] PROVIDE (__sync_synchronize = __sync_synchronize_none)
But by the time it prints this out it has already emitted the warning that I'm trying to suppress.
I suspect the problem is that PROVIDE is documented as only generating the definition iff __sync_synchronize is *not* defined, but in my case that isn't true and I need to override the existing definition in libgcc with the alternative.
R.
More information about the Binutils
mailing list