diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2010-07-14 00:30:57 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2010-07-14 00:30:57 +0000 |
commit | a7b16ceb928e405dc096f2af5ca7c7321e5e2e7a (patch) | |
tree | a15122e38442d047ba5fcd23f8460176c95f9ee4 | |
parent | 6ae10a308748553b3e864c8a795c536573000de7 (diff) | |
download | ppe42-binutils-a7b16ceb928e405dc096f2af5ca7c7321e5e2e7a.tar.gz ppe42-binutils-a7b16ceb928e405dc096f2af5ca7c7321e5e2e7a.zip |
Don't allocate .got.plt section if there are no GOT nor PLT entries.
bfd/
2010-07-13 H.J. Lu <hongjiu.lu@intel.com>
PR ld/11812
* elf32-i386.c (elf_i386_size_dynamic_sections): Don't
allocate .got.plt section if there are no GOT nor PLT
entries.
* elf64-x86-64.c (elf64_x86_64_size_dynamic_sections): Likewise.
ld/testsuite/
2010-07-13 H.J. Lu <hongjiu.lu@intel.com>
PR ld/11812
* ld-elf/exclude3b.d: Don't run on ia64-*-*. Replace .got with
.dynamic.
* ld-elf/exclude3d.d: New.
* ld-i386/nogot1.d: Likewise.
* ld-i386/nogot1.s: Likewise.
* ld-x86-64/nogot1.d: Likewise.
* ld-x86-64/nogot1.s: Likewise.
* ld-i386/i386.exp: Run nogot1.
* ld-x86-64/x86-64.exp: Likewise.
-rw-r--r-- | bfd/ChangeLog | 8 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 17 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 17 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/exclude3b.d | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/exclude3d.d | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/i386.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/nogot1.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/nogot1.s | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/nogot1.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/nogot1.s | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/x86-64.exp | 1 |
12 files changed, 106 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e12771ae94..26b38aec47 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,13 @@ 2010-07-13 H.J. Lu <hongjiu.lu@intel.com> + PR ld/11812 + * elf32-i386.c (elf_i386_size_dynamic_sections): Don't + allocate .got.plt section if there are no GOT nor PLT + entries. + * elf64-x86-64.c (elf64_x86_64_size_dynamic_sections): Likewise. + +2010-07-13 H.J. Lu <hongjiu.lu@intel.com> + PR ld/11791 * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Support garbage collection against STT_GNU_IFUNC symbols. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index ac9bdb63eb..0ff31471f3 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2555,6 +2555,23 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab->elf.srelplt) htab->sgotplt_jump_table_size = htab->next_tls_desc_index * 4; + if (htab->elf.sgotplt) + { + /* Don't allocate .got.plt section if there are no GOT nor PLT + entries. */ + if ((htab->elf.sgotplt->size + == get_elf_backend_data (output_bfd)->got_header_size) + && (htab->elf.splt == NULL + || htab->elf.splt->size == 0) + && (htab->elf.sgot == NULL + || htab->elf.sgot->size == 0) + && (htab->elf.iplt == NULL + || htab->elf.iplt->size == 0) + && (htab->elf.igotplt == NULL + || htab->elf.igotplt->size == 0)) + htab->elf.sgotplt->size = 0; + } + /* We now have determined the sizes of the various dynamic sections. Allocate memory for them. */ relocs = FALSE; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 108f2578fd..b0bc5c0125 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2374,6 +2374,23 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, } } + if (htab->elf.sgotplt) + { + /* Don't allocate .got.plt section if there are no GOT nor PLT + entries. */ + if ((htab->elf.sgotplt->size + == get_elf_backend_data (output_bfd)->got_header_size) + && (htab->elf.splt == NULL + || htab->elf.splt->size == 0) + && (htab->elf.sgot == NULL + || htab->elf.sgot->size == 0) + && (htab->elf.iplt == NULL + || htab->elf.iplt->size == 0) + && (htab->elf.igotplt == NULL + || htab->elf.igotplt->size == 0)) + htab->elf.sgotplt->size = 0; + } + /* We now have determined the sizes of the various dynamic sections. Allocate memory for them. */ relocs = FALSE; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index a1f9e6b154..71ce0e6f18 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,5 +1,20 @@ 2010-07-13 H.J. Lu <hongjiu.lu@intel.com> + PR ld/11812 + * ld-elf/exclude3b.d: Don't run on ia64-*-*. Replace .got with + .dynamic. + + * ld-elf/exclude3d.d: New. + * ld-i386/nogot1.d: Likewise. + * ld-i386/nogot1.s: Likewise. + * ld-x86-64/nogot1.d: Likewise. + * ld-x86-64/nogot1.s: Likewise. + + * ld-i386/i386.exp: Run nogot1. + * ld-x86-64/x86-64.exp: Likewise. + +2010-07-13 H.J. Lu <hongjiu.lu@intel.com> + * ld-i386/hidden2.d: Don't hard code expected output. * ld-i386/protected3.d: Likewise. * ld-x86-64/hidden2.d: Likewise. diff --git a/ld/testsuite/ld-elf/exclude3b.d b/ld/testsuite/ld-elf/exclude3b.d index f6404492fa..8d8a43fd98 100644 --- a/ld/testsuite/ld-elf/exclude3b.d +++ b/ld/testsuite/ld-elf/exclude3b.d @@ -1,9 +1,9 @@ #source: exclude3.s #ld: --shared #readelf: -S --wide -#target: x86_64-*-* i?86-*-* ia64-*-* +#target: x86_64-*-* i?86-*-* #... -[ ]*\[.*\][ ]+\.got.*[ ]+PROGBITS.* +[ ]*\[.*\][ ]+\.dynamic[ ]+DYNAMIC.* [ ]*\[.*\][ ]+.*STRTAB.* #pass diff --git a/ld/testsuite/ld-elf/exclude3d.d b/ld/testsuite/ld-elf/exclude3d.d new file mode 100644 index 0000000000..0d487f5eb3 --- /dev/null +++ b/ld/testsuite/ld-elf/exclude3d.d @@ -0,0 +1,9 @@ +#source: exclude3.s +#ld: --shared +#readelf: -S --wide +#target: ia64-*-* + +#... +[ ]*\[.*\][ ]+\.got.*[ ]+PROGBITS.* +[ ]*\[.*\][ ]+.*STRTAB.* +#pass diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index a88a436334..3f20533c3a 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -189,3 +189,4 @@ run_dump_test "protected1" run_dump_test "protected2" run_dump_test "protected3" run_dump_test "tlspie1" +run_dump_test "nogot1" diff --git a/ld/testsuite/ld-i386/nogot1.d b/ld/testsuite/ld-i386/nogot1.d new file mode 100644 index 0000000000..a6c883240b --- /dev/null +++ b/ld/testsuite/ld-i386/nogot1.d @@ -0,0 +1,8 @@ +#ld: --shared -melf_i386 +#readelf: -S --wide +#as: --32 + +#... +[ ]*\[.*\][ ]+\.dynamic[ ]+DYNAMIC.* +[ ]*\[.*\][ ]+.*STRTAB.* +#pass diff --git a/ld/testsuite/ld-i386/nogot1.s b/ld/testsuite/ld-i386/nogot1.s new file mode 100644 index 0000000000..c657231057 --- /dev/null +++ b/ld/testsuite/ld-i386/nogot1.s @@ -0,0 +1,10 @@ + .type bar, @function +bar: + ret + .size bar, .-bar +.globl foo + .type foo, @function +foo: + leal bar@GOTOFF(%ecx), %eax + ret + .size foo, .-foo diff --git a/ld/testsuite/ld-x86-64/nogot1.d b/ld/testsuite/ld-x86-64/nogot1.d new file mode 100644 index 0000000000..f6c4cf15e1 --- /dev/null +++ b/ld/testsuite/ld-x86-64/nogot1.d @@ -0,0 +1,8 @@ +#ld: --shared -melf_x86_64 +#readelf: -S --wide +#as: --64 + +#... +[ ]*\[.*\][ ]+\.dynamic[ ]+DYNAMIC.* +[ ]*\[.*\][ ]+.*STRTAB.* +#pass diff --git a/ld/testsuite/ld-x86-64/nogot1.s b/ld/testsuite/ld-x86-64/nogot1.s new file mode 100644 index 0000000000..d884f6f339 --- /dev/null +++ b/ld/testsuite/ld-x86-64/nogot1.s @@ -0,0 +1,10 @@ + .type bar, @function +bar: + ret + .size bar, .-bar +.globl foo + .type foo, @function +foo: + leaq bar(%rip), %rax + ret + .size foo, .-foo diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index a8ebd4119f..76ac47463c 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -98,3 +98,4 @@ run_dump_test "protected3-l1om" run_dump_test "tlsle1" run_dump_test "tlspie1" run_dump_test "unique1" +run_dump_test "nogot1" |