[PATCH] readelf: Add --plt-contents

H.J. Lu hjl.tools@gmail.com
Tue Sep 9 18:49:06 GMT 2025


On Tue, Sep 9, 2025 at 3:24 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 04.09.2025 15:41, H.J. Lu wrote:
> > Add --plt-contents option to readelf to display contents of PLT sections.
> > --plt-contents option requires:
> >
> > 1. The DT_JMPREL dynamic section for relocations associated with PLT
> > entries.
> > 2. Detailed PLT layout information to extract PLT relocation index and
> > GOT index from PLT entries.
> >
> > When --plt-contents option is used:
> >
> > 1. Allocate an array, plt_relocations, to hold PLT relocations from the
> > DT_JMPREL dynamic section.
> > 2. Allocate an array, all_relocations, to hold all relocations to map
> > GOT entries to corresponding symbols.
> > 3. Process each PLT entry by extracting PLT relocation index and/or GOT
> > index to display symbols or relocation associated with the PLT entry.
> >
> > Only i386 and x86-64 PLTs are supported.
>
> Which would need clarifying in doc, NEWS, and command line help.

Fixed in the v2 patch.

> > $ readelf --plt-contents libfoo.so
> >
> > Procedure Linkage Table '.plt' contains 3 entries:
> >  Index:  Address GOT Idx GOT Addr Rel Idx Symbol/Reloc
> >      0: 00000150
> >      1: 00000160      3: 00200250      0: func
> >      2: 00000170      4: 00200258      1: bar
> >
> > Procedure Linkage Table '.plt.got' contains 1 entry:
> >  Index:  Address GOT Idx GOT Addr Symbol/Reloc
> >      0: 00000180     -1: 00200230 foo
>
> That's omitting a lot of information. Isn't the disassembly of .plt quite
> a bit more meaningful? I question whether the overall more than 3k lines
> of new code (incl testcases) are really worth this new representation form.
>

Adding disassembler to readelf is a separate issue.  In the meantime,
objdump can be used.   --plt-contents provides a different set of
information not available from objdump.   The new code in readelf.c
is around 900 lines.  The rest are mostly tests.

-- 
H.J.


More information about the Binutils mailing list