This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix powerpc64le ld segfaults when --emit-relocs is used
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Cc: Bill Schmidt <wschmidt at linux dot vnet dot ibm dot com>
- Date: Fri, 24 Jan 2014 14:36:22 +1030
- Subject: Fix powerpc64le ld segfaults when --emit-relocs is used
- Authentication-results: sourceware.org; auth=none
ELFv2 needs fewer relocs to annotate plt call stubs. I correctly
allocated a smaller buffer and wrote the proper relocs, but stupidly
bumped the reloc count as for ELFv1. That resulted in a buffer
overrun and trashing of other ld state.
Committed mainline and 2.24.
* elf64-ppc.c (ppc_build_one_stub): Correct reloc count passed
to get_relocs for ELFv2.
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index bb3326d..c97a39e 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -10750,10 +10750,11 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
if (info->emitrelocations)
{
r = get_relocs (stub_entry->stub_sec,
- (2
- + (PPC_HA (off) != 0)
- + (htab->plt_static_chain
- && PPC_HA (off + 16) == PPC_HA (off))));
+ ((PPC_HA (off) != 0)
+ + (htab->opd_abi
+ ? 2 + (htab->plt_static_chain
+ && PPC_HA (off + 16) == PPC_HA (off))
+ : 1)));
if (r == NULL)
return FALSE;
r[0].r_offset = loc - stub_entry->stub_sec->contents;
--
Alan Modra
Australia Development Lab, IBM