From 17d6eea5d50485078affbb12b895e3e508366ba9 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 11 Jun 2012 13:23:51 +0000 Subject: [PATCH] Don't hardcode .got.plt into DATA_SEGMENT_RELRO_END evaluation ld/ PR ld/14215 * ldexp.c (fold_name ): Allow forward section references. * emulparams/elf32_x86_64.sh (SEPARATE_GOTPLT): Depend on size of .got.plt. * emulparams/elf32mb_linux.sh (SEPARATE_GOTPLT): Likewise. * emulparams/elf32tilegx.sh (SEPARATE_GOTPLT): Likewise. * emulparams/elf32tilepro.sh (SEPARATE_GOTPLT): Likewise. * emulparams/elf64tilegx.sh (SEPARATE_GOTPLT): Likewise. * emulparams/elf_i386.sh (SEPARATE_GOTPLT): Likewise. * emulparams/elf_k1om.sh (SEPARATE_GOTPLT): Likewise. * emulparams/elf_l1om.sh (SEPARATE_GOTPLT): Likewise. * emulparams/elf_x86_64.sh (SEPARATE_GOTPLT): Likewise. ld/testsuite/ PR ld/14215 * ld-i386/i386.exp: Run pr14215. * ld-x86-64/x86-64.exp: Likewise. * ld-i386/pr14215.d: New file. * ld-i386/pr14215.s: Likewise. * ld-x86-64/pr14215.d: Likewise. * ld-x86-64/pr14215.s: Likewise. --- ld/ChangeLog | 16 ++++++++++++++++ ld/emulparams/elf32_x86_64.sh | 2 +- ld/emulparams/elf32mb_linux.sh | 2 +- ld/emulparams/elf32tilegx.sh | 2 +- ld/emulparams/elf32tilepro.sh | 2 +- ld/emulparams/elf64tilegx.sh | 2 +- ld/emulparams/elf_i386.sh | 2 +- ld/emulparams/elf_k1om.sh | 2 +- ld/emulparams/elf_l1om.sh | 2 +- ld/emulparams/elf_x86_64.sh | 2 +- ld/ldexp.c | 4 +++- ld/testsuite/ChangeLog | 11 +++++++++++ ld/testsuite/ld-i386/i386.exp | 1 + ld/testsuite/ld-i386/pr14215.d | 9 +++++++++ ld/testsuite/ld-i386/pr14215.s | 4 ++++ ld/testsuite/ld-x86-64/pr14215.d | 9 +++++++++ ld/testsuite/ld-x86-64/pr14215.s | 4 ++++ ld/testsuite/ld-x86-64/x86-64.exp | 1 + 18 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 ld/testsuite/ld-i386/pr14215.d create mode 100644 ld/testsuite/ld-i386/pr14215.s create mode 100644 ld/testsuite/ld-x86-64/pr14215.d create mode 100644 ld/testsuite/ld-x86-64/pr14215.s diff --git a/ld/ChangeLog b/ld/ChangeLog index e292ea45905..eb9bfbd9233 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,19 @@ +2012-06-11 Alan Modra + + PR ld/14215 + * ldexp.c (fold_name ): Allow forward section + references. + * emulparams/elf32_x86_64.sh (SEPARATE_GOTPLT): Depend on size of + .got.plt. + * emulparams/elf32mb_linux.sh (SEPARATE_GOTPLT): Likewise. + * emulparams/elf32tilegx.sh (SEPARATE_GOTPLT): Likewise. + * emulparams/elf32tilepro.sh (SEPARATE_GOTPLT): Likewise. + * emulparams/elf64tilegx.sh (SEPARATE_GOTPLT): Likewise. + * emulparams/elf_i386.sh (SEPARATE_GOTPLT): Likewise. + * emulparams/elf_k1om.sh (SEPARATE_GOTPLT): Likewise. + * emulparams/elf_l1om.sh (SEPARATE_GOTPLT): Likewise. + * emulparams/elf_x86_64.sh (SEPARATE_GOTPLT): Likewise. + 2012-06-07 Georg-Johann Lay PR 13697 diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh index fb9400312b2..bc77c85f020 100644 --- a/ld/emulparams/elf32_x86_64.sh +++ b/ld/emulparams/elf32_x86_64.sh @@ -13,7 +13,7 @@ GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes LARGE_SECTIONS=yes -SEPARATE_GOTPLT=24 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 24 ? 24 : 0" IREL_IN_PLT= if [ "x${host}" = "x${target}" ]; then diff --git a/ld/emulparams/elf32mb_linux.sh b/ld/emulparams/elf32mb_linux.sh index 3503bb1a7a5..f26f1a0c3a8 100644 --- a/ld/emulparams/elf32mb_linux.sh +++ b/ld/emulparams/elf32mb_linux.sh @@ -13,5 +13,5 @@ TEMPLATE_NAME=elf32 GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes -SEPARATE_GOTPLT=12 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 12 ? 12 : 0" diff --git a/ld/emulparams/elf32tilegx.sh b/ld/emulparams/elf32tilegx.sh index 92121e7ef27..faf3ee03867 100644 --- a/ld/emulparams/elf32tilegx.sh +++ b/ld/emulparams/elf32tilegx.sh @@ -16,7 +16,7 @@ GENERATE_SHLIB_SCRIPT=yes GENERATE_COMBRELOC_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes -SEPARATE_GOTPLT=8 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 8 ? 8 : 0" # Look for 32 bit target libraries in /lib32, /usr/lib32 etc., first. LIBPATH_SUFFIX=32 OTHER_SECTIONS=" diff --git a/ld/emulparams/elf32tilepro.sh b/ld/emulparams/elf32tilepro.sh index 5fb4443f163..01d84bcff38 100644 --- a/ld/emulparams/elf32tilepro.sh +++ b/ld/emulparams/elf32tilepro.sh @@ -17,7 +17,7 @@ GENERATE_SHLIB_SCRIPT=yes GENERATE_COMBRELOC_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes -SEPARATE_GOTPLT=8 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 8 ? 8 : 0" OTHER_SECTIONS=" /* TILEPRO architecture interrupt vector areas */ .intrpt0 0xfc000000 : { KEEP(*(.intrpt0)) } diff --git a/ld/emulparams/elf64tilegx.sh b/ld/emulparams/elf64tilegx.sh index 6ac9fa83ae8..51cbef7f3da 100644 --- a/ld/emulparams/elf64tilegx.sh +++ b/ld/emulparams/elf64tilegx.sh @@ -17,7 +17,7 @@ GENERATE_SHLIB_SCRIPT=yes GENERATE_COMBRELOC_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes -SEPARATE_GOTPLT=16 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 16 ? 16 : 0" OTHER_SECTIONS=" /* TILE architecture interrupt vector areas */ .intrpt0 0xfffffffffc000000 : { KEEP(*(.intrpt0)) } diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh index 2b2f910fd6a..665a1ad3660 100644 --- a/ld/emulparams/elf_i386.sh +++ b/ld/emulparams/elf_i386.sh @@ -11,5 +11,5 @@ TEMPLATE_NAME=elf32 GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes -SEPARATE_GOTPLT=12 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 12 ? 12 : 0" IREL_IN_PLT= diff --git a/ld/emulparams/elf_k1om.sh b/ld/emulparams/elf_k1om.sh index d28ffc0761b..e77b2b00848 100644 --- a/ld/emulparams/elf_k1om.sh +++ b/ld/emulparams/elf_k1om.sh @@ -14,7 +14,7 @@ GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes LARGE_SECTIONS=yes -SEPARATE_GOTPLT=24 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 24 ? 24 : 0" if [ "x${host}" = "x${target}" ]; then case " $EMULATION_LIBPATH " in diff --git a/ld/emulparams/elf_l1om.sh b/ld/emulparams/elf_l1om.sh index 80152fea304..624f4b305d7 100644 --- a/ld/emulparams/elf_l1om.sh +++ b/ld/emulparams/elf_l1om.sh @@ -14,7 +14,7 @@ GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes LARGE_SECTIONS=yes -SEPARATE_GOTPLT=24 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 24 ? 24 : 0" if [ "x${host}" = "x${target}" ]; then case " $EMULATION_LIBPATH " in diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh index c38e8453ce0..f1b60cba884 100644 --- a/ld/emulparams/elf_x86_64.sh +++ b/ld/emulparams/elf_x86_64.sh @@ -13,7 +13,7 @@ GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes LARGE_SECTIONS=yes -SEPARATE_GOTPLT=24 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 24 ? 24 : 0" IREL_IN_PLT= if [ "x${host}" = "x${target}" ]; then diff --git a/ld/ldexp.c b/ld/ldexp.c index 3bddc813e0d..d83e274f273 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -681,7 +681,7 @@ fold_name (etree_type *tree) tree, tree->name.name); new_number (0); } - else if (os->processed_vma) + else if (os->bfd_section != NULL) { bfd_vma val; @@ -693,6 +693,8 @@ fold_name (etree_type *tree) new_number (val); } + else + new_number (0); } break; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index a37ddc11223..ba73f8c11b0 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2012-06-11 H.J. Lu + + PR ld/14215 + * ld-i386/i386.exp: Run pr14215. + * ld-x86-64/x86-64.exp: Likewise. + + * ld-i386/pr14215.d: New file. + * ld-i386/pr14215.s: Likewise. + * ld-x86-64/pr14215.d: Likewise. + * ld-x86-64/pr14215.s: Likewise. + 2012-06-06 Alan Modra * ld-alpha/tlsbin.rd, * ld-alpha/tlsbinr.rd, * ld-alpha/tlspic.rd, diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 47f918fa187..03367ca1296 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -245,3 +245,4 @@ if { !([istarget "i?86-*-linux*"] run_dump_test "compressed1" run_dump_test "pr12627" run_dump_test "pr13302" +run_dump_test "pr14215" diff --git a/ld/testsuite/ld-i386/pr14215.d b/ld/testsuite/ld-i386/pr14215.d new file mode 100644 index 00000000000..78ec994bc3b --- /dev/null +++ b/ld/testsuite/ld-i386/pr14215.d @@ -0,0 +1,9 @@ +#name: PR ld/14215 +#as: --32 +#ld: -melf_i386 -shared -z relro +#readelf: -l --wide + +#failif +#... + 03 .dynamic .got .data +#... diff --git a/ld/testsuite/ld-i386/pr14215.s b/ld/testsuite/ld-i386/pr14215.s new file mode 100644 index 00000000000..df0cbc256f5 --- /dev/null +++ b/ld/testsuite/ld-i386/pr14215.s @@ -0,0 +1,4 @@ + .section .got + .space 0x2a8, 4 + .data + .zero 12 diff --git a/ld/testsuite/ld-x86-64/pr14215.d b/ld/testsuite/ld-x86-64/pr14215.d new file mode 100644 index 00000000000..7d8e90d04b8 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr14215.d @@ -0,0 +1,9 @@ +#name: PR ld/14215 +#as: --64 +#ld: -melf_x86_64 -shared -z relro +#readelf: -l --wide + +#failif +#... + 03 .dynamic .got .data +#... diff --git a/ld/testsuite/ld-x86-64/pr14215.s b/ld/testsuite/ld-x86-64/pr14215.s new file mode 100644 index 00000000000..281b638c54d --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr14215.s @@ -0,0 +1,4 @@ + .section .got + .space 0x2a8, 4 + .data + .zero 24 diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 7d2934f9b52..b9af8dea93c 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -208,6 +208,7 @@ run_dump_test "pr12921" run_dump_test "pr13947" run_dump_test "pr12570a" run_dump_test "pr12570b" +run_dump_test "pr14215" if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { return -- 2.30.2