diff options
author | Kai Tietz <kai.tietz@onevision.com> | 2012-10-18 17:42:29 +0000 |
---|---|---|
committer | Kai Tietz <kai.tietz@onevision.com> | 2012-10-18 17:42:29 +0000 |
commit | a29a8af823af0415dae4d3b2ffd60cb3b53ec011 (patch) | |
tree | df66edb33293676a41d1ed63dadbb40701203f51 /bfd | |
parent | 4fc8b8950a1aed53bc553c9003808f04919cc7ca (diff) | |
download | gdb-a29a8af823af0415dae4d3b2ffd60cb3b53ec011.zip gdb-a29a8af823af0415dae4d3b2ffd60cb3b53ec011.tar.gz gdb-a29a8af823af0415dae4d3b2ffd60cb3b53ec011.tar.bz2 |
ChangeLog bfd
2012-10-18 Kai Tietz <ktietz@redhat.com>
PR binutils/14067
* coff-i386.c (bfd_target): Add section flag SEC_EXCLUDE.
Allow BFD_COMPRESS and BFD_DECOMPRESS flags.
* coff-x86_64.c: Likewise.
* coffcode.h (DOT_ZDEBUG): New define.
(sec_to_styp_flags): Check for .zdebug.
(styp_to_sec_flags): Likewise.
* coffgen.c (make_a_section): Handle .debug_* section
compression/decompression flags.
* cofflink.c (mark_relocs): Ignore relocations
for a section, which isn't marked as used.
(_bfd_coff_link_input_bfd): Add support of compressed
debug sections.
* compress.c (decompress_contents): Loop as long
as there is input available and there is room for
output.
* bfd/pe-arm.c: Add .zdebug_ partial match entry.
* pe-i386.c: Likewise.
* pe-x86_64.c: Likewise.
* peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't clear all
data-directories as this might destroy content.
* coff-i386.c (_bfd_generic_find_nearest_line_discriminator):
define as coff_find_nearest_line_discriminator.
* libcoff-in.h (coff_find_nearest_line_discriminator): New
* libcoff.h: Regenerated.
* coff-x86_64.c: Likewise.
* coffgen.c (coff_find_nearest_line_discriminator): New function.
prototype.
ChangeLog binutils
2012-10-18 Kai Tietz <ktietz@redhat.com>
* objdump.c (dump_bfd): Call dump headers after
call of slurp_symtab.
ChangeLog ld
2012-10-18 Kai Tietz <ktietz@redhat.com>
PR binutils/14067
* NEWS: Menition new feature.
* scripttempl/pep.sc: Add zdebug sections.
* scripttempl/pe.sc: L
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 32 | ||||
-rw-r--r-- | bfd/coff-i386.c | 9 | ||||
-rw-r--r-- | bfd/coff-x86_64.c | 6 | ||||
-rw-r--r-- | bfd/coffcode.h | 7 | ||||
-rw-r--r-- | bfd/coffgen.c | 92 | ||||
-rw-r--r-- | bfd/cofflink.c | 11 | ||||
-rw-r--r-- | bfd/compress.c | 2 | ||||
-rw-r--r-- | bfd/libcoff-in.h | 3 | ||||
-rw-r--r-- | bfd/libcoff.h | 3 | ||||
-rw-r--r-- | bfd/pe-arm.c | 2 | ||||
-rw-r--r-- | bfd/pe-i386.c | 2 | ||||
-rw-r--r-- | bfd/pe-x86_64.c | 2 | ||||
-rw-r--r-- | bfd/peXXigen.c | 3 |
13 files changed, 156 insertions, 18 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6729407..5c7e869 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,35 @@ +2012-10-18 Kai Tietz <ktietz@redhat.com> + + PR binutils/14067 + * coff-i386.c (bfd_target): Add section flag SEC_EXCLUDE. + Allow BFD_COMPRESS and BFD_DECOMPRESS flags. + * coff-x86_64.c: Likewise. + * coffcode.h (DOT_ZDEBUG): New define. + (sec_to_styp_flags): Check for .zdebug. + (styp_to_sec_flags): Likewise. + * coffgen.c (make_a_section): Handle .debug_* section + compression/decompression flags. + * cofflink.c (mark_relocs): Ignore relocations + for a section, which isn't marked as used. + (_bfd_coff_link_input_bfd): Add support of compressed + debug sections. + * compress.c (decompress_contents): Loop as long + as there is input available and there is room for + output. + * bfd/pe-arm.c: Add .zdebug_ partial match entry. + * pe-i386.c: Likewise. + * pe-x86_64.c: Likewise. + * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't clear all + data-directories as this might destroy content. + + * coff-i386.c (_bfd_generic_find_nearest_line_discriminator): + define as coff_find_nearest_line_discriminator. + * libcoff-in.h (coff_find_nearest_line_discriminator): New + * libcoff.h: Regenerated. + * coff-x86_64.c: Likewise. + * coffgen.c (coff_find_nearest_line_discriminator): New function. + prototype. + 2012-10-16 Joel Brobecker <brobecker@adacore.com> * coff64-rs6000.c (rs6000coff64_vec): Set _close_and_cleanup diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c index f69f502..af92b40 100644 --- a/bfd/coff-i386.c +++ b/bfd/coff-i386.c @@ -607,6 +607,9 @@ coff_i386_is_local_label_name (bfd *abfd, const char *name) #include "coffcode.h" +#define _bfd_generic_find_nearest_line_discriminator \ + coff_find_nearest_line_discriminator + const bfd_target #ifdef TARGET_SYM TARGET_SYM = @@ -625,13 +628,13 @@ const bfd_target (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */ #ifdef COFF_WITH_PE - | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY + | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING #endif - | SEC_CODE | SEC_DATA), + | SEC_CODE | SEC_DATA | SEC_EXCLUDE ), #ifdef TARGET_UNDERSCORE TARGET_UNDERSCORE, /* leading underscore */ diff --git a/bfd/coff-x86_64.c b/bfd/coff-x86_64.c index 4f00b78..fc39f9f 100644 --- a/bfd/coff-x86_64.c +++ b/bfd/coff-x86_64.c @@ -749,13 +749,13 @@ const bfd_target (HAS_RELOC | EXEC_P | /* Object flags. */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags. */ #if defined(COFF_WITH_PE) - | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY + | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING #endif - | SEC_CODE | SEC_DATA), + | SEC_CODE | SEC_DATA | SEC_EXCLUDE ), #ifdef TARGET_UNDERSCORE TARGET_UNDERSCORE, /* Leading underscore. */ diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 62eeb20..dc101b5 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -372,6 +372,7 @@ CODE_FRAGMENT #define STRING_SIZE_SIZE 4 #define DOT_DEBUG ".debug" +#define DOT_ZDEBUG ".zdebug" #define GNU_LINKONCE_WI ".gnu.linkonce.wi." #define GNU_LINKONCE_WT ".gnu.linkonce.wt." #define DOT_RELOC ".reloc" @@ -545,7 +546,8 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) styp_flags = STYP_LIT; #endif /* _LIT */ } - else if (CONST_STRNEQ (sec_name, DOT_DEBUG)) + else if (CONST_STRNEQ (sec_name, DOT_DEBUG) + || CONST_STRNEQ (sec_name, DOT_ZDEBUG)) { /* Handle the XCOFF debug section and DWARF2 debug sections. */ if (!sec_name[6]) @@ -652,6 +654,7 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) bfd_boolean is_dbg = FALSE; if (CONST_STRNEQ (sec_name, DOT_DEBUG) + || CONST_STRNEQ (sec_name, DOT_ZDEBUG) #ifdef COFF_LONG_SECTION_NAMES || CONST_STRNEQ (sec_name, GNU_LINKONCE_WI) || CONST_STRNEQ (sec_name, GNU_LINKONCE_WT) @@ -821,6 +824,7 @@ styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED, sec_flags |= SEC_ALLOC; } else if (CONST_STRNEQ (name, DOT_DEBUG) + || CONST_STRNEQ (name, DOT_ZDEBUG) #ifdef _COMMENT || strcmp (name, _COMMENT) == 0 #endif @@ -1158,6 +1162,7 @@ styp_to_sec_flags (bfd *abfd, bfd_boolean is_dbg = FALSE; if (CONST_STRNEQ (name, DOT_DEBUG) + || CONST_STRNEQ (name, DOT_ZDEBUG) #ifdef COFF_LONG_SECTION_NAMES || CONST_STRNEQ (name, GNU_LINKONCE_WI) || CONST_STRNEQ (name, GNU_LINKONCE_WT) diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 509119b..584f64b 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -91,7 +91,7 @@ make_a_section_from_file (bfd *abfd, don't know the length of the string table. */ strings += strindex; name = (char *) bfd_alloc (abfd, - (bfd_size_type) strlen (strings) + 1); + (bfd_size_type) strlen (strings) + 1 + 1); if (name == NULL) return FALSE; strcpy (name, strings); @@ -102,7 +102,7 @@ make_a_section_from_file (bfd *abfd, { /* Assorted wastage to null-terminate the name, thanks AT&T! */ name = (char *) bfd_alloc (abfd, - (bfd_size_type) sizeof (hdr->s_name) + 1); + (bfd_size_type) sizeof (hdr->s_name) + 1 + 1); if (name == NULL) return FALSE; strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name)); @@ -146,6 +146,76 @@ make_a_section_from_file (bfd *abfd, if (hdr->s_scnptr != 0) return_section->flags |= SEC_HAS_CONTENTS; + /* Compress/decompress DWARF debug sections with names: .debug_* and + .zdebug_*, after the section flags is set. */ + if ((flags & SEC_DEBUGGING) + && ((name[1] == 'd' && name[6] == '_') + || (name[1] == 'z' && name[7] == '_'))) + { + enum { nothing, compress, decompress } action = nothing; + char *new_name = NULL; + + if (bfd_is_section_compressed (abfd, return_section)) + { + /* Compressed section. Check if we should decompress. */ + if ((abfd->flags & BFD_DECOMPRESS)) + action = decompress; + } + else if (!bfd_is_section_compressed (abfd, return_section)) + { + /* Normal section. Check if we should compress. */ + if ((abfd->flags & BFD_COMPRESS) && return_section->size != 0) + action = compress; + } + + switch (action) + { + case nothing: + break; + case compress: + if (!bfd_init_section_compress_status (abfd, return_section)) + { + (*_bfd_error_handler) + (_("%B: unable to initialize compress status for section %s"), + abfd, name); + return FALSE; + } + if (name[1] != 'z') + { + unsigned int len = strlen (name); + + new_name = bfd_alloc (abfd, len + 2); + if (new_name == NULL) + return FALSE; + new_name[0] = '.'; + new_name[1] = 'z'; + memcpy (new_name + 2, name + 1, len); + } + break; + case decompress: + if (!bfd_init_section_decompress_status (abfd, return_section)) + { + (*_bfd_error_handler) + (_("%B: unable to initialize decompress status for section %s"), + abfd, name); + return FALSE; + } + if (name[1] == 'z') + { + unsigned int len = strlen (name); + + new_name = bfd_alloc (abfd, len); + if (new_name == NULL) + return FALSE; + new_name[0] = '.'; + memcpy (new_name + 1, name + 2, len - 1); + } + break; + } + if (new_name != NULL) + bfd_rename_section (abfd, return_section, new_name); + } + return result; } @@ -2349,6 +2419,24 @@ coff_find_nearest_line (bfd *abfd, } bfd_boolean +coff_find_nearest_line_discriminator (bfd *abfd, + asection *section, + asymbol **symbols, + bfd_vma offset, + const char **filename_ptr, + const char **functionname_ptr, + unsigned int *line_ptr, + unsigned int *discriminator) +{ + *discriminator = 0; + return coff_find_nearest_line_with_names (abfd, dwarf_debug_sections, + section, symbols, offset, + filename_ptr, functionname_ptr, + line_ptr); +} + + +bfd_boolean coff_find_inliner_info (bfd *abfd, const char **filename_ptr, const char **functionname_ptr, diff --git a/bfd/cofflink.c b/bfd/cofflink.c index dd3e4b1..b390801 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -1424,7 +1424,8 @@ mark_relocs (struct coff_final_link_info *flaginfo, bfd *input_bfd) struct internal_reloc * irel; struct internal_reloc * irelend; - if ((a->flags & SEC_RELOC) == 0 || a->reloc_count < 1) + if ((a->flags & SEC_RELOC) == 0 || a->reloc_count < 1 + || a->linker_mark == 0) continue; /* Don't mark relocs in excluded sections. */ if (a->output_section == bfd_abs_section_ptr) @@ -2426,10 +2427,9 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd) contents = secdata->contents; else { - bfd_size_type x = o->rawsize ? o->rawsize : o->size; - if (! bfd_get_section_contents (input_bfd, o, flaginfo->contents, 0, x)) - return FALSE; contents = flaginfo->contents; + if (! bfd_get_full_section_contents (input_bfd, o, &contents)) + return FALSE; } if ((o->flags & SEC_RELOC) != 0) @@ -2447,7 +2447,8 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd) ? (flaginfo->section_info[target_index].relocs + o->output_section->reloc_count) : flaginfo->internal_relocs))); - if (internal_relocs == NULL) + if (internal_relocs == NULL + && o->reloc_count > 0) return FALSE; /* Run through the relocs looking for relocs against symbols diff --git a/bfd/compress.c b/bfd/compress.c index 52c884c..17b5928 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -46,7 +46,7 @@ decompress_contents (bfd_byte *compressed_buffer, strm.avail_out = uncompressed_size; rc = inflateInit (&strm); - while (strm.avail_in > 0) + while (strm.avail_in > 0 && strm.avail_out > 0) { if (rc != Z_OK) return FALSE; diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 0cd8de5..6efbc52 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -350,6 +350,9 @@ extern asymbol *coff_bfd_make_debug_symbol extern bfd_boolean coff_find_nearest_line (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, unsigned int *); +extern bfd_boolean coff_find_nearest_line_discriminator + (bfd *, asection *, asymbol **, bfd_vma, const char **, + const char **, unsigned int *, unsigned int *); struct dwarf_debug_section; extern bfd_boolean coff_find_nearest_line_with_names (bfd *, const struct dwarf_debug_section *, asection *, asymbol **, diff --git a/bfd/libcoff.h b/bfd/libcoff.h index 8aef552..206668e 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -354,6 +354,9 @@ extern asymbol *coff_bfd_make_debug_symbol extern bfd_boolean coff_find_nearest_line (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, unsigned int *); +extern bfd_boolean coff_find_nearest_line_discriminator + (bfd *, asection *, asymbol **, bfd_vma, const char **, + const char **, unsigned int *, unsigned int *); struct dwarf_debug_section; extern bfd_boolean coff_find_nearest_line_with_names (bfd *, const struct dwarf_debug_section *, asection *, asymbol **, diff --git a/bfd/pe-arm.c b/bfd/pe-arm.c index 4c46a7a..909221f 100644 --- a/bfd/pe-arm.c +++ b/bfd/pe-arm.c @@ -60,6 +60,8 @@ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \ { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ +{ COFF_SECTION_NAME_PARTIAL_MATCH (".zdebug"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } diff --git a/bfd/pe-i386.c b/bfd/pe-i386.c index 9da6413..b26243a 100644 --- a/bfd/pe-i386.c +++ b/bfd/pe-i386.c @@ -38,6 +38,8 @@ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \ { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ +{ COFF_SECTION_NAME_PARTIAL_MATCH (".zdebug"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } diff --git a/bfd/pe-x86_64.c b/bfd/pe-x86_64.c index b739cc4..bac481b 100644 --- a/bfd/pe-x86_64.c +++ b/bfd/pe-x86_64.c @@ -52,6 +52,8 @@ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \ { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ +{ COFF_SECTION_NAME_PARTIAL_MATCH (".zdebug"), \ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index e506546..0d5ff30 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -591,9 +591,6 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; - /* First null out all data directory entries. */ - memset (extra->DataDirectory, 0, sizeof (extra->DataDirectory)); - add_data_entry (abfd, extra, 0, ".edata", ib); add_data_entry (abfd, extra, 2, ".rsrc", ib); add_data_entry (abfd, extra, 3, ".pdata", ib); |