]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
readelf: Run --got-contents only on ET_DYN/ET_EXEC files
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 3 Sep 2025 01:07:23 +0000 (18:07 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 3 Sep 2025 12:44:54 +0000 (05:44 -0700)
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>
binutils/readelf.c
binutils/testsuite/binutils-all/readelf-got.d [deleted file]
binutils/testsuite/binutils-all/readelf.exp

index 3205cf2e69eec2a8cb4f112b0e56c236a2f71d25..1514ebc5cb4e19eef3ecd9e556d35737d8130b06 100644 (file)
@@ -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 (file)
index c5b2901..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#name: readelf --got-contents
-#source: pr25543.s
-#readelf: --got-contents
-
-There is no GOT section in this file.
index 10de1e5cf4017854821b37aee47c2ad0b246e7f7..22f2a355bfdf69767390eaeb60710bef4d34cd5a 100644 (file)
@@ -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 {