public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR16056, objcopy -R .gnu_debuglink failure on binary created by gold
@ 2013-10-17 10:03 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2013-10-17 10:03 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-10-17 10:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-17 10:03 PR16056, objcopy -R .gnu_debuglink failure on binary created by gold Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).