From: H.J. Lu Date: Wed, 3 Sep 2025 01:07:23 +0000 (-0700) Subject: readelf: Run --got-contents only on ET_DYN/ET_EXEC files X-Git-Tag: gdb-17-branchpoint~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5d3a6f777d50bc72669c4fe02734bd48fd578cd8;p=thirdparty%2Fbinutils-gdb.git 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 --- 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 {