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

H.J. Lu hjl.tools@gmail.com
Fri Sep 5 12:32:25 GMT 2025


On Fri, Sep 5, 2025 at 5:25 AM Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>
> Hi H.J.,
>
> >> > 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.
> >>
> >> Jan
> >
> > These tests are generic x86 tests, not Linux specific.  If Rainer believes
> > that a Solaris specific test is needed, he can add one.
>
> you still haven't explained why the specific addresses matter at all for
> this specific test when they don't for most other similar tests.  Just
> asserting they do instead of explaining doesn't help.

"readelf --got-contents" dumps indices and addresses.  If the expected
outputs are arbitrary values, these tests are ineffective.

> And please: so far I've been operating under the assumption that
> binutils is a cross-target project supposed to work on all sorts of OSes
> and targets.  If this has changed recently, turning it Linux/x86_64

It is the other way around.   Linux uses generic ELF emulation.  It
sets ELFOSABI_GNU only if Linux specific extensions are used.
If Solaris needs special treatments, someone needs to do the
work.

> only, I'd like to know since all my efforts are completely in vain
> then...
>
>         Rainer
>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University



-- 
H.J.


More information about the Binutils mailing list