mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 05:47:26 +08:00
Fix compile time warnings about the possibility of using uninitialised fields in the Elf_Internal_Chdr structure when building readelf.
* readelf.c (get_compression_header): Add ATTRIBUTE_WARN_UNUSED_RESULT. (process_section_headers): Check the return value from get_compression_header. (dump_section_as_strings): Likewise. (dump_section_as_bytes): Likewise. (load_specific_debug_section): Likewise.
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
2020-03-20 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* readelf.c (get_compression_header): Add ATTRIBUTE_WARN_UNUSED_RESULT.
|
||||||
|
(process_section_headers): Check the return value from
|
||||||
|
get_compression_header.
|
||||||
|
(dump_section_as_strings): Likewise.
|
||||||
|
(dump_section_as_bytes): Likewise.
|
||||||
|
(load_specific_debug_section): Likewise.
|
||||||
|
|
||||||
2020-03-20 H.J. Lu <hongjiu.lu@intel.com>
|
2020-03-20 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* ar.c (main): Update bfd_plugin_set_program_name call.
|
* ar.c (main): Update bfd_plugin_set_program_name call.
|
||||||
|
@ -6076,7 +6076,7 @@ get_elf_section_flags (Filedata * filedata, bfd_vma sh_flags)
|
|||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int ATTRIBUTE_WARN_UNUSED_RESULT
|
||||||
get_compression_header (Elf_Internal_Chdr *chdr, unsigned char *buf, bfd_size_type size)
|
get_compression_header (Elf_Internal_Chdr *chdr, unsigned char *buf, bfd_size_type size)
|
||||||
{
|
{
|
||||||
if (is_32bit_elf)
|
if (is_32bit_elf)
|
||||||
@ -6728,8 +6728,10 @@ process_section_headers (Filedata * filedata)
|
|||||||
{
|
{
|
||||||
Elf_Internal_Chdr chdr;
|
Elf_Internal_Chdr chdr;
|
||||||
|
|
||||||
(void) get_compression_header (&chdr, buf, sizeof (buf));
|
if (get_compression_header (&chdr, buf, sizeof (buf)) == 0)
|
||||||
|
printf (_(" [<corrupt>]\n"));
|
||||||
|
else
|
||||||
|
{
|
||||||
if (chdr.ch_type == ELFCOMPRESS_ZLIB)
|
if (chdr.ch_type == ELFCOMPRESS_ZLIB)
|
||||||
printf (" ZLIB, ");
|
printf (" ZLIB, ");
|
||||||
else
|
else
|
||||||
@ -6741,6 +6743,7 @@ process_section_headers (Filedata * filedata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!do_section_details)
|
if (!do_section_details)
|
||||||
{
|
{
|
||||||
@ -13692,6 +13695,10 @@ dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata)
|
|||||||
unsigned int compression_header_size
|
unsigned int compression_header_size
|
||||||
= get_compression_header (& chdr, (unsigned char *) start,
|
= get_compression_header (& chdr, (unsigned char *) start,
|
||||||
num_bytes);
|
num_bytes);
|
||||||
|
if (compression_header_size == 0)
|
||||||
|
/* An error message will have already been generated
|
||||||
|
by get_compression_header. */
|
||||||
|
goto error_out;
|
||||||
|
|
||||||
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
|
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
|
||||||
{
|
{
|
||||||
@ -13904,6 +13911,11 @@ dump_section_as_bytes (Elf_Internal_Shdr * section,
|
|||||||
unsigned int compression_header_size
|
unsigned int compression_header_size
|
||||||
= get_compression_header (& chdr, start, section_size);
|
= get_compression_header (& chdr, start, section_size);
|
||||||
|
|
||||||
|
if (compression_header_size == 0)
|
||||||
|
/* An error message will have already been generated
|
||||||
|
by get_compression_header. */
|
||||||
|
goto error_out;
|
||||||
|
|
||||||
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
|
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
|
||||||
{
|
{
|
||||||
warn (_("section '%s' has unsupported compress type: %d\n"),
|
warn (_("section '%s' has unsupported compress type: %d\n"),
|
||||||
@ -14237,6 +14249,10 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
|
|||||||
}
|
}
|
||||||
|
|
||||||
compression_header_size = get_compression_header (&chdr, start, size);
|
compression_header_size = get_compression_header (&chdr, start, size);
|
||||||
|
if (compression_header_size == 0)
|
||||||
|
/* An error message will have already been generated
|
||||||
|
by get_compression_header. */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
|
if (chdr.ch_type != ELFCOMPRESS_ZLIB)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user