PR16056, objcopy -R .gnu_debuglink failure on binary created by gold
Alan Modra
amodra@gmail.com
Thu Oct 17 10:03:00 GMT 2013
The testcase in PR16056 has a bunch of zero length unallocated
.gnu.warning sections adjacent to the last alloc section.
[28] .got PROGBITS 437b5d50 0c5d50 000c04 00 WA 0 0 4
[29] .bss NOBITS 437b6958 0c6954 0000c5 00 WA 0 0 8
[30] .gnu.warning.snd_names_list PROGBITS 00000000 0c6954 000000 00 0 0 1
I'm not sure how they were created in the first place (gold bug
perhaps?) but their zero addresses wreak havoc with the segment
address calculations in copy_elf_program_header. The PR correctly
fingers a bfd fix of mine from 2010 for zero length alloc sections,
which happened to expose another bug. Fixed as follows. Applying
mainline and branch.
PR 16056
* elf.c (copy_elf_program_header): Only consider SEC_ALLOC sections
when finding lowest_section.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.591
diff -u -p -r1.591 elf.c
--- bfd/elf.c 27 Mar 2013 13:37:50 -0000 1.591
+++ bfd/elf.c 17 Oct 2013 09:02:39 -0000
@@ -6226,12 +6226,13 @@ copy_elf_program_header (bfd *ibfd, bfd
if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
{
map->sections[isec++] = section->output_section;
- if (section->lma < lowest_section->lma)
- lowest_section = section;
if ((section->flags & SEC_ALLOC) != 0)
{
bfd_vma seg_off;
+ if (section->lma < lowest_section->lma)
+ lowest_section = section;
+
/* Section lmas are set up from PT_LOAD header
p_paddr in _bfd_elf_make_section_from_shdr.
If this header has a p_paddr that disagrees
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list