bfd/
* Makefile.am (BFD32_LIBS): Add compress.lo. (BFD32_LIBS_CFILES): Add compress.c. (BFD_H_FILES): Likewise. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf2.c (read_section): New function. (read_indirect_string): Call new function read_section. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Call new function read_section when just one .zdebug_info section is found, otherwise read and compress multiple sections. (_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr. * elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix. (special_sections_z): New struct. (special_sections): Refer to special_sections_z. * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize sections named .zdebug_*. (_bfd_mips_elf_fake_sections): Likewise. * compress.c: New file. (bfd_uncompress_section_contents): New function. bfd/doc/ * Makefile.am (BFD_H_DEP): Add ../compress.c. * Makefile.in: Regenerate. binutils/ * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf.c (debug_displays): Add .zdebug_* strings. * dwarf.h (struct dwarf_section): Add fields uncompressed_namd and compressed_name. * objdump.c (load_debug_section): Call bfd_uncompress_section_contents when loading a compressed section. (dump_dwarf_section): Recognize compressed section name. (mach_o_dwarf_sections): Rename as mach_o_uncompressed_dwarf_sections. (mach_o_compressed_dwarf_sections): New variable. (generic_dwarf_section): Rename as generic_uncompressed_dwarf_sections. (generic_compressed_dwarf_sections): New variable. (check_mach_o_dwarf): Save and restore mach_o_compressed_dwarf_sections. * readelf.c: Add #include for config.h and zlib.h (process_section_headers): Recognize compressed section name. (uncompress_section_contents): New function. (load_debug_section): Call uncompress_section_contents when loading a compressed section. (display_debug_section): Recognize compressed section name. binutils/testsuite: * binutils-all/objdump.exp: Add test for objdump -s on a file with a compressed debug section. Add test for objdump -W on a file that contains a compressed debug section. * binutils-all/readelf.exp: Call readelf_compressed_wa_test. (readelf_compressed_wa_test): New function. * binutils-all/dw2-compressed.S: New file. * binutils-all/objdump.W: New file. * binutils-all/objdump.s: New file. * binutils-all/readelf.wa: New file.
This commit is contained in:
parent
67f9f80fe8
commit
1b31505692
31 changed files with 1968 additions and 799 deletions
|
@ -2062,13 +2062,28 @@ load_debug_section (enum dwarf_section_display_enum debug, void *file)
|
|||
bfd *abfd = file;
|
||||
asection *sec;
|
||||
bfd_boolean ret;
|
||||
int section_is_compressed;
|
||||
|
||||
/* If it is already loaded, do nothing. */
|
||||
if (section->start != NULL)
|
||||
return 1;
|
||||
|
||||
/* Locate the debug section. */
|
||||
sec = bfd_get_section_by_name (abfd, section->name);
|
||||
sec = bfd_get_section_by_name (abfd, section->uncompressed_name);
|
||||
if (sec != NULL)
|
||||
{
|
||||
section->name = section->uncompressed_name;
|
||||
section_is_compressed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sec = bfd_get_section_by_name (abfd, section->compressed_name);
|
||||
if (sec != NULL)
|
||||
{
|
||||
section->name = section->compressed_name;
|
||||
section_is_compressed = 1;
|
||||
}
|
||||
}
|
||||
if (sec == NULL)
|
||||
return 0;
|
||||
|
||||
|
@ -2097,11 +2112,24 @@ load_debug_section (enum dwarf_section_display_enum debug, void *file)
|
|||
ret = bfd_get_section_contents (abfd, sec, section->start, 0,
|
||||
section->size);
|
||||
|
||||
if (!ret)
|
||||
if (! ret)
|
||||
{
|
||||
free_debug_section (debug);
|
||||
printf (_("\nCan't get contents for section '%s'.\n"),
|
||||
section->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (section_is_compressed)
|
||||
{
|
||||
bfd_size_type size = section->size;
|
||||
if (! bfd_uncompress_section_contents (§ion->start, &size))
|
||||
{
|
||||
free_debug_section (debug);
|
||||
printf (_("\nCan't uncompress section '%s'.\n"), section->name);
|
||||
return 0;
|
||||
}
|
||||
section->size = size;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -2135,15 +2163,16 @@ dump_dwarf_section (bfd *abfd, asection *section,
|
|||
match = name;
|
||||
|
||||
for (i = 0; i < max; i++)
|
||||
if (strcmp (debug_displays[i].section.name, match) == 0)
|
||||
if (strcmp (debug_displays [i].section.uncompressed_name, match) == 0
|
||||
|| strcmp (debug_displays [i].section.compressed_name, match) == 0)
|
||||
{
|
||||
if (!debug_displays[i].eh_frame)
|
||||
if (!debug_displays [i].eh_frame)
|
||||
{
|
||||
struct dwarf_section *sec = &debug_displays [i].section;
|
||||
|
||||
if (load_debug_section (i, abfd))
|
||||
{
|
||||
debug_displays[i].display (sec, abfd);
|
||||
debug_displays [i].display (sec, abfd);
|
||||
|
||||
if (i != info && i != abbrev)
|
||||
free_debug_section (i);
|
||||
|
@ -2153,7 +2182,7 @@ dump_dwarf_section (bfd *abfd, asection *section,
|
|||
}
|
||||
}
|
||||
|
||||
static const char *mach_o_dwarf_sections [] = {
|
||||
static const char *mach_o_uncompressed_dwarf_sections [] = {
|
||||
"LC_SEGMENT.__DWARFA.__debug_abbrev", /* .debug_abbrev */
|
||||
"LC_SEGMENT.__DWARFA.__debug_aranges", /* .debug_aranges */
|
||||
"LC_SEGMENT.__DWARFA.__debug_frame", /* .debug_frame */
|
||||
|
@ -2172,7 +2201,27 @@ static const char *mach_o_dwarf_sections [] = {
|
|||
"LC_SEGMENT.__DWARFA.__debug_weaknames" /* .debug_weaknames */
|
||||
};
|
||||
|
||||
static const char *generic_dwarf_sections [max];
|
||||
static const char *mach_o_compressed_dwarf_sections [] = {
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_abbrev", /* .zdebug_abbrev */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_aranges", /* .zdebug_aranges */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_frame", /* .zdebug_frame */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_info", /* .zdebug_info */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_line", /* .zdebug_line */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_pubnames", /* .zdebug_pubnames */
|
||||
".eh_frame", /* .eh_frame */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_macinfo", /* .zdebug_macinfo */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_str", /* .zdebug_str */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_loc", /* .zdebug_loc */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_pubtypes", /* .zdebug_pubtypes */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_ranges", /* .zdebug_ranges */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_static_func", /* .zdebug_static_func */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_static_vars", /* .zdebug_static_vars */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_types", /* .zdebug_types */
|
||||
"LC_SEGMENT.__DWARFA.__zdebug_weaknames" /* .zdebug_weaknames */
|
||||
};
|
||||
|
||||
static const char *generic_uncompressed_dwarf_sections [max];
|
||||
static const char *generic_compressed_dwarf_sections [max];
|
||||
|
||||
static void
|
||||
check_mach_o_dwarf (bfd *abfd)
|
||||
|
@ -2181,18 +2230,33 @@ check_mach_o_dwarf (bfd *abfd)
|
|||
enum bfd_flavour current_flavour = bfd_get_flavour (abfd);
|
||||
enum dwarf_section_display_enum i;
|
||||
|
||||
if (generic_dwarf_sections [0] == NULL)
|
||||
if (generic_uncompressed_dwarf_sections [0] == NULL)
|
||||
for (i = 0; i < max; i++)
|
||||
generic_dwarf_sections [i] = debug_displays[i].section.name;
|
||||
{
|
||||
generic_uncompressed_dwarf_sections [i]
|
||||
= debug_displays[i].section.uncompressed_name;
|
||||
generic_compressed_dwarf_sections [i]
|
||||
= debug_displays[i].section.compressed_name;
|
||||
}
|
||||
|
||||
if (old_flavour != current_flavour)
|
||||
{
|
||||
if (current_flavour == bfd_target_mach_o_flavour)
|
||||
for (i = 0; i < max; i++)
|
||||
debug_displays[i].section.name = mach_o_dwarf_sections [i];
|
||||
{
|
||||
debug_displays[i].section.uncompressed_name
|
||||
= mach_o_uncompressed_dwarf_sections [i];
|
||||
debug_displays[i].section.compressed_name
|
||||
= mach_o_compressed_dwarf_sections [i];
|
||||
}
|
||||
else if (old_flavour == bfd_target_mach_o_flavour)
|
||||
for (i = 0; i < max; i++)
|
||||
debug_displays[i].section.name = generic_dwarf_sections [i];
|
||||
{
|
||||
debug_displays[i].section.uncompressed_name
|
||||
= generic_uncompressed_dwarf_sections [i];
|
||||
debug_displays[i].section.compressed_name
|
||||
= generic_compressed_dwarf_sections [i];
|
||||
}
|
||||
|
||||
old_flavour = current_flavour;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue