summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2013-07-25 15:18:26 +0000
committerAlan Modra <amodra@bigpond.net.au>2013-07-25 15:18:26 +0000
commit7a8caec96a43bb17be1650668f43f4cc1edc5bfa (patch)
tree5a204ac5a504efe304f61c822d667d0e009ca4d8
parent2fe42e82135c2d1cea50ee7126283fa5cc723d52 (diff)
downloadgdb-7a8caec96a43bb17be1650668f43f4cc1edc5bfa.tar.gz
* elf64-ppc.c (struct ppc64_elf_obj_tdata): Replace opd_relocs
with a union. (opd_entry_value): Cache .opd section contents. (ppc64_elf_relocate_section): Adjust.
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf64-ppc.c27
2 files changed, 25 insertions, 9 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index efbf5bb0f50..0f25f37cfff 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,12 @@
2013-07-25 Alan Modra <amodra@gmail.com>
+ * elf64-ppc.c (struct ppc64_elf_obj_tdata): Replace opd_relocs
+ with a union.
+ (opd_entry_value): Cache .opd section contents.
+ (ppc64_elf_relocate_section): Adjust.
+
+2013-07-25 Alan Modra <amodra@gmail.com>
+
PR ld/15762
PR ld/12761
* elflink.c (elf_link_add_object_symbols): Correct test in
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index b0a9afb1a96..349f9b3fd43 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -2615,8 +2615,13 @@ struct ppc64_elf_obj_tdata
sections means we potentially need one of these for each input bfd. */
struct got_entry tlsld_got;
- /* A copy of relocs before they are modified for --emit-relocs. */
- Elf_Internal_Rela *opd_relocs;
+ union {
+ /* A copy of relocs before they are modified for --emit-relocs. */
+ Elf_Internal_Rela *relocs;
+
+ /* Section contents. */
+ bfd_byte *contents;
+ } opd;
/* Nonzero if this bfd has small toc/got relocs, ie. that expect
the reloc to be in the range -32768 to 32767. */
@@ -5574,12 +5579,16 @@ opd_entry_value (asection *opd_sec,
at a final linked executable with addr2line or somesuch. */
if (opd_sec->reloc_count == 0)
{
- char buf[8];
+ bfd_byte *contents = ppc64_elf_tdata (opd_bfd)->opd.contents;
- if (!bfd_get_section_contents (opd_bfd, opd_sec, buf, offset, 8))
- return (bfd_vma) -1;
+ if (contents == NULL)
+ {
+ if (!bfd_malloc_and_get_section (opd_bfd, opd_sec, &contents))
+ return (bfd_vma) -1;
+ ppc64_elf_tdata (opd_bfd)->opd.contents = contents;
+ }
- val = bfd_get_64 (opd_bfd, buf);
+ val = bfd_get_64 (opd_bfd, contents + offset);
if (code_sec != NULL)
{
asection *sec, *likely = NULL;
@@ -5611,7 +5620,7 @@ opd_entry_value (asection *opd_sec,
BFD_ASSERT (is_ppc64_elf (opd_bfd));
- relocs = ppc64_elf_tdata (opd_bfd)->opd_relocs;
+ relocs = ppc64_elf_tdata (opd_bfd)->opd.relocs;
if (relocs == NULL)
relocs = _bfd_elf_link_read_relocs (opd_bfd, opd_sec, NULL, NULL, TRUE);
@@ -14065,8 +14074,8 @@ ppc64_elf_relocate_section (bfd *output_bfd,
bfd_size_type amt;
amt = input_section->reloc_count * sizeof (Elf_Internal_Rela);
rel = bfd_alloc (input_bfd, amt);
- BFD_ASSERT (ppc64_elf_tdata (input_bfd)->opd_relocs == NULL);
- ppc64_elf_tdata (input_bfd)->opd_relocs = rel;
+ BFD_ASSERT (ppc64_elf_tdata (input_bfd)->opd.relocs == NULL);
+ ppc64_elf_tdata (input_bfd)->opd.relocs = rel;
if (rel == NULL)
return FALSE;
memcpy (rel, relocs, amt);