[binutils-gdb] readelf: Run --got-contents only on ET_DYN/ET_EXEC files
H.J. Lu
hjl@sourceware.org
Wed Sep 3 12:44:59 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5d3a6f777d50bc72669c4fe02734bd48fd578cd8
commit 5d3a6f777d50bc72669c4fe02734bd48fd578cd8
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Sep 2 18:07:23 2025 -0700
readelf: Run --got-contents only on ET_DYN/ET_EXEC files
Update "readelf --got-contents" to skip on non-ET_DYN/ET_EXEC files.
* readelf.c (process_got_section_contents): Skip if not
ET_DYN/ET_EXEC files.
* testsuite/binutils-all/readelf-got.d: Removed.
* testsuite/binutils-all/readelf.exp: Don't run readelf-got.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Diff:
---
binutils/readelf.c | 9 +++++++++
binutils/testsuite/binutils-all/readelf-got.d | 5 -----
binutils/testsuite/binutils-all/readelf.exp | 1 -
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 3205cf2e69e..1514ebc5cb4 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -21014,6 +21014,15 @@ process_got_section_contents (Filedata * filedata)
if (!do_got_section_contents)
return res;
+ switch (filedata->file_header.e_type)
+ {
+ case ET_DYN:
+ case ET_EXEC:
+ break;
+ default:
+ goto out;
+ }
+
switch (filedata->file_header.e_machine)
{
case EM_MIPS:
diff --git a/binutils/testsuite/binutils-all/readelf-got.d b/binutils/testsuite/binutils-all/readelf-got.d
deleted file mode 100644
index c5b29018f97..00000000000
--- a/binutils/testsuite/binutils-all/readelf-got.d
+++ /dev/null
@@ -1,5 +0,0 @@
-#name: readelf --got-contents
-#source: pr25543.s
-#readelf: --got-contents
-
-There is no GOT section in this file.
diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp
index 10de1e5cf40..22f2a355bfd 100644
--- a/binutils/testsuite/binutils-all/readelf.exp
+++ b/binutils/testsuite/binutils-all/readelf.exp
@@ -402,7 +402,6 @@ if {[which $AS] != 0} then {
run_dump_test "readelf-maskos-1a"
run_dump_test "readelf-maskos-1b"
run_dump_test "readelf-debug-str-offsets-dw4"
- run_dump_test "readelf-got"
if {![istarget *-*-hpux*]} then {
run_dump_test pr26548
if {![binutils_assemble_flags $srcdir/$subdir/pr26548.s tmpdir/pr26548e.o {--defsym ERROR=1}]} then {
More information about the Binutils-cvs
mailing list