diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-02-23 05:18:43 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-03-14 18:07:02 -0700 |
commit | 160d3e0600f6e47492f371904692b22e284f2629 (patch) | |
tree | 854957e81246819073603796abf2c96c76d29735 | |
parent | 71f9d50691870216209a62550cf97398bb2ea337 (diff) | |
download | binutils-gdb-users/hjl/dynamic/binutils-2_26-branch.tar.gz |
Make linker assigned symbol dynamic only for shared objectusers/hjl/dynamic/binutils-2_26-branch
Linker assigned symbols should be made dynamic by default only when
creating shared object or relocatable executable.
We should always create the dynsym section, even if it is empty, with
dynamic sections.
Backport from master
bfd/
* elflink.c (bfd_elf_record_link_assignment): Check for shared
library, instead of PIC, and don't check PDE when making linker
assigned symbol dynamic.
* elflink.c (_bfd_elf_link_renumber_dynsyms): Always create the
dynsym section, even if it is empty, with dynamic sections.
ld/
* testsuite/ld-frv/fdpic-pie-6.d: Updated.
* testsuite/ld-mips-elf/pie-n32.d: Likewise.
* testsuite/ld-mips-elf/pie-n64.d: Likewise.
* testsuite/ld-mips-elf/pie-o32.d: Likewise.
-rw-r--r-- | bfd/ChangeLog | 14 | ||||
-rw-r--r-- | bfd/elflink.c | 11 | ||||
-rw-r--r-- | ld/ChangeLog | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-frv/fdpic-pie-6.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pie-n32.d | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pie-n64.d | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pie-o32.d | 14 |
7 files changed, 54 insertions, 31 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ac1513b5515..04b27ea1be4 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,6 +1,20 @@ 2016-03-14 H.J. Lu <hongjiu.lu@intel.com> Backport from master + 2016-02-23 H.J. Lu <hongjiu.lu@intel.com> + + * elflink.c (bfd_elf_record_link_assignment): Check for shared + library, instead of PIC, and don't check PDE when making linker + assigned symbol dynamic. + + 2016-02-22 H.J. Lu <hongjiu.lu@intel.com> + + * elflink.c (_bfd_elf_link_renumber_dynsyms): Always create the + dynsym section, even if it is empty, with dynamic sections. + +2016-03-14 H.J. Lu <hongjiu.lu@intel.com> + + Backport from master 2016-01-30 H.J. Lu <hongjiu.lu@intel.com> PR ld/19539 diff --git a/bfd/elflink.c b/bfd/elflink.c index 842e85ba741..d128025b5e3 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -645,9 +645,8 @@ bfd_elf_record_link_assignment (bfd *output_bfd, if ((h->def_dynamic || h->ref_dynamic - || bfd_link_pic (info) - || (bfd_link_pde (info) - && elf_hash_table (info)->is_relocatable_executable)) + || bfd_link_dll (info) + || elf_hash_table (info)->is_relocatable_executable) && h->dynindx == -1) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) @@ -888,9 +887,9 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd, &dynsymcount); /* There is an unused NULL entry at the head of the table which - we must account for in our count. Unless there weren't any - symbols, which means we'll have no table at all. */ - if (dynsymcount != 0) + we must account for in our count. We always create the dynsym + section, even if it is empty, with dynamic sections. */ + if (elf_hash_table (info)->dynamic_sections_created) ++dynsymcount; elf_hash_table (info)->dynsymcount = dynsymcount; diff --git a/ld/ChangeLog b/ld/ChangeLog index af588b2b0c2..716624f3a56 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,6 +1,16 @@ 2016-03-14 H.J. Lu <hongjiu.lu@intel.com> Backport from master + 2016-02-23 H.J. Lu <hongjiu.lu@intel.com> + + * testsuite/ld-frv/fdpic-pie-6.d: Updated. + * testsuite/ld-mips-elf/pie-n32.d: Likewise. + * testsuite/ld-mips-elf/pie-n64.d: Likewise. + * testsuite/ld-mips-elf/pie-o32.d: Likewise. + +2016-03-14 H.J. Lu <hongjiu.lu@intel.com> + + Backport from master 2016-02-20 H.J. Lu <hongjiu.lu@intel.com> * testsuite/ld-elf/pr19539.d: Skip cris*-*-* targets. diff --git a/ld/testsuite/ld-frv/fdpic-pie-6.d b/ld/testsuite/ld-frv/fdpic-pie-6.d index 7bdda5dfa5a..c59b30484af 100644 --- a/ld/testsuite/ld-frv/fdpic-pie-6.d +++ b/ld/testsuite/ld-frv/fdpic-pie-6.d @@ -49,16 +49,16 @@ Disassembly of section \.dat[0-9a-f ]+: Disassembly of section \.got: [0-9a-f ]+<_GLOBAL_OFFSET_TABLE_-0x20>: -[0-9a-f ]+: 00 00 04 b8 .* +[0-9a-f ]+: 00 00 03 b0 .* [0-9a-f ]+: R_FRV_FUNCDESC_VALUE WF9 [0-9a-f ]+: 00 00 00 02 .* -[0-9a-f ]+: 00 00 04 b0 .* +[0-9a-f ]+: 00 00 03 a8 .* [0-9a-f ]+: R_FRV_FUNCDESC_VALUE WF8 [0-9a-f ]+: 00 00 00 02 .* -[0-9a-f ]+: 00 00 04 a8 .* +[0-9a-f ]+: 00 00 03 a0 .* [0-9a-f ]+: R_FRV_FUNCDESC_VALUE WF0 [0-9a-f ]+: 00 00 00 02 .* -[0-9a-f ]+: 00 00 04 a0 .* +[0-9a-f ]+: 00 00 03 98 .* [0-9a-f ]+: R_FRV_FUNCDESC_VALUE WF7 [0-9a-f ]+: 00 00 00 02 .* diff --git a/ld/testsuite/ld-mips-elf/pie-n32.d b/ld/testsuite/ld-mips-elf/pie-n32.d index dec984d72fa..4b641029f27 100644 --- a/ld/testsuite/ld-mips-elf/pie-n32.d +++ b/ld/testsuite/ld-mips-elf/pie-n32.d @@ -6,19 +6,19 @@ Dynamic section at offset 0x180 contains 17 entries: Tag * Type * Name/Value 0x00000004 \(HASH\) * 0x230 - 0x00000005 \(STRTAB\) * 0x30c - 0x00000006 \(SYMTAB\) * 0x26c - 0x0000000a \(STRSZ\) * 72 \(bytes\) + 0x00000005 \(STRTAB\) * 0x28c + 0x00000006 \(SYMTAB\) * 0x24c + 0x0000000a \(STRSZ\) * 28 \(bytes\) 0x0000000b \(SYMENT\) * 16 \(bytes\) - 0x70000035 \(MIPS_RLD_MAP_REL\) * 0x101c8 + 0x70000035 \(MIPS_RLD_MAP_REL\) * 0x10118 0x00000015 \(DEBUG\) * 0x0 - 0x00000003 \(PLTGOT\) * 0x10380 + 0x00000003 \(PLTGOT\) * 0x102d0 0x70000001 \(MIPS_RLD_VERSION\) * 1 0x70000005 \(MIPS_FLAGS\) * NOTPOT 0x70000006 \(MIPS_BASE_ADDRESS\) * 0x0 0x7000000a \(MIPS_LOCAL_GOTNO\) * 2 - 0x70000011 \(MIPS_SYMTABNO\) * 10 + 0x70000011 \(MIPS_SYMTABNO\) * 4 0x70000012 \(MIPS_UNREFEXTNO\) * 13 - 0x70000013 \(MIPS_GOTSYM\) * 0xa + 0x70000013 \(MIPS_GOTSYM\) * 0x4 0x6ffffffb \(FLAGS_1\) * Flags: PIE 0x00000000 \(NULL\) * 0x0 diff --git a/ld/testsuite/ld-mips-elf/pie-n64.d b/ld/testsuite/ld-mips-elf/pie-n64.d index 75a78e3e0db..b7f57a80770 100644 --- a/ld/testsuite/ld-mips-elf/pie-n64.d +++ b/ld/testsuite/ld-mips-elf/pie-n64.d @@ -6,19 +6,19 @@ Dynamic section at offset 0x208 contains 17 entries: Tag * Type * Name/Value 0x0+00000004 \(HASH\) * 0x368 - 0x0+00000005 \(STRTAB\) * 0x498 - 0x0+00000006 \(SYMTAB\) * 0x3a8 - 0x0+0000000a \(STRSZ\) * 72 \(bytes\) + 0x0+00000005 \(STRTAB\) * 0x3e8 + 0x0+00000006 \(SYMTAB\) * 0x388 + 0x0+0000000a \(STRSZ\) * 28 \(bytes\) 0x0+0000000b \(SYMENT\) * 24 \(bytes\) - 0x0+70000035 \(MIPS_RLD_MAP_REL\) * 0x102b8 + 0x0+70000035 \(MIPS_RLD_MAP_REL\) * 0x101e8 0x0+00000015 \(DEBUG\) * 0x0 - 0x0+00000003 \(PLTGOT\) * 0x10520 + 0x0+00000003 \(PLTGOT\) * 0x10450 0x0+70000001 \(MIPS_RLD_VERSION\) * 1 0x0+70000005 \(MIPS_FLAGS\) * NOTPOT 0x0+70000006 \(MIPS_BASE_ADDRESS\) * 0x0 0x0+7000000a \(MIPS_LOCAL_GOTNO\) * 2 - 0x0+70000011 \(MIPS_SYMTABNO\) * 10 + 0x0+70000011 \(MIPS_SYMTABNO\) * 4 0x0+70000012 \(MIPS_UNREFEXTNO\) * 13 - 0x0+70000013 \(MIPS_GOTSYM\) * 0xa + 0x0+70000013 \(MIPS_GOTSYM\) * 0x4 0x0+6ffffffb \(FLAGS_1\) * Flags: PIE 0x0+00000000 \(NULL\) * 0x0 diff --git a/ld/testsuite/ld-mips-elf/pie-o32.d b/ld/testsuite/ld-mips-elf/pie-o32.d index 4db3d2c6afc..aa4693d2d77 100644 --- a/ld/testsuite/ld-mips-elf/pie-o32.d +++ b/ld/testsuite/ld-mips-elf/pie-o32.d @@ -6,19 +6,19 @@ Dynamic section at offset 0x178 contains 17 entries: Tag * Type * Name/Value 0x00000004 \(HASH\) * 0x228 - 0x00000005 \(STRTAB\) * 0x304 - 0x00000006 \(SYMTAB\) * 0x264 - 0x0000000a \(STRSZ\) * 72 \(bytes\) + 0x00000005 \(STRTAB\) * 0x284 + 0x00000006 \(SYMTAB\) * 0x244 + 0x0000000a \(STRSZ\) * 28 \(bytes\) 0x0000000b \(SYMENT\) * 16 \(bytes\) - 0x70000035 \(MIPS_RLD_MAP_REL\) * 0x101c0 + 0x70000035 \(MIPS_RLD_MAP_REL\) * 0x10110 0x00000015 \(DEBUG\) * 0x0 - 0x00000003 \(PLTGOT\) * 0x10370 + 0x00000003 \(PLTGOT\) * 0x102c0 0x70000001 \(MIPS_RLD_VERSION\) * 1 0x70000005 \(MIPS_FLAGS\) * NOTPOT 0x70000006 \(MIPS_BASE_ADDRESS\) * 0x0 0x7000000a \(MIPS_LOCAL_GOTNO\) * 2 - 0x70000011 \(MIPS_SYMTABNO\) * 10 + 0x70000011 \(MIPS_SYMTABNO\) * 4 0x70000012 \(MIPS_UNREFEXTNO\) * 13 - 0x70000013 \(MIPS_GOTSYM\) * 0xa + 0x70000013 \(MIPS_GOTSYM\) * 0x4 0x6ffffffb \(FLAGS_1\) * Flags: PIE 0x00000000 \(NULL\) * 0x0 |