[PATCH v2] readelf: Handle 0 sh_entsize of GOT sections for x86

H.J. Lu hjl.tools@gmail.com
Thu Sep 4 13:08:38 GMT 2025


On Wed, Sep 3, 2025 at 11:05 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 04.09.2025 03:02, H.J. Lu wrote:
> > --- a/binutils/readelf.c
> > +++ b/binutils/readelf.c
> > @@ -21150,6 +21150,30 @@ process_got_section_contents (Filedata * filedata)
> >         }
> >
> >       uint32_t entsz = section->sh_entsize;
> > +     /* NB: Some linker sets sh_entsize to 0 on .got and .got.plt
                                            ^^^^^^^^^^^^^^^^^^^^
> > +        sections, for example x86-64 Google chrome browser.  */
>
> Didn't you say you would adjust this comment, as per Alan's remark?

See ^^^^^^^^^^^^^^^^^^^^ above.

> > +     if (entsz == 0)
> > +       switch (filedata->file_header.e_machine)
> > +         {
> > +         default:
> > +           if (is_32bit_elf)
> > +             {
> > +               /* NB: ELFCLASS32 may use 8 byte GOT sh_entsize,
> > +                  like x32.  */
>
> The comment contradicts ...
>
> > +               warn (_("Can't determine section '%s' sh_entsize\n"),
> > +                     name);
> > +               res = false;
> > +               goto out;
> > +             }
> > +           /* Fall through.  */
> > +         case EM_X86_64:
>
> ... this case label, as x32 will land here afaict. I'm also unconvinced
> of penalizing all non-x86 32-bit architectures, just because of the x32
> special case. I'd rather see it done the other way around: Go from
> EI_CLASS generally and add a special case for x32. More special casing
> can be added as needed.
>

Fixed in the v3 patch.

-- 
H.J.


More information about the Binutils mailing list