From 84f5d08e6b2cc79becc9a7dcad5c4ad9ba1959b1 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 12 Feb 2007 12:02:58 +0000 Subject: bfd/ * elf64-ppc.c (create_linkage_sections): Don't create .rela.rodata.brlt for --emit-relocs. (ppc_build_one_stub): Create relocs for brlt --emit-relocs here. (ppc_size_one_stub): Count them. Simplify test of stub type when counting stub relocs. Set SEC_RELOC too. (ppc64_elf_size_stubs): Clear reloc_count and SEC_RELOC. (ppc64_elf_finish_dynamic_sections): Output brlt relocs. ld/testsuite/ * ld-powerpc/relbrlt.d: Update. --- bfd/ChangeLog | 10 +++++++++ bfd/elf64-ppc.c | 66 +++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 62 insertions(+), 14 deletions(-) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 605c795..9410510 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,15 @@ 2007-02-12 Alan Modra + * elf64-ppc.c (create_linkage_sections): Don't create + .rela.rodata.brlt for --emit-relocs. + (ppc_build_one_stub): Create relocs for brlt --emit-relocs here. + (ppc_size_one_stub): Count them. Simplify test of stub type + when counting stub relocs. Set SEC_RELOC too. + (ppc64_elf_size_stubs): Clear reloc_count and SEC_RELOC. + (ppc64_elf_finish_dynamic_sections): Output brlt relocs. + +2007-02-12 Alan Modra + * elflink.c (evaluate_complex_relocation_symbols): Ignore relocs with a zero symbol index. diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index a354957..41a917a 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -1,5 +1,5 @@ /* PowerPC64-specific support for 64-bit ELF. - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Written by Linus Nordberg, Swox AB , based on elf32-ppc.c by Ian Lance Taylor. @@ -3846,14 +3846,6 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) = bfd_make_section_anyway_with_flags (dynobj, ".rela.data.rel.ro.brlt", flags); } - else if (info->emitrelocations) - { - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY - | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->relbrlt - = bfd_make_section_anyway_with_flags (dynobj, ".rela.rodata.brlt", - flags); - } else return TRUE; @@ -8394,6 +8386,33 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) rl += htab->relbrlt->reloc_count++ * sizeof (Elf64_External_Rela); bfd_elf64_swap_reloca_out (htab->relbrlt->owner, &rela, rl); } + else if (info->emitrelocations) + { + Elf_Internal_Rela *relocs, *r; + struct bfd_elf_section_data *elfsec_data; + + elfsec_data = elf_section_data (htab->brlt); + relocs = elfsec_data->relocs; + if (relocs == NULL) + { + bfd_size_type relsize; + relsize = htab->brlt->reloc_count * sizeof (*relocs); + relocs = bfd_alloc (htab->brlt->owner, relsize); + if (relocs == NULL) + return FALSE; + elfsec_data->relocs = relocs; + elfsec_data->rel_hdr.sh_size = relsize; + elfsec_data->rel_hdr.sh_entsize = 24; + htab->brlt->reloc_count = 0; + } + r = relocs + htab->brlt->reloc_count; + htab->brlt->reloc_count += 1; + r->r_offset = (br_entry->offset + + htab->brlt->output_offset + + htab->brlt->output_section->vma); + r->r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE); + r->r_addend = off; + } off = (br_entry->offset + htab->brlt->output_offset @@ -8623,6 +8642,11 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) if (htab->relbrlt != NULL) htab->relbrlt->size += sizeof (Elf64_External_Rela); + else if (info->emitrelocations) + { + htab->brlt->reloc_count += 1; + htab->brlt->flags |= SEC_RELOC; + } } stub_entry->stub_type += ppc_stub_plt_branch - ppc_stub_long_branch; @@ -8630,11 +8654,11 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) if (stub_entry->stub_type != ppc_stub_plt_branch) size = 28; } - - if (info->emitrelocations - && (stub_entry->stub_type == ppc_stub_long_branch - || stub_entry->stub_type == ppc_stub_long_branch_r2off)) - stub_entry->stub_sec->reloc_count += 1; + else if (info->emitrelocations) + { + stub_entry->stub_sec->reloc_count += 1; + stub_entry->stub_sec->flags |= SEC_RELOC; + } } stub_entry->stub_sec->size += size; @@ -9426,9 +9450,12 @@ ppc64_elf_size_stubs (bfd *output_bfd, stub_sec->rawsize = stub_sec->size; stub_sec->size = 0; stub_sec->reloc_count = 0; + stub_sec->flags &= ~SEC_RELOC; } htab->brlt->size = 0; + htab->brlt->reloc_count = 0; + htab->brlt->flags &= ~SEC_RELOC; if (htab->relbrlt != NULL) htab->relbrlt->size = 0; @@ -11442,6 +11469,17 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd, = PLT_ENTRY_SIZE; } + /* brlt is SEC_LINKER_CREATED, so we need to write out relocs for + brlt ourselves if emitrelocations. */ + if (htab->brlt != NULL + && htab->brlt->reloc_count != 0 + && !_bfd_elf_link_output_relocs (output_bfd, + htab->brlt, + &elf_section_data (htab->brlt)->rel_hdr, + elf_section_data (htab->brlt)->relocs, + NULL)) + return FALSE; + /* We need to handle writing out multiple GOT sections ourselves, since we didn't add them to DYNOBJ. We know dynobj is the first bfd. */ -- cgit v1.1