[RFC PATCH] readelf: Add -G/--got-contents options

Maciej W. Rozycki macro@orcam.me.uk
Thu Aug 28 03:15:36 GMT 2025


On Tue, 26 Aug 2025, H.J. Lu wrote:

> Add -G/--got-contents options to readelf, inspired by the similar option
> on Solaris, to display the contents of GOT sections:
> 
> $ readelf -G libfoo.so
> 
> Global Offset Table '.got' contains 5 entries:
>  Index:    Address       Reloc         Sym. Name + Addend/Value
>      0: 000000002fc8 R_X86_64_GLOB_DAT bar + 0
>      1: 000000002fd0 R_X86_64_GLOB_DAT __gmon_start__ + 0
>      2: 000000002fd8 R_X86_64_GLOB_DAT _ITM_registerTMCloneTable + 0
>      3: 000000002fe0 R_X86_64_GLOB_DAT __cxa_finalize@GLIBC_2.2.5 + 0
>      4: 000000002fe8                   0
> 
> Global Offset Table '.got.plt' contains 4 entries:
>  Index:    Address       Reloc         Sym. Name + Addend/Value
>      0: 000000002ff0                   2dd0
>      1: 000000002ff8                   0
>      2: 000000003000 R_X86_64_JUMP_SLO printf@GLIBC_2.2.5 + 2c0
>      3: 000000003008                   0
> 
> Any comments?

 Why invent a new option?  The MIPS target has it under `-A', e.g.:

$ readelf -A libdl.so.2
Attribute Section: gnu
File Attributes
  Tag_GNU_MIPS_ABI_FP: Hard float (double precision)

MIPS ABI Flags Version: 0

ISA: MIPS1
GPR size: 32
CPR1 size: 32
CPR2 size: 0
FP ABI: Hard float (double precision)
ISA Extension: None
ASEs:
	None
FLAGS 1: 00000000
FLAGS 2: 00000000

Primary GOT:
 Canonical gp value: 00027ff0

 Reserved entries:
   Address     Access  Initial Purpose
  00020000 -32752(gp) 00000000 Lazy resolver
  00020004 -32748(gp) 80000000 Module pointer (GNU extension)

 Local entries:
   Address     Access  Initial
  00020008 -32744(gp) 00020000
  0002000c -32740(gp) 00020030
  00020010 -32736(gp) 00000000
  00020014 -32732(gp) 00000000
  00020018 -32728(gp) 00000000
  0002001c -32724(gp) 00000000

 Global entries:
   Address     Access  Initial Sym.Val. Type    Ndx Name
  00020020 -32720(gp) 00000000 00000000 NOTYPE  UND _ITM_registerTMCloneTable
  00020024 -32716(gp) 00000000 00000000 FUNC    UND __gmon_start__
  00020028 -32712(gp) 00000000 00000000 NOTYPE  UND _ITM_deregisterTMCloneTable
  0002002c -32708(gp) 00000000 00000000 FUNC    UND __cxa_finalize

  Maciej


More information about the Binutils mailing list