diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2014-05-16 15:34:13 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2014-05-16 15:34:13 +0100 |
commit | 6e6e7cfc78e3ae1f4b670fc42d3b4e113d57a62b (patch) | |
tree | a793c7a01c0387aebbb964c4d3bda9c156bf8cb1 /binutils | |
parent | 856ea05ccf051d4d86f422552f5cdfa83659dd6b (diff) | |
download | gdb-6e6e7cfc78e3ae1f4b670fc42d3b4e113d57a62b.zip gdb-6e6e7cfc78e3ae1f4b670fc42d3b4e113d57a62b.tar.gz gdb-6e6e7cfc78e3ae1f4b670fc42d3b4e113d57a62b.tar.bz2 |
This fixes a few issues with pe/coff build-ids that were discovered since the
original patches were posted:
pe/coff: Display GUID build-id in the conventional way
pe/coff: Don't interpret debug directory in section with no contents
pe/coff: Keep .build-id with --only-keep-debug
pe/coff: Don't break .build-id with objcopy/strip
* peXXigen.c (pe_print_debugdata): Don't interpret debug directory
in a section with no contents.
(is_vma_in_section, find_section_by_vma): New functions.
(_bfd_XX_bfd_copy_private_bfd_data_common): Recalculate file
offsets in the debug directory.
(_bfd_XXi_slurp_codeview_record, _bfd_XXi_write_codeview_record):
Byte-swap GUID from little-endian to big-endian order for
consistent and conventional display.
* objcopy.c (is_nondebug_keep_contents_section): New function.
(setup_section): Use it.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 5 | ||||
-rw-r--r-- | binutils/objcopy.c | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 66f2ec1..82b8eae 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2014-05-16 Jon Turney <jon.turney@dronecode.org.uk> + + * objcopy.c (is_nondebug_keep_contents_section): New function. + (setup_section): Use it. + 2014-05-16 Kaushik Phata <Kaushik.Phatak@kpit.com> * readelf.c (get_machine_flags): Handle RL78 64-bit doubles flag. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 873908c..46fd8bc 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1141,6 +1141,24 @@ is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) return FALSE; } +static bfd_boolean +is_nondebug_keep_contents_section (bfd *ibfd, asection *isection) +{ + /* Always keep ELF note sections. */ + if (ibfd->xvec->flavour == bfd_target_elf_flavour) + return (elf_section_type (isection) == SHT_NOTE); + + /* Always keep the .build-id section for PE/COFF. + + Strictly, this should be written "always keep the section storing the debug + directory", but that may be the .text section for objects produced by some + tools, which it is not sensible to keep. */ + if (ibfd->xvec->flavour == bfd_target_coff_flavour) + return (strcmp (bfd_get_section_name (ibfd, isection), ".build-id") == 0); + + return FALSE; +} + /* Return true if SYM is a hidden symbol. */ static bfd_boolean @@ -2695,8 +2713,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC)); else if (strip_symbols == STRIP_NONDEBUG && (flags & (SEC_ALLOC | SEC_GROUP)) != 0 - && !(ibfd->xvec->flavour == bfd_target_elf_flavour - && elf_section_type (isection) == SHT_NOTE)) + && !is_nondebug_keep_contents_section (ibfd, isection)) { flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD | SEC_GROUP); if (obfd->xvec->flavour == bfd_target_elf_flavour) |