aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-07-10 10:23:12 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-07-10 10:23:12 -0700
commit813dabb9f0413c3391035300e9af083513ce83fb (patch)
tree293cf3238dd883ee3517245b32947b87211497de /binutils
parent209ce4c2de420e5d55649eecdcb3e8a837fa546f (diff)
downloadgdb-813dabb9f0413c3391035300e9af083513ce83fb.zip
gdb-813dabb9f0413c3391035300e9af083513ce83fb.tar.gz
gdb-813dabb9f0413c3391035300e9af083513ce83fb.tar.bz2
Warn unsupported compress type and corrupted compressed section
* readelf.c (dump_section_as_strings): Warn unsupported compress type and corrupted compressed section. (dump_section_as_bytes): Likewise. (load_specific_debug_section): Likewise.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/readelf.c51
2 files changed, 45 insertions, 13 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 53b69ca..09b0e1c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2015-07-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ * readelf.c (dump_section_as_strings): Warn unsupported compress
+ type and corrupted compressed section.
+ (dump_section_as_bytes): Likewise.
+ (load_specific_debug_section): Likewise.
+
2015-07-09 Catherine Moore <clm@codesourcery.com>
* readelf.c (print_mips_fp_abi_value): Handle
diff --git a/binutils/readelf.c b/binutils/readelf.c
index ceedf3d..55faf83 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -12030,13 +12030,21 @@ dump_section_as_strings (Elf_Internal_Shdr * section, FILE * file)
unsigned int compression_header_size
= get_compression_header (& chdr, (unsigned char *) start);
- if (chdr.ch_type == ELFCOMPRESS_ZLIB
- && chdr.ch_addralign == section->sh_addralign)
+ if (chdr.ch_type != ELFCOMPRESS_ZLIB)
{
- uncompressed_size = chdr.ch_size;
- start += compression_header_size;
- new_size -= compression_header_size;
+ warn (_("section '%s' has unsupported compress type: %d\n"),
+ printable_section_name (section), chdr.ch_type);
+ return;
+ }
+ else if (chdr.ch_addralign != section->sh_addralign)
+ {
+ warn (_("compressed section '%s' is corrupted\n"),
+ printable_section_name (section));
+ return;
}
+ uncompressed_size = chdr.ch_size;
+ start += compression_header_size;
+ new_size -= compression_header_size;
}
else if (new_size > 12 && streq ((char *) start, "ZLIB"))
{
@@ -12156,13 +12164,21 @@ dump_section_as_bytes (Elf_Internal_Shdr * section,
unsigned int compression_header_size
= get_compression_header (& chdr, start);
- if (chdr.ch_type == ELFCOMPRESS_ZLIB
- && chdr.ch_addralign == section->sh_addralign)
+ if (chdr.ch_type != ELFCOMPRESS_ZLIB)
{
- uncompressed_size = chdr.ch_size;
- start += compression_header_size;
- new_size -= compression_header_size;
+ warn (_("section '%s' has unsupported compress type: %d\n"),
+ printable_section_name (section), chdr.ch_type);
+ return;
}
+ else if (chdr.ch_addralign != section->sh_addralign)
+ {
+ warn (_("compressed section '%s' is corrupted\n"),
+ printable_section_name (section));
+ return;
+ }
+ uncompressed_size = chdr.ch_size;
+ start += compression_header_size;
+ new_size -= compression_header_size;
}
else if (new_size > 12 && streq ((char *) start, "ZLIB"))
{
@@ -12290,9 +12306,18 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
Elf_Internal_Chdr chdr;
unsigned int compression_header_size
= get_compression_header (&chdr, start);
- if (chdr.ch_type != ELFCOMPRESS_ZLIB
- || chdr.ch_addralign != sec->sh_addralign)
- return 0;
+ if (chdr.ch_type != ELFCOMPRESS_ZLIB)
+ {
+ warn (_("section '%s' has unsupported compress type: %d\n"),
+ section->name, chdr.ch_type);
+ return 0;
+ }
+ else if (chdr.ch_addralign != sec->sh_addralign)
+ {
+ warn (_("compressed section '%s' is corrupted\n"),
+ section->name);
+ return 0;
+ }
uncompressed_size = chdr.ch_size;
start += compression_header_size;
size -= compression_header_size;