This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 2/3] BFD/Power: Add assertions to guard against dynindx == -1
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: <binutils at sourceware dot org>
- Cc: Geoff Keating <geoffk at geoffk dot org>, Alan Modra <amodra at gmail dot com>
- Date: Wed, 8 Aug 2012 13:20:23 +0100
- Subject: [PATCH 2/3] BFD/Power: Add assertions to guard against dynindx == -1
Hi,
As noted in the description associated with the hidden/internal versioned
symbol preemption fix, the Power port of LD lets the dynamic symbol
table's index of minus one slip through to the final binary produced and
be used in dynamic relocations. This should be considered an internal
error condition in BFD and (some?) other ports already have assertions in
place to catch it. Here's a change to add them to the Power port as well.
This change causes no regressions in my usual set of targets, however the
assertion does correctly trigger if used with the extra symbol preemption
test cases (sent separately) added to cover the original bug referred
above and the corresponding fix not applied.
OK to apply?
2012-08-08 Maciej W. Rozycki <macro@codesourcery.com>
bfd/
* elf32-ppc.c (ppc_elf_relocate_section): Assert that dynindx is
not minus one.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
Maciej
binutils-bfd-ppc-dynindx-assert.diff
Index: binutils-fsf-trunk-quilt/bfd/elf32-ppc.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/bfd/elf32-ppc.c 2012-07-19 12:48:39.341783320 +0100
+++ binutils-fsf-trunk-quilt/bfd/elf32-ppc.c 2012-07-19 13:15:05.141793272 +0100
@@ -7826,6 +7826,7 @@ ppc_elf_relocate_section (bfd *output_bf
;
else
{
+ BFD_ASSERT (h->dynindx != -1);
indx = h->dynindx;
unresolved_reloc = FALSE;
}
@@ -8176,6 +8177,7 @@ ppc_elf_relocate_section (bfd *output_bf
|| h->root.type == bfd_link_hash_undefweak))
|| !SYMBOL_REFERENCES_LOCAL (info, h))
{
+ BFD_ASSERT (h->dynindx != -1);
unresolved_reloc = FALSE;
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
outrel.r_addend = rel->r_addend;
Index: binutils-fsf-trunk-quilt/bfd/elf64-ppc.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/bfd/elf64-ppc.c 2012-07-19 12:48:39.341783320 +0100
+++ binutils-fsf-trunk-quilt/bfd/elf64-ppc.c 2012-07-19 13:15:05.151360244 +0100
@@ -13118,6 +13118,7 @@ ppc64_elf_relocate_section (bfd *output_
;
else
{
+ BFD_ASSERT (h->elf.dynindx != -1);
indx = h->elf.dynindx;
unresolved_reloc = FALSE;
}
@@ -13490,7 +13491,10 @@ ppc64_elf_relocate_section (bfd *output_
else if (!SYMBOL_CALLS_LOCAL (info, &h->elf)
&& !is_opd
&& r_type != R_PPC64_TOC)
- outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
+ {
+ BFD_ASSERT (h->elf.dynindx != -1);
+ outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
+ }
else
{
/* This symbol is local, or marked to become local,