From a22a8039037163a1d61120e6e6b9feaa27186994 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Sun, 5 Aug 2012 22:45:20 +0000 Subject: [PATCH] bfd/ * elf32-vax.c (elf_vax_adjust_dynamic_symbol): Don't allocate PLT slots for local symbols. ld/testsuite/ * ld-vax-elf: New directory. * ld-vax-elf/plt-local-lib.dd: New test. * ld-vax-elf/plt-local-lib.ld: New test linker script. * ld-vax-elf/plt-local-lib.s: New test source. * ld-vax-elf/plt-local.dd: New test. * ld-vax-elf/plt-local.ld: New test linker script. * ld-vax-elf/plt-local.s: New test source. * ld-vax-elf/plt-local-hidden-pic.s: New test source. * ld-vax-elf/plt-local-rehidden-pic.s: New test source. * ld-vax-elf/vax-elf.exp: New test script. --- bfd/ChangeLog | 5 ++ bfd/elf32-vax.c | 32 ++------- ld/testsuite/ChangeLog | 13 ++++ ld/testsuite/ld-vax-elf/plt-local-hidden-pic.s | 14 ++++ ld/testsuite/ld-vax-elf/plt-local-lib.dd | 91 ++++++++++++++++++++++++ ld/testsuite/ld-vax-elf/plt-local-lib.ld | 18 +++++ ld/testsuite/ld-vax-elf/plt-local-lib.s | 50 +++++++++++++ ld/testsuite/ld-vax-elf/plt-local-rehidden-pic.s | 14 ++++ ld/testsuite/ld-vax-elf/plt-local.dd | 73 +++++++++++++++++++ ld/testsuite/ld-vax-elf/plt-local.ld | 34 +++++++++ ld/testsuite/ld-vax-elf/plt-local.s | 25 +++++++ ld/testsuite/ld-vax-elf/vax-elf.exp | 50 +++++++++++++ 12 files changed, 394 insertions(+), 25 deletions(-) create mode 100644 ld/testsuite/ld-vax-elf/plt-local-hidden-pic.s create mode 100644 ld/testsuite/ld-vax-elf/plt-local-lib.dd create mode 100644 ld/testsuite/ld-vax-elf/plt-local-lib.ld create mode 100644 ld/testsuite/ld-vax-elf/plt-local-lib.s create mode 100644 ld/testsuite/ld-vax-elf/plt-local-rehidden-pic.s create mode 100644 ld/testsuite/ld-vax-elf/plt-local.dd create mode 100644 ld/testsuite/ld-vax-elf/plt-local.ld create mode 100644 ld/testsuite/ld-vax-elf/plt-local.s create mode 100644 ld/testsuite/ld-vax-elf/vax-elf.exp diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 559bb35..30fff7a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2012-08-05 Maciej W. Rozycki + + * elf32-vax.c (elf_vax_adjust_dynamic_symbol): Don't allocate + PLT slots for local symbols. + 2012-08-03 Maciej W. Rozycki * elf64-mips.c (mips16_elf64_howto_table_rela): Correct src_mask diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index 84ec9725..6258d96 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -933,39 +933,21 @@ elf_vax_adjust_dynamic_symbol (info, h) if (h->type == STT_FUNC || h->needs_plt) { - if (! info->shared - && !h->def_dynamic - && !h->ref_dynamic - /* We must always create the plt entry if it was referenced - by a PLTxxO relocation. In this case we already recorded - it as a dynamic symbol. */ - && h->dynindx == -1) + if (h->plt.refcount <= 0 + || SYMBOL_CALLS_LOCAL (info, h) + || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + && h->root.type == bfd_link_hash_undefweak)) { /* This case can occur if we saw a PLTxx reloc in an input file, but the symbol was never referred to by a dynamic - object. In such a case, we don't actually need to build - a procedure linkage table, and we can just do a PCxx - reloc instead. */ - BFD_ASSERT (h->needs_plt); + object, or if all references were garbage collected. In + such a case, we don't actually need to build a procedure + linkage table, and we can just do a PCxx reloc instead. */ h->plt.offset = (bfd_vma) -1; - return TRUE; - } - - /* GC may have rendered this entry unused. */ - if (h->plt.refcount <= 0) - { h->needs_plt = 0; - h->plt.offset = (bfd_vma) -1; return TRUE; } - /* Make sure this symbol is output as a dynamic symbol. */ - if (h->dynindx == -1) - { - if (! bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; - } - s = bfd_get_linker_section (dynobj, ".plt"); BFD_ASSERT (s != NULL); diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 5a63a94..4695e1d 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2012-08-05 Maciej W. Rozycki + + * ld-vax-elf: New directory. + * ld-vax-elf/plt-local-lib.dd: New test. + * ld-vax-elf/plt-local-lib.ld: New test linker script. + * ld-vax-elf/plt-local-lib.s: New test source. + * ld-vax-elf/plt-local.dd: New test. + * ld-vax-elf/plt-local.ld: New test linker script. + * ld-vax-elf/plt-local.s: New test source. + * ld-vax-elf/plt-local-hidden-pic.s: New test source. + * ld-vax-elf/plt-local-rehidden-pic.s: New test source. + * ld-vax-elf/vax-elf.exp: New test script. + 2012-08-03 Maciej W. Rozycki * lib/ld-lib.exp (at_least_gcc_version): Accept more version diff --git a/ld/testsuite/ld-vax-elf/plt-local-hidden-pic.s b/ld/testsuite/ld-vax-elf/plt-local-hidden-pic.s new file mode 100644 index 0000000..62f2453 --- /dev/null +++ b/ld/testsuite/ld-vax-elf/plt-local-hidden-pic.s @@ -0,0 +1,14 @@ + .text + + .hidden foo_hidden + .globl foo_hidden + .type foo_hidden, @function +foo_hidden: + .word 0 + calls $0, foo_extern + calls $0, foo_global + calls $0, foo_local + calls $0, foo_hidden + calls $0, foo_rehidden + ret + .size foo_hidden, . - foo_hidden diff --git a/ld/testsuite/ld-vax-elf/plt-local-lib.dd b/ld/testsuite/ld-vax-elf/plt-local-lib.dd new file mode 100644 index 0000000..95e8176 --- /dev/null +++ b/ld/testsuite/ld-vax-elf/plt-local-lib.dd @@ -0,0 +1,91 @@ +.*: +file format .*vax.* + +Disassembly of section \.plt: + +00001000 : + 1000: dd ef 76 20 pushl 307c <_GLOBAL_OFFSET_TABLE_\+0x4> + 1004: 00 00 + 1006: 17 ff 74 20 jmp \*3080 <_GLOBAL_OFFSET_TABLE_\+0x8> + 100a: 00 00 + +0000100c : + 100c: fc 0f \.word 0x0ffc # Entry mask: < r11 r10 r9 r8 r7 r6 r5 r4 r3 r2 > + 100e: 16 ef ec ff jsb 1000 + 1012: ff ff + 1014: 00 00 00 00 \.long 0x00000000 + +00001018 : + 1018: fc 0f \.word 0x0ffc # Entry mask: < r11 r10 r9 r8 r7 r6 r5 r4 r3 r2 > + 101a: 16 ef e0 ff jsb 1000 + 101e: ff ff + 1020: 0c 00 00 00 \.long 0x0000000c + +00001024 : + 1024: fc 0f \.word 0x0ffc # Entry mask: < r11 r10 r9 r8 r7 r6 r5 r4 r3 r2 > + 1026: 16 ef d4 ff jsb 1000 + 102a: ff ff + 102c: 18 00 00 00 \.long 0x00000018 + +00001030 : + 1030: fc 0f \.word 0x0ffc # Entry mask: < r11 r10 r9 r8 r7 r6 r5 r4 r3 r2 > + 1032: 16 ef c8 ff jsb 1000 + 1036: ff ff + 1038: 24 00 00 00 \.long 0x00000024 + +Disassembly of section \.text: + +00002000 : + 2000: 00 00 \.word 0x0000 # Entry mask: < > + 2002: fb 00 ff 7f calls \$0x0,\*3088 <_GLOBAL_OFFSET_TABLE_\+0x10> + 2006: 10 00 00 + 2009: fb 00 ff 80 calls \$0x0,\*3090 <_GLOBAL_OFFSET_TABLE_\+0x18> + 200d: 10 00 00 + 2010: fb 00 ff 6d calls \$0x0,\*3084 <_GLOBAL_OFFSET_TABLE_\+0xc> + 2014: 10 00 00 + 2017: fb 00 ef 2e calls \$0x0,204c + 201b: 00 00 00 + 201e: fb 00 ff 67 calls \$0x0,\*308c <_GLOBAL_OFFSET_TABLE_\+0x14> + 2022: 10 00 00 + 2025: 04 ret + +00002026 : + 2026: 00 00 \.word 0x0000 # Entry mask: < > + 2028: fb 00 ff 59 calls \$0x0,\*3088 <_GLOBAL_OFFSET_TABLE_\+0x10> + 202c: 10 00 00 + 202f: fb 00 ff 5a calls \$0x0,\*3090 <_GLOBAL_OFFSET_TABLE_\+0x18> + 2033: 10 00 00 + 2036: fb 00 ff 47 calls \$0x0,\*3084 <_GLOBAL_OFFSET_TABLE_\+0xc> + 203a: 10 00 00 + 203d: fb 00 ef 08 calls \$0x0,204c + 2041: 00 00 00 + 2044: fb 00 ff 41 calls \$0x0,\*308c <_GLOBAL_OFFSET_TABLE_\+0x14> + 2048: 10 00 00 + 204b: 04 ret + +0000204c : + 204c: 00 00 \.word 0x0000 # Entry mask: < > + 204e: fb 00 ff 33 calls \$0x0,\*3088 <_GLOBAL_OFFSET_TABLE_\+0x10> + 2052: 10 00 00 + 2055: fb 00 ff 34 calls \$0x0,\*3090 <_GLOBAL_OFFSET_TABLE_\+0x18> + 2059: 10 00 00 + 205c: fb 00 ff 21 calls \$0x0,\*3084 <_GLOBAL_OFFSET_TABLE_\+0xc> + 2060: 10 00 00 + 2063: fb 00 ef e2 calls \$0x0,204c + 2067: ff ff ff + 206a: fb 00 ff 1b calls \$0x0,\*308c <_GLOBAL_OFFSET_TABLE_\+0x14> + 206e: 10 00 00 + 2071: 04 ret + +00002072 : + 2072: 00 00 \.word 0x0000 # Entry mask: < > + 2074: fb 00 ff 0d calls \$0x0,\*3088 <_GLOBAL_OFFSET_TABLE_\+0x10> + 2078: 10 00 00 + 207b: fb 00 ff 0e calls \$0x0,\*3090 <_GLOBAL_OFFSET_TABLE_\+0x18> + 207f: 10 00 00 + 2082: fb 00 ff fb calls \$0x0,\*3084 <_GLOBAL_OFFSET_TABLE_\+0xc> + 2086: 0f 00 00 + 2089: fb 00 ef bc calls \$0x0,204c + 208d: ff ff ff + 2090: fb 00 ff f5 calls \$0x0,\*308c <_GLOBAL_OFFSET_TABLE_\+0x14> + 2094: 0f 00 00 + 2097: 04 ret diff --git a/ld/testsuite/ld-vax-elf/plt-local-lib.ld b/ld/testsuite/ld-vax-elf/plt-local-lib.ld new file mode 100644 index 0000000..4a0b44c --- /dev/null +++ b/ld/testsuite/ld-vax-elf/plt-local-lib.ld @@ -0,0 +1,18 @@ +SECTIONS +{ + . = 0; + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rela.plt : { *(.rela.plt) } + + . = 0x1000; + .plt : { *(.plt) } + + . = 0x2000; + .text : { *(.text) } + + . = 0x3000; + .dynamic : { *(.dynamic) } + .got : { *(.got.plt) } +} diff --git a/ld/testsuite/ld-vax-elf/plt-local-lib.s b/ld/testsuite/ld-vax-elf/plt-local-lib.s new file mode 100644 index 0000000..b05dcdf --- /dev/null +++ b/ld/testsuite/ld-vax-elf/plt-local-lib.s @@ -0,0 +1,50 @@ + .text + + .globl foo_extern + .type foo_extern, @function +foo_extern: + .word 0 + calls $0, foo_extern + calls $0, foo_global + calls $0, foo_local + calls $0, foo_hidden + calls $0, foo_rehidden + ret + .size foo_extern, . - foo_extern + + .globl foo_local + .type foo_local, @function +foo_local: + .word 0 + calls $0, foo_extern + calls $0, foo_global + calls $0, foo_local + calls $0, foo_hidden + calls $0, foo_rehidden + ret + .size foo_local, . - foo_local + + .hidden foo_hidden + .globl foo_hidden + .type foo_hidden, @function +foo_hidden: + .word 0 + calls $0, foo_extern + calls $0, foo_global + calls $0, foo_local + calls $0, foo_hidden + calls $0, foo_rehidden + ret + .size foo_hidden, . - foo_hidden + + .globl foo_rehidden + .type foo_rehidden, @function +foo_rehidden: + .word 0 + calls $0, foo_extern + calls $0, foo_global + calls $0, foo_local + calls $0, foo_hidden + calls $0, foo_rehidden + ret + .size foo_rehidden, . - foo_rehidden diff --git a/ld/testsuite/ld-vax-elf/plt-local-rehidden-pic.s b/ld/testsuite/ld-vax-elf/plt-local-rehidden-pic.s new file mode 100644 index 0000000..51b1e67 --- /dev/null +++ b/ld/testsuite/ld-vax-elf/plt-local-rehidden-pic.s @@ -0,0 +1,14 @@ + .text + + .hidden foo_rehidden + .globl foo_rehidden + .type foo_rehidden, @function +foo_rehidden: + .word 0 + calls $0, foo_extern + calls $0, foo_global + calls $0, foo_local + calls $0, foo_hidden + calls $0, foo_rehidden + ret + .size foo_rehidden, . - foo_rehidden diff --git a/ld/testsuite/ld-vax-elf/plt-local.dd b/ld/testsuite/ld-vax-elf/plt-local.dd new file mode 100644 index 0000000..84eca55 --- /dev/null +++ b/ld/testsuite/ld-vax-elf/plt-local.dd @@ -0,0 +1,73 @@ +.*: +file format .*vax.* + +Disassembly of section \.plt: + +00001000 : + 1000: dd ef 86 20 pushl 308c <_GLOBAL_OFFSET_TABLE_\+0x4> + 1004: 00 00 + 1006: 17 ff 84 20 jmp \*3090 <_GLOBAL_OFFSET_TABLE_\+0x8> + 100a: 00 00 + +0000100c : + 100c: fc 0f \.word 0x0ffc # Entry mask: < r11 r10 r9 r8 r7 r6 r5 r4 r3 r2 > + 100e: 16 ef ec ff jsb 1000 + 1012: ff ff + 1014: 00 00 00 00 \.long 0x00000000 + +Disassembly of section \.text: + +00002000 : + 2000: 00 00 \.word 0x0000 # Entry mask: < > + 2002: fb 00 ff 8b calls \$0x0,\*3094 <_GLOBAL_OFFSET_TABLE_\+0xc> + 2006: 10 00 00 + 2009: fb 00 ef 3c calls \$0x0,204c + 200d: 00 00 00 + 2010: fb 00 ef 5b calls \$0x0,2072 + 2014: 00 00 00 + 2017: fb 00 ef e2 calls \$0x0,2000 + 201b: ff ff ff + 201e: fb 00 ef 01 calls \$0x0,2026 + 2022: 00 00 00 + 2025: 04 ret + +00002026 : + 2026: 00 00 \.word 0x0000 # Entry mask: < > + 2028: fb 00 ff 65 calls \$0x0,\*3094 <_GLOBAL_OFFSET_TABLE_\+0xc> + 202c: 10 00 00 + 202f: fb 00 ef 16 calls \$0x0,204c + 2033: 00 00 00 + 2036: fb 00 ef 35 calls \$0x0,2072 + 203a: 00 00 00 + 203d: fb 00 ef bc calls \$0x0,2000 + 2041: ff ff ff + 2044: fb 00 ef db calls \$0x0,2026 + 2048: ff ff ff + 204b: 04 ret + +0000204c : + 204c: 00 00 \.word 0x0000 # Entry mask: < > + 204e: fb 00 ff 3f calls \$0x0,\*3094 <_GLOBAL_OFFSET_TABLE_\+0xc> + 2052: 10 00 00 + 2055: fb 00 ef f0 calls \$0x0,204c + 2059: ff ff ff + 205c: fb 00 ef 0f calls \$0x0,2072 + 2060: 00 00 00 + 2063: fb 00 ef 96 calls \$0x0,2000 + 2067: ff ff ff + 206a: fb 00 ef b5 calls \$0x0,2026 + 206e: ff ff ff + 2071: 04 ret + +00002072 : + 2072: 00 00 \.word 0x0000 # Entry mask: < > + 2074: fb 00 ff 19 calls \$0x0,\*3094 <_GLOBAL_OFFSET_TABLE_\+0xc> + 2078: 10 00 00 + 207b: fb 00 ef ca calls \$0x0,204c + 207f: ff ff ff + 2082: fb 00 ef e9 calls \$0x0,2072 + 2086: ff ff ff + 2089: fb 00 ef 70 calls \$0x0,2000 + 208d: ff ff ff + 2090: fb 00 ef 8f calls \$0x0,2026 + 2094: ff ff ff + 2097: 04 ret diff --git a/ld/testsuite/ld-vax-elf/plt-local.ld b/ld/testsuite/ld-vax-elf/plt-local.ld new file mode 100644 index 0000000..ca87459 --- /dev/null +++ b/ld/testsuite/ld-vax-elf/plt-local.ld @@ -0,0 +1,34 @@ +ENTRY (foo_global) +SECTIONS +{ + . = 0; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .rela.plt : { *(.rela.plt) } + + . = 0x1000; + .plt : { *(.plt) } + + . = 0x2000; + .text : { *(.text) } + + . = 0x3000; + .dynamic : { *(.dynamic) } + .got : { *(.got.plt) } +}; +VERSION +{ + { + global: + foo_extern; + foo_global; + foo_hidden; + foo_rehidden; + local: + foo_local; + }; +} diff --git a/ld/testsuite/ld-vax-elf/plt-local.s b/ld/testsuite/ld-vax-elf/plt-local.s new file mode 100644 index 0000000..b1fa8f0 --- /dev/null +++ b/ld/testsuite/ld-vax-elf/plt-local.s @@ -0,0 +1,25 @@ + .text + + .globl foo_global + .type foo_global, @function +foo_global: + .word 0 + calls $0, foo_extern + calls $0, foo_global + calls $0, foo_local + calls $0, foo_hidden + calls $0, foo_rehidden + ret + .size foo_global, . - foo_global + + .globl foo_local + .type foo_local, @function +foo_local: + .word 0 + calls $0, foo_extern + calls $0, foo_global + calls $0, foo_local + calls $0, foo_hidden + calls $0, foo_rehidden + ret + .size foo_local, . - foo_local diff --git a/ld/testsuite/ld-vax-elf/vax-elf.exp b/ld/testsuite/ld-vax-elf/vax-elf.exp new file mode 100644 index 0000000..3240b1a --- /dev/null +++ b/ld/testsuite/ld-vax-elf/vax-elf.exp @@ -0,0 +1,50 @@ +# Expect script for VAX ELF linker tests +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +if { ![istarget vax-*-*] || ![is_elf_format] } { + return +} + +run_ld_link_tests [list \ + [list "PLT test (shared library)" \ + "-shared -T plt-local-lib.ld" \ + "-k" \ + { plt-local-lib.s } \ + { { objdump -d plt-local-lib.dd } } \ + "plt-local-lib.so"] \ + [list "PLT test (object 1)" \ + "-r" \ + "-k" \ + { plt-local-hidden-pic.s } \ + {} \ + "plt-local-hidden-pic-r.o"] \ + [list "PLT test (object 2)" \ + "-r" \ + "-k" \ + { plt-local-rehidden-pic.s } \ + {} \ + "plt-local-rehidden-pic-r.o"] \ + [list "PLT test (executable)" \ + "-T plt-local.ld tmpdir/plt-local-hidden-pic-r.o tmpdir/plt-local-rehidden-pic-r.o tmpdir/plt-local-lib.so" \ + "" \ + { plt-local.s } \ + { { objdump -d plt-local.dd } } \ + "plt-local"]] -- 2.7.4