diff options
Diffstat (limited to 'bfd/coffgen.c')
-rw-r--r-- | bfd/coffgen.c | 92 |
1 files changed, 90 insertions, 2 deletions
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, |