diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2025-09-01 11:00:43 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2025-09-02 08:29:26 -0700 |
commit | eae0da7eb450546da6551a625aa3a5c6328c1c9f (patch) | |
tree | 52de9141e917d17c4fed04cbcaa2973b095d4204 | |
parent | eb3e0ff4f191ecc43579233df43295c648ce918e (diff) | |
download | binutils-eae0da7eb450546da6551a625aa3a5c6328c1c9f.zip binutils-eae0da7eb450546da6551a625aa3a5c6328c1c9f.tar.gz binutils-eae0da7eb450546da6551a625aa3a5c6328c1c9f.tar.bz2 |
readelf: Report if no GOT section found
Update "readelf --got-contents" to report if no GOT section found.
* readelf.c (process_got_section_contents): Report if no GOT
section found.
* testsuite/binutils-all/readelf-got.d: New file.
* testsuite/binutils-all/readelf.exp: Run readelf-got.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
-rw-r--r-- | binutils/readelf.c | 13 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf-got.d | 5 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.exp | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c index 2affc71..2f8dda8 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -21009,6 +21009,7 @@ process_got_section_contents (Filedata * filedata) uint64_t entries; unsigned char *data; bool res = true; + bool found = false; if (!do_got_section_contents) return res; @@ -21020,6 +21021,7 @@ process_got_section_contents (Filedata * filedata) /* process_mips_specific also displays GOT related contents. */ if (!do_arch) res = process_mips_specific (filedata, true); + found = true; goto out; } @@ -21039,6 +21041,8 @@ process_got_section_contents (Filedata * filedata) if (!startswith (name, ".got")) continue; + found = true; + data = (unsigned char *) get_section_contents (section, filedata); if (data == NULL) @@ -21122,6 +21126,15 @@ process_got_section_contents (Filedata * filedata) } out: + if (! found) + { + if (filedata->is_separate) + printf (_("\nThere is no GOT section in linked file '%s'.\n"), + filedata->file_name); + else + printf (_("\nThere is no GOT section in this file.\n")); + } + for (size_t j = 0; j < all_relocations_count; j++) free (all_relocations_root[j].r_symbol); free (all_relocations_root); diff --git a/binutils/testsuite/binutils-all/readelf-got.d b/binutils/testsuite/binutils-all/readelf-got.d new file mode 100644 index 0000000..c5b2901 --- /dev/null +++ b/binutils/testsuite/binutils-all/readelf-got.d @@ -0,0 +1,5 @@ +#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 22f2a35..10de1e5 100644 --- a/binutils/testsuite/binutils-all/readelf.exp +++ b/binutils/testsuite/binutils-all/readelf.exp @@ -402,6 +402,7 @@ 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 { |