From bfeb4a285ab62875ca5dafedc0c51d06493a1952 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 22 Apr 2013 03:11:40 +0000 Subject: [PATCH] bfd/ * elf64-ppc.c (ppc64_elf_check_relocs): Don't call create_linkage_sections here.. (ppc64_elf_init_stub_bfd): ..do so here. Return status. (create_linkage_sections): Move earlier in file. (ppc64_elf_setup_section_lists): Remove now useless htab->brlt test. * elf64-ppc.h (ppc64_elf_init_stub_bfd): Update proto. ld/ * emultempl/ppc64elf.em (ppc_create_output_section_statements): Check return from ppc64_elf_init_stub_bfd. ld/testsuite/ * ld-powerpc/tlsexe.d: Adjust. * ld-powerpc/tlsexe.r: Adjust. * ld-powerpc/tlsexetoc.d: Adjust. * ld-powerpc/tlsexetoc.r: Adjust. * ld-powerpc/tlsso.d: Adjust. * ld-powerpc/tlsso.r: Adjust. * ld-powerpc/tlstocso.d: Adjust. * ld-powerpc/tlstocso.r: Adjust. --- bfd/ChangeLog | 9 ++ bfd/elf64-ppc.c | 172 ++++++++++++++-------------- bfd/elf64-ppc.h | 2 +- ld/ChangeLog | 5 + ld/emultempl/ppc64elf.em | 3 +- ld/testsuite/ChangeLog | 19 ++- ld/testsuite/ld-powerpc/tlsexe.d | 2 +- ld/testsuite/ld-powerpc/tlsexe.r | 2 +- ld/testsuite/ld-powerpc/tlsexetoc.d | 2 +- ld/testsuite/ld-powerpc/tlsexetoc.r | 2 +- ld/testsuite/ld-powerpc/tlsso.d | 2 +- ld/testsuite/ld-powerpc/tlsso.r | 2 +- ld/testsuite/ld-powerpc/tlstocso.d | 2 +- ld/testsuite/ld-powerpc/tlstocso.r | 2 +- 14 files changed, 124 insertions(+), 102 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 22cf4407569..c8d5619d7fc 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2013-04-22 Alan Modra + + * elf64-ppc.c (ppc64_elf_check_relocs): Don't call + create_linkage_sections here.. + (ppc64_elf_init_stub_bfd): ..do so here. Return status. + (create_linkage_sections): Move earlier in file. + (ppc64_elf_setup_section_lists): Remove now useless htab->brlt test. + * elf64-ppc.h (ppc64_elf_init_stub_bfd): Update proto. + 2013-04-19 Nick Clifton PR binutils/15356 diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index e14bfb081dd..cb33821a76c 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -4061,9 +4061,86 @@ ppc64_elf_link_hash_table_free (struct bfd_link_hash_table *hash) _bfd_elf_link_hash_table_free (hash); } +/* Create sections for linker generated code. */ + +static bfd_boolean +create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) +{ + struct ppc_link_hash_table *htab; + flagword flags; + + htab = ppc_hash_table (info); + + /* Create .sfpr for code to save and restore fp regs. */ + flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY + | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); + htab->sfpr = bfd_make_section_anyway_with_flags (dynobj, ".sfpr", + flags); + if (htab->sfpr == NULL + || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) + return FALSE; + + /* Create .glink for lazy dynamic linking support. */ + htab->glink = bfd_make_section_anyway_with_flags (dynobj, ".glink", + flags); + if (htab->glink == NULL + || ! bfd_set_section_alignment (dynobj, htab->glink, 3)) + return FALSE; + + if (!info->no_ld_generated_unwind_info) + { + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS + | SEC_IN_MEMORY | SEC_LINKER_CREATED); + htab->glink_eh_frame = bfd_make_section_anyway_with_flags (dynobj, + ".eh_frame", + flags); + if (htab->glink_eh_frame == NULL + || !bfd_set_section_alignment (dynobj, htab->glink_eh_frame, 2)) + return FALSE; + } + + flags = SEC_ALLOC | SEC_LINKER_CREATED; + htab->iplt = bfd_make_section_anyway_with_flags (dynobj, ".iplt", flags); + if (htab->iplt == NULL + || ! bfd_set_section_alignment (dynobj, htab->iplt, 3)) + return FALSE; + + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY + | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); + htab->reliplt = bfd_make_section_anyway_with_flags (dynobj, + ".rela.iplt", + flags); + if (htab->reliplt == NULL + || ! bfd_set_section_alignment (dynobj, htab->reliplt, 3)) + return FALSE; + + /* Create branch lookup table for plt_branch stubs. */ + flags = (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); + htab->brlt = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt", + flags); + if (htab->brlt == NULL + || ! bfd_set_section_alignment (dynobj, htab->brlt, 3)) + return FALSE; + + if (!info->shared) + return TRUE; + + 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.branch_lt", + flags); + if (htab->relbrlt == NULL + || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3)) + return FALSE; + + return TRUE; +} + /* Satisfy the ELF linker by filling in some fields in our fake bfd. */ -void +bfd_boolean ppc64_elf_init_stub_bfd (bfd *abfd, struct bfd_link_info *info) { struct ppc_link_hash_table *htab; @@ -4075,9 +4152,14 @@ ppc64_elf_init_stub_bfd (bfd *abfd, struct bfd_link_info *info) the start of the output TOC section. */ htab = ppc_hash_table (info); if (htab == NULL) - return; + return FALSE; htab->stub_bfd = abfd; htab->elf.dynobj = abfd; + + if (info->relocatable) + return TRUE; + + return create_linkage_sections (htab->elf.dynobj, info); } /* Build a name for an entry in the stub hash table. */ @@ -4227,85 +4309,6 @@ ppc_add_stub (const char *stub_name, return stub_entry; } -/* Create sections for linker generated code. */ - -static bfd_boolean -create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) -{ - struct ppc_link_hash_table *htab; - flagword flags; - - htab = ppc_hash_table (info); - if (htab == NULL) - return FALSE; - - /* Create .sfpr for code to save and restore fp regs. */ - flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY - | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->sfpr = bfd_make_section_anyway_with_flags (dynobj, ".sfpr", - flags); - if (htab->sfpr == NULL - || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) - return FALSE; - - /* Create .glink for lazy dynamic linking support. */ - htab->glink = bfd_make_section_anyway_with_flags (dynobj, ".glink", - flags); - if (htab->glink == NULL - || ! bfd_set_section_alignment (dynobj, htab->glink, 3)) - return FALSE; - - if (!info->no_ld_generated_unwind_info) - { - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->glink_eh_frame = bfd_make_section_anyway_with_flags (dynobj, - ".eh_frame", - flags); - if (htab->glink_eh_frame == NULL - || !bfd_set_section_alignment (dynobj, htab->glink_eh_frame, 2)) - return FALSE; - } - - flags = SEC_ALLOC | SEC_LINKER_CREATED; - htab->iplt = bfd_make_section_anyway_with_flags (dynobj, ".iplt", flags); - if (htab->iplt == NULL - || ! bfd_set_section_alignment (dynobj, htab->iplt, 3)) - return FALSE; - - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY - | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->reliplt = bfd_make_section_anyway_with_flags (dynobj, - ".rela.iplt", - flags); - if (htab->reliplt == NULL - || ! bfd_set_section_alignment (dynobj, htab->reliplt, 3)) - return FALSE; - - /* Create branch lookup table for plt_branch stubs. */ - flags = (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->brlt = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt", - flags); - if (htab->brlt == NULL - || ! bfd_set_section_alignment (dynobj, htab->brlt, 3)) - return FALSE; - - if (!info->shared) - return TRUE; - - 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.branch_lt", - flags); - if (htab->relbrlt == NULL - || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3)) - return FALSE; - - return TRUE; -} - /* Create .got and .rela.got sections in ABFD, and .got in dynobj if not already done. */ @@ -4983,10 +4986,6 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, ppc64_elf_section_data (sec)->sec_type = sec_opd; } - if (htab->sfpr == NULL - && !create_linkage_sections (htab->elf.dynobj, info)) - return FALSE; - rel_end = relocs + sec->reloc_count; for (rel = relocs; rel < rel_end; rel++) { @@ -10547,9 +10546,6 @@ ppc64_elf_setup_section_lists htab->add_stub_section = add_stub_section; htab->layout_sections_again = layout_sections_again; - if (htab->brlt == NULL) - return 0; - /* Find the top input section id. */ for (input_bfd = info->input_bfds, top_id = 3; input_bfd != NULL; diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h index 2728b275b68..89495bcfc0f 100644 --- a/bfd/elf64-ppc.h +++ b/bfd/elf64-ppc.h @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -void ppc64_elf_init_stub_bfd +bfd_boolean ppc64_elf_init_stub_bfd (bfd *, struct bfd_link_info *); bfd_boolean ppc64_elf_edit_opd (struct bfd_link_info *, bfd_boolean); diff --git a/ld/ChangeLog b/ld/ChangeLog index a1841f2d4dc..d9ebc3d1306 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2013-04-22 Alan Modra + + * emultempl/ppc64elf.em (ppc_create_output_section_statements): + Check return from ppc64_elf_init_stub_bfd. + 2013-04-15 Nick Clifton * Makefile.am (ELF_DEPS): Add a dependency upon diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em index d578f7f9340..43f9b6106fd 100644 --- a/ld/emultempl/ppc64elf.em +++ b/ld/emultempl/ppc64elf.em @@ -107,7 +107,8 @@ ppc_create_output_section_statements (void) stub_file->the_bfd->flags |= BFD_LINKER_CREATED; ldlang_add_file (stub_file); - ppc64_elf_init_stub_bfd (stub_file->the_bfd, &link_info); + if (!ppc64_elf_init_stub_bfd (stub_file->the_bfd, &link_info)) + einfo ("%F%P: can not init BFD: %E\n"); } /* Move the input section statement at *U which happens to be on LIST diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index cc2c022be67..7ed0242cb13 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2013-04-22 Alan Modra + + * ld-powerpc/tlsexe.d: Adjust for section id changes. + * ld-powerpc/tlsexe.r: Likewise. + * ld-powerpc/tlsexetoc.d: Likewise. + * ld-powerpc/tlsexetoc.r: Likewise. + * ld-powerpc/tlsso.d: Likewise. + * ld-powerpc/tlsso.r: Likewise. + * ld-powerpc/tlstocso.d: Likewise. + * ld-powerpc/tlstocso.r: Likewise. + 2013-04-15 H.J. Lu PR ld/15371 @@ -88,7 +99,7 @@ 2013-03-20 Will Newton - * ld-elfvers/vers.exp (objdump_symstuff): Sort objdump output + * ld-elfvers/vers.exp (objdump_symstuff): Sort objdump output based on the symbol name rather than address. * ld-elfvers/vers1.sym: Reorder contents to match changes to vers.exp. * ld-elfvers/vers15.sym: Likewise. @@ -122,7 +133,7 @@ 2013-03-08 Venkataramanan Kumar - * lib/ld-lib.exp (check_gc_sections_available): Remove aarch64 + * lib/ld-lib.exp (check_gc_sections_available): Remove aarch64 from list of targets that don't support gc-section. 2013-03-05 Alan Modra @@ -191,9 +202,9 @@ 2013-02-18 Maciej W. Rozycki - * ld-mips-elf/jalx-2.ld: Include .rel.plt in output, give .plt a + * ld-mips-elf/jalx-2.ld: Include .rel.plt in output, give .plt a mapping. - * ld-mips-elf/jalx-2.dd: Adjust disassembly accordingly. + * ld-mips-elf/jalx-2.dd: Adjust disassembly accordingly. 2013-02-18 Alan Modra diff --git a/ld/testsuite/ld-powerpc/tlsexe.d b/ld/testsuite/ld-powerpc/tlsexe.d index 83905514647..ebbf2f0048f 100644 --- a/ld/testsuite/ld-powerpc/tlsexe.d +++ b/ld/testsuite/ld-powerpc/tlsexe.d @@ -8,7 +8,7 @@ Disassembly of section \.text: -.* <00000010\.plt_call\.__tls_get_addr(|_opt)>: +.* <.*plt_call\.__tls_get_addr(|_opt)>: .* (e9 63 00 00|00 00 63 e9) ld r11,0\(r3\) .* (e9 83 00 08|08 00 83 e9) ld r12,8\(r3\) .* (7c 60 1b 78|78 1b 60 7c) mr r0,r3 diff --git a/ld/testsuite/ld-powerpc/tlsexe.r b/ld/testsuite/ld-powerpc/tlsexe.r index 8d6ff301dfa..788e6ac0a28 100644 --- a/ld/testsuite/ld-powerpc/tlsexe.r +++ b/ld/testsuite/ld-powerpc/tlsexe.r @@ -96,9 +96,9 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* TLS +LOCAL +DEFAULT +8 le5 .* (FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt) .* FILE +LOCAL +DEFAULT +ABS .* -.* NOTYPE +LOCAL +DEFAULT +7 00000010\.plt_call\.__tls_get_addr(|_opt) .* OBJECT +LOCAL +DEFAULT +10 _DYNAMIC .* NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve +.* NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt) .* GLOBAL +DEFAULT +UND gd .* GLOBAL +DEFAULT +9 le0 .* GLOBAL +DEFAULT +9 ld0 diff --git a/ld/testsuite/ld-powerpc/tlsexetoc.d b/ld/testsuite/ld-powerpc/tlsexetoc.d index fc209922f98..635b0eb3d79 100644 --- a/ld/testsuite/ld-powerpc/tlsexetoc.d +++ b/ld/testsuite/ld-powerpc/tlsexetoc.d @@ -8,7 +8,7 @@ Disassembly of section \.text: -.* <00000010\.plt_call\.__tls_get_addr(|_opt)>: +.* <.*plt_call\.__tls_get_addr(|_opt)>: .* (e9 63 00 00|00 00 63 e9) ld r11,0\(r3\) .* (e9 83 00 08|08 00 83 e9) ld r12,8\(r3\) .* (7c 60 1b 78|78 1b 60 7c) mr r0,r3 diff --git a/ld/testsuite/ld-powerpc/tlsexetoc.r b/ld/testsuite/ld-powerpc/tlsexetoc.r index 71d6c9e85ac..8905d3f18ec 100644 --- a/ld/testsuite/ld-powerpc/tlsexetoc.r +++ b/ld/testsuite/ld-powerpc/tlsexetoc.r @@ -96,9 +96,9 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* NOTYPE +LOCAL +DEFAULT +11 \.Lie0 .* (FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt) .* FILE +LOCAL +DEFAULT +ABS .* -.* NOTYPE +LOCAL +DEFAULT +7 00000010\.plt_call\.__tls_get_addr(|_opt) .* OBJECT +LOCAL +DEFAULT +10 _DYNAMIC .* NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve +.* NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt) .* TLS +GLOBAL +DEFAULT +UND gd .* TLS +GLOBAL +DEFAULT +9 le0 .* TLS +GLOBAL +DEFAULT +9 ld0 diff --git a/ld/testsuite/ld-powerpc/tlsso.d b/ld/testsuite/ld-powerpc/tlsso.d index 00b00a03ded..be8eae0a8ea 100644 --- a/ld/testsuite/ld-powerpc/tlsso.d +++ b/ld/testsuite/ld-powerpc/tlsso.d @@ -8,7 +8,7 @@ Disassembly of section \.text: -.* <00000010\.plt_call\.__tls_get_addr(|_opt)>: +.* <.*plt_call\.__tls_get_addr(|_opt)>: .* (f8 41 00 28|28 00 41 f8) std r2,40\(r1\) .* (e9 62 80 78|78 80 62 e9) ld r11,-32648\(r2\) .* (7d 69 03 a6|a6 03 69 7d) mtctr r11 diff --git a/ld/testsuite/ld-powerpc/tlsso.r b/ld/testsuite/ld-powerpc/tlsso.r index fab50e02259..bc0c2ca4877 100644 --- a/ld/testsuite/ld-powerpc/tlsso.r +++ b/ld/testsuite/ld-powerpc/tlsso.r @@ -111,7 +111,7 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* NOTYPE +LOCAL +DEFAULT +UND \.__tls_get_addr .* FILE +LOCAL +DEFAULT +ABS .* .* OBJECT +LOCAL +DEFAULT +9 _DYNAMIC -.* NOTYPE +LOCAL +DEFAULT +6 00000010\.plt_call\.__tls_get_addr +.* NOTYPE +LOCAL +DEFAULT +6 .*\.plt_call\.__tls_get_addr .* NOTYPE +LOCAL +DEFAULT +6 __glink_PLTresolve .* TLS +GLOBAL +DEFAULT +UND gd .* TLS +GLOBAL +DEFAULT +8 le0 diff --git a/ld/testsuite/ld-powerpc/tlstocso.d b/ld/testsuite/ld-powerpc/tlstocso.d index a0cd08f6192..b48597a4f5e 100644 --- a/ld/testsuite/ld-powerpc/tlstocso.d +++ b/ld/testsuite/ld-powerpc/tlstocso.d @@ -8,7 +8,7 @@ Disassembly of section \.text: -.* <00000010\.plt_call\.__tls_get_addr(|_opt)>: +.* <.*plt_call\.__tls_get_addr(|_opt)>: .* (f8 41 00 28|28 00 41 f8) std r2,40\(r1\) .* (e9 62 80 70|70 80 62 e9) ld r11,-32656\(r2\) .* (7d 69 03 a6|a6 03 69 7d) mtctr r11 diff --git a/ld/testsuite/ld-powerpc/tlstocso.r b/ld/testsuite/ld-powerpc/tlstocso.r index 1ec8b6301ee..76943e74be6 100644 --- a/ld/testsuite/ld-powerpc/tlstocso.r +++ b/ld/testsuite/ld-powerpc/tlstocso.r @@ -107,7 +107,7 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* NOTYPE +LOCAL +DEFAULT +UND \.__tls_get_addr .* FILE +LOCAL +DEFAULT +ABS .* .* OBJECT +LOCAL +DEFAULT +9 _DYNAMIC -.* NOTYPE +LOCAL +DEFAULT +6 00000010\.plt_call\.__tls_get_addr +.* NOTYPE +LOCAL +DEFAULT +6 .*\.plt_call\.__tls_get_addr .* NOTYPE +LOCAL +DEFAULT +6 __glink_PLTresolve .* TLS +GLOBAL +DEFAULT +UND gd .* TLS +GLOBAL +DEFAULT +8 le0 -- 2.30.2