aboutsummaryrefslogtreecommitdiff
path: root/binutils/readelf.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2020-05-05 16:16:03 +0100
committerNick Clifton <nickc@redhat.com>2020-05-05 16:16:03 +0100
commit546cb2d85eddba4f56dfbcb0288db68243e3a0fd (patch)
tree35769bf0625cb16c6d8bd6ec734a8648ccfd2bc4 /binutils/readelf.c
parent7d0bd4874453d781a0e6e998b47422f968907bdb (diff)
downloadgdb-546cb2d85eddba4f56dfbcb0288db68243e3a0fd.zip
gdb-546cb2d85eddba4f56dfbcb0288db68243e3a0fd.tar.gz
gdb-546cb2d85eddba4f56dfbcb0288db68243e3a0fd.tar.bz2
Restore readelf's warnings that describe real problems with the file being examined. Fix bug displaying empty file name tables.
binutils* dwarf.c (do_checks): New global variable. (display_formatted_table): Warn about an unexpected number of columns in the table, if checks are enabled. Do not complain about the lack of data following the number of entries in the table if the table is empty. (display_debug_lines_decoded): Only warn about an unexpected number of columns in a table if checks are enabled. * dwarf.h (do_checks): Add a prototype. * elfcomm.c (error): Remove weak attribute. (warn): Likewise. * readelf.c (do_checks): Delete. (warn): Delete. (process_section_headers): Only warn about empty sections if checks are enabled. gas * dwarf2dbg.c (out_dir_and_file_list): Add comments describing the construction of a DWARF-5 directory name table. * testsuite/gas/elf/pr25917.d: Update expected output.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r--binutils/readelf.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 25c2cce..6bf6d52 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -231,7 +231,6 @@ static bfd_boolean do_ctf = FALSE;
static bfd_boolean do_arch = FALSE;
static bfd_boolean do_notes = FALSE;
static bfd_boolean do_archive_index = FALSE;
-static bfd_boolean do_checks = FALSE;
static bfd_boolean check_all = FALSE;
static bfd_boolean is_32bit_elf = FALSE;
static bfd_boolean decompress_dumps = FALSE;
@@ -387,25 +386,6 @@ bfd_vmatoa (char *fmtch, bfd_vma value)
return ret;
}
-/* A version of the warn() function that is disabled if do_checks is not active. */
-
-void
-warn (const char *message, ...)
-{
- va_list args;
-
- if (!do_checks)
- return;
-
- /* Try to keep warning messages in sync with the program's normal output. */
- fflush (stdout);
-
- va_start (args, message);
- fprintf (stderr, _("%s: Warning: "), program_name);
- vfprintf (stderr, message, args);
- va_end (args);
-}
-
/* Retrieve NMEMB structures, each SIZE bytes long from FILEDATA starting at
OFFSET + the offset of the current archive member, if we are examining an
archive. Put the retrieved data into VAR, if it is not NULL. Otherwise
@@ -6378,21 +6358,22 @@ process_section_headers (Filedata * filedata)
case SHT_REL:
CHECK_ENTSIZE (section, i, Rel);
- if (section->sh_size == 0)
+ if (do_checks && section->sh_size == 0)
warn (_("Section '%s': zero-sized relocation section\n"), name);
break;
case SHT_RELA:
CHECK_ENTSIZE (section, i, Rela);
- if (section->sh_size == 0)
+ if (do_checks && section->sh_size == 0)
warn (_("Section '%s': zero-sized relocation section\n"), name);
break;
case SHT_NOTE:
case SHT_PROGBITS:
- if (section->sh_size == 0)
- /* This is not illegal according to the ELF standard, but
- it might be an indication that something is wrong. */
+ /* Having a zero sized section is not illegal according to the
+ ELF standard, but it might be an indication that something
+ is wrong. So issue a warning if we are running in lint mode. */
+ if (do_checks && section->sh_size == 0)
warn (_("Section '%s': has a size of zero - is this intended ?\n"), name);
break;