From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR16056, objcopy -R .gnu_debuglink failure on binary created by gold
Date: Thu, 17 Oct 2013 10:03:00 -0000 [thread overview]
Message-ID: <20131017100320.GO20756@bubble.grove.modra.org> (raw)
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
reply other threads:[~2013-10-17 10:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131017100320.GO20756@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).