[PATCH] ld: Limit "readelf --got-contents" tests

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Fri Sep 5 08:17:55 GMT 2025


Hi Jan,

>> If it's about testing the contents of the .got section dump, it would
>> suffice to check the readelf --got-contents output only.  Diffing the
>> outputs of that on Linux/x86_64 and Solaris/amd64 shows only a few
>> differences in addresses easily handled by relaxing the patterns as is
>> done everywhere else:
>> 
>> --- /homes/ro/libgot-1.so.readelf-got.x86_64	2025-09-05 09:58:17.258268114 +0200
>> +++ libgot-1.so.readelf-got.amd64	2025-09-05 09:58:27.948840354 +0200
>> @@ -1,11 +1,11 @@
>>  
>>  Global Offset Table '.got' contains 1 entry:
>>   Index:    Address       Reloc         Sym. Name + Addend/Value
>> -     0: 000000200340 R_X86_64_GLOB_DAT foo + 0
>> +     0: 0000002003c0 R_X86_64_GLOB_DAT foo + 0
>>  
>>  Global Offset Table '.got.plt' contains 4 entries:
>>   Index:    Address       Reloc         Sym. Name + Addend/Value
>> -     0: 000000200348                   200220
>> -     1: 000000200350                   0
>> -     2: 000000200358                   0
>> -     3: 000000200360 R_X86_64_JUMP_SLO bar + 0
>> +     0: 0000002003c8                   2002a0
>> +     1: 0000002003d0                   0
>> +     2: 0000002003d8                   0
>> +     3: 0000002003e0 R_X86_64_JUMP_SLO bar + 0
>> 
>> So it seems that HJs claim that the output is highly Linux-specific and
>> cannot be checked anywhere else is clearly wrong.  That's why I called
>> his patches lazy.
>
> I agree. Judging from the diff above, what's relevant rather looks to be
> the relative position of the entries wrt one another, not the absolute
> addresses. I realize such may be difficult to express in .d files, but I
> don't think that's an excuse to exclude Solaris from testing. If need be,
> make a 2nd expectations file for Solaris.

that would be relatively simple to do: just check for the *_sol2
emulations and set e.g. a sol2 variable to ".sol2" or "", appending
$sol2 to the *.rd filename in binutils.exp and have two correspongind
.rd files.

However, I wonder if this is really necessary: similar tests for
R_X86_64_JUMP_SLOT are more relaxed already:

ld-x86-64/plt-main.rd:[0-9a-f ]+R_X86_64_JUMP_SLOT +0+ +bar \+ 0
ld-x86-64/pr17689now.rd:[0-9a-f ]+R_X86_64_JUMP_SLOT +0+ +.*
ld-x86-64/pr18900b.rd:[0-9a-f ]+R_X86_64_JUMP_SLOT[0-9a-f ]+foo \+ 0

and others are the same.  Only HJ can say if that's ok in this case,
but I suspect it is.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


More information about the Binutils mailing list