From 131a105386d16b1099ffeeae33a905e2d5105fc9 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 19 Apr 2005 05:59:02 +0000 Subject: [PATCH] bfd/ * elf32-ppc.c (ppc_elf_check_relocs): Don't bother with dynamic relocs in non-SEC_ALLOC sections. (ppc_elf_gc_sweep_hook): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. ld/testsuite/ * ld-powerpc/reloc.d: Update to suit removal of non-alloc relocs. --- bfd/ChangeLog | 8 ++++++++ bfd/elf32-ppc.c | 30 +++++++++++++++++++++++------- ld/testsuite/ChangeLog | 4 ++++ ld/testsuite/ld-powerpc/reloc.d | 5 +---- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 36945c61c54..fbb7e5a6e2f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2005-04-19 Alan Modra + + * elf32-ppc.c (ppc_elf_check_relocs): Don't bother with + dynamic relocs in non-SEC_ALLOC sections. + (ppc_elf_gc_sweep_hook): Likewise. + (ppc_elf_relax_section): Likewise. + (ppc_elf_relocate_section): Likewise. + 2005-04-15 Alan Modra PR ld/815 diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index b4c56e6682f..443b8701c3a 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1647,8 +1647,11 @@ ppc_elf_relax_section (bfd *abfd, *again = FALSE; - /* Nothing to do if there are no relocations. */ - if ((isec->flags & SEC_RELOC) == 0 || isec->reloc_count == 0) + /* Nothing to do if there are no relocations, and no need to do + anything with non-alloc sections. */ + if ((isec->flags & SEC_ALLOC) == 0 + || (isec->flags & SEC_RELOC) == 0 + || isec->reloc_count == 0) return TRUE; trampoff = (isec->size + 3) & (bfd_vma) -4; @@ -3562,6 +3565,15 @@ ppc_elf_check_relocs (bfd *abfd, if (info->relocatable) return TRUE; + /* Don't do anything special with non-loaded, non-alloced sections. + In particular, any relocs in such sections should not affect GOT + and PLT reference counting (ie. we don't allow them to create GOT + or PLT entries), there's no possibility or desire to optimize TLS + relocs, and there's not much point in propagating relocs to shared + libs that the dynamic linker won't relocate. */ + if ((sec->flags & SEC_ALLOC) == 0) + return TRUE; + #ifdef DEBUG _bfd_error_handler ("ppc_elf_check_relocs called for section %A in %B", sec, abfd); @@ -3893,7 +3905,6 @@ ppc_elf_check_relocs (bfd *abfd, || !h->def_regular)))) || (ELIMINATE_COPY_RELOCS && !info->shared - && (sec->flags & SEC_ALLOC) != 0 && h != NULL && (h->root.type == bfd_link_hash_defweak || !h->def_regular))) @@ -3930,9 +3941,8 @@ ppc_elf_check_relocs (bfd *abfd, sreloc = bfd_make_section (htab->elf.dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY - | SEC_IN_MEMORY | SEC_LINKER_CREATED); - if ((sec->flags & SEC_ALLOC) != 0) - flags |= SEC_ALLOC | SEC_LOAD; + | SEC_IN_MEMORY | SEC_LINKER_CREATED + | SEC_ALLOC | SEC_LOAD); if (sreloc == NULL || ! bfd_set_section_flags (htab->elf.dynobj, sreloc, flags) @@ -4044,6 +4054,9 @@ ppc_elf_gc_sweep_hook (bfd *abfd, bfd_signed_vma *local_got_refcounts; const Elf_Internal_Rela *rel, *relend; + if ((sec->flags & SEC_ALLOC) == 0) + return TRUE; + elf_section_data (sec)->local_dynrel = NULL; htab = ppc_elf_hash_table (info); @@ -5284,6 +5297,10 @@ ppc_elf_relocate_section (bfd *output_bfd, break; /* Fall thru. */ + if ((input_section->flags & SEC_ALLOC) == 0) + break; + /* Fall thru. */ + if ((info->shared && (h == NULL || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT @@ -5292,7 +5309,6 @@ ppc_elf_relocate_section (bfd *output_bfd, || !SYMBOL_CALLS_LOCAL (info, h))) || (ELIMINATE_COPY_RELOCS && !info->shared - && (input_section->flags & SEC_ALLOC) != 0 && h != NULL && h->dynindx != -1 && !h->non_got_ref diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 5aa3a95139e..9528435093e 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-04-19 Alan Modra + + * ld-powerpc/reloc.d: Update to suit removal of non-alloc relocs. + 2005-03-24 Mark Mitchell * config/default.exp: Do not load libpath.exp if it does not diff --git a/ld/testsuite/ld-powerpc/reloc.d b/ld/testsuite/ld-powerpc/reloc.d index 08a209db3d5..1c7eb8a90d5 100644 --- a/ld/testsuite/ld-powerpc/reloc.d +++ b/ld/testsuite/ld-powerpc/reloc.d @@ -1,6 +1,5 @@ # Test that orphan reloc sections are placed before .rela.plt even when -# .rela.plt is the only reloc section. Also tests that orphan non-alloc -# reloc sections go after alloc sections. +# .rela.plt is the only reloc section. #source: reloc.s #ld: -shared -z nocombreloc @@ -11,6 +10,4 @@ .*\.relaplatypus.* #... .*\.rela\.plt.* -#... -.*\.relaechidna.* #pass -- 2.47.2