From 0acf065b19253e02ea32188ea0cbdf4e80e3c42d Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Sat, 3 Jul 2010 20:52:24 +0000 Subject: bfd/ChangeLog: * compress.c (bfd_uncompress_section_contents): Add ATTRIBUTE_UNUSED. * dwarf2.c (read_and_uncompress_section): New function. (read_section): Call it. (find_line): Likewise. binutils/ChangeLog: * objdump.c (load_specific_debug_section): Decompress section contents before applying relocations. * readelf.c (load_specific_debug_section): Update section size after decompression. gas/ChangeLog: * Makefile.am: Add compress-debug.c and compress-debug.h. * Makefile.in: Regenerate. * config.in: Add HAVE_ZLIB_H. * configure.in: Check for zlib.h. * configure: Regenerate. * as.c (parse_args): Add --compress-debug-sections and --nocompress-debug-sections. * as.h (flag_compress_debug): New variable. * compress-debug.c: New file. * compress-debug.h: New file. * write.c: Include compress-debug.h. (compress_frag): New function. (compress_debug): New function. (write_object_file): Compress debug sections if requested. --- binutils/ChangeLog | 7 +++++++ binutils/objdump.c | 34 ++++++++++++++++++++++++++-------- binutils/readelf.c | 7 +++++-- 3 files changed, 38 insertions(+), 10 deletions(-) (limited to 'binutils') diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 0007863..74d22ed 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,10 @@ +2010-07-03 Cary Coutant + + * objdump.c (load_specific_debug_section): Decompress section contents + before applying relocations. + * readelf.c (load_specific_debug_section): Update section size after + decompression. + 2010-06-29 Alan Modra PR binutils/3166 diff --git a/binutils/objdump.c b/binutils/objdump.c index 2a419b7..f94dee9 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -2205,14 +2205,8 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, section->size = bfd_get_section_size (sec); section->start = (unsigned char *) xmalloc (section->size); - if (is_relocatable && debug_displays [debug].relocate) - ret = bfd_simple_get_relocated_section_contents (abfd, - sec, - section->start, - syms) != NULL; - else - ret = bfd_get_section_contents (abfd, sec, section->start, 0, - section->size); + ret = bfd_get_section_contents (abfd, sec, section->start, 0, + section->size); if (! ret) { @@ -2234,6 +2228,30 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, section->size = size; } + if (is_relocatable && debug_displays [debug].relocate) + { + /* We want to relocate the data we've already read (and + decompressed), so we store a pointer to the data in + the bfd_section, and tell it that the contents are + already in memory. */ + sec->contents = section->start; + sec->flags |= SEC_IN_MEMORY; + sec->size = section->size; + + ret = bfd_simple_get_relocated_section_contents (abfd, + sec, + section->start, + syms) != NULL; + + if (! ret) + { + free_debug_section (debug); + printf (_("\nCan't get contents for section '%s'.\n"), + section->name); + return 0; + } + } + return 1; } diff --git a/binutils/readelf.c b/binutils/readelf.c index d4f47ca..1c3cb8b 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -9962,8 +9962,11 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, return 0; if (section_is_compressed) - if (! uncompress_section_contents (§ion->start, §ion->size)) - return 0; + { + if (! uncompress_section_contents (§ion->start, §ion->size)) + return 0; + sec->sh_size = section->size; + } if (debug_displays [debug].relocate) apply_relocations ((FILE *) file, sec, section->start); -- cgit v1.1