[PATCH] readelf: Handle 0 sh_entsize of GOT sections for x86
H.J. Lu
hjl.tools@gmail.com
Wed Sep 3 23:28:30 GMT 2025
Some linker sets sh_entsize on .got and .got.plt sections, for example
x86-64 Google chrome browser:
$ readelf -SW /opt/google/chrome/chrome | grep got
[27] .got PROGBITS 000000000fb29fc0 fb27fc0 001be0 00 WA 0 0 8
[28] .got.plt PROGBITS 000000000fb2bba0 fb29ba0 0029a8 00 WA 0 0 8
$
If sh_entsize of GOT sections is 0 for x86, assume 4 for i386 and 8 for
x86-64.
PR binutils/33368
* readelf.c (process_got_section_contents): Handle 0 sh_entsize
of GOT sections for i386 and x86-64.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
binutils/readelf.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 4b1a26602c2..c7a66d2a8e0 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -21150,6 +21150,24 @@ process_got_section_contents (Filedata * filedata)
}
uint32_t entsz = section->sh_entsize;
+ /* NB: Some linker sets sh_entsize on .got and .got.plt
+ sections, for example x86-64 Google chrome browser. */
+ if (entsz == 0)
+ switch (filedata->file_header.e_machine)
+ {
+ default:
+ warn (_("Can't determine section '%s' sh_entsize\n"),
+ name);
+ res = false;
+ goto out;
+ case EM_386:
+ entsz = 4;
+ break;
+ case EM_X86_64:
+ entsz = 8;
+ break;
+ }
+
entries = section->sh_size / entsz;
if (entries == 1)
printf (_("\nGlobal Offset Table '%s' contains 1 entry:\n"),
--
2.51.0
More information about the Binutils
mailing list