From 11cba4accf7f9a82fdb7902f0e36521038eda205 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 31 Aug 2012 02:52:14 +0000 Subject: [PATCH] Provide __executable_start for PIE ld/ PR ld/14525 * scripttempl/elf.sc: Also provide __executable_start for PIE. ld/testsuite/ PR ld/14525 * ld-elf/elf.exp: Run pr14525. * ld-elf/pr14525.c: New. * ld-elf/pr14525.out: Likewise. --- ld/ChangeLog | 23 ++++++++++++++--------- ld/scripttempl/elf.sc | 2 +- ld/testsuite/ChangeLog | 26 +++++++++++++++++--------- ld/testsuite/ld-elf/elf.exp | 1 + ld/testsuite/ld-elf/pr14525.c | 11 +++++++++++ ld/testsuite/ld-elf/pr14525.out | 1 + 6 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 ld/testsuite/ld-elf/pr14525.c create mode 100644 ld/testsuite/ld-elf/pr14525.out diff --git a/ld/ChangeLog b/ld/ChangeLog index ab233cc..22f7c69 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2012-08-30 H.J. Lu + + PR ld/14525 + * scripttempl/elf.sc: Also provide __executable_start for PIE. + 2012-08-17 Kai Tietz PR ld/14326 @@ -10,15 +15,15 @@ * po/uk.po: New Ukranian translation. 2012-08-13 Ian Bolton - Laurent Desnogues - Jim MacArthur - Marcus Shawcroft - Nigel Stephens - Ramana Radhakrishnan - Richard Earnshaw - Sofiane Naci - Tejas Belagod - Yufeng Zhang + Laurent Desnogues + Jim MacArthur + Marcus Shawcroft + Nigel Stephens + Ramana Radhakrishnan + Richard Earnshaw + Sofiane Naci + Tejas Belagod + Yufeng Zhang * Makefile.am: Add AArch64. * Makefile.in: Regenerate. diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index 51a655e..72d2af7 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -335,7 +335,7 @@ SECTIONS /* Read-only sections, merged into text segment: */ ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} - ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} + ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} EOF emit_early_ro() diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index eca4181..5537d0a 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2012-08-30 H.J. Lu + + PR ld/14525 + * ld-elf/elf.exp: Run pr14525. + + * ld-elf/pr14525.c: New. + * ld-elf/pr14525.out: Likewise. + 2012-08-28 Maciej W. Rozycki * ld-elf/export-class.sd: New test. @@ -81,15 +89,15 @@ * ld-mips-elf/mips-elf.exp: Run the new tests. 2012-08-13 Ian Bolton - Laurent Desnogues - Jim MacArthur - Marcus Shawcroft - Nigel Stephens - Ramana Radhakrishnan - Richard Earnshaw - Sofiane Naci - Tejas Belagod - Yufeng Zhang + Laurent Desnogues + Jim MacArthur + Marcus Shawcroft + Nigel Stephens + Ramana Radhakrishnan + Richard Earnshaw + Sofiane Naci + Tejas Belagod + Yufeng Zhang * ld-aarch64/aarch64-elf.exp: New file. * ld-aarch64/aarch64.ld: New file. diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index 1780b50..a97e3df 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -151,6 +151,7 @@ set array_tests_pie { {"PIE init array" "-pie" "" {init.c} "init" "init.out" "-fPIE"} {"PIE fini array" "-pie" "" {fini.c} "fini" "fini.out" "-fPIE"} {"PIE init array mixed" "-pie" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"} + {"PIE PR ld/14525" "-pie" "" {pr14525.c} "pr14525" "pr14525.out" "-fPIE"} } set array_tests_static { {"static preinit array" "-static" "" {preinit.c} "preinit" "preinit.out"} diff --git a/ld/testsuite/ld-elf/pr14525.c b/ld/testsuite/ld-elf/pr14525.c new file mode 100644 index 0000000..082eb87 --- /dev/null +++ b/ld/testsuite/ld-elf/pr14525.c @@ -0,0 +1,11 @@ +#include + +extern void *__executable_start; + +int +main() +{ + if ((void **) &main >= &__executable_start) + printf ("OK\n"); + return 0; +} diff --git a/ld/testsuite/ld-elf/pr14525.out b/ld/testsuite/ld-elf/pr14525.out new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/ld/testsuite/ld-elf/pr14525.out @@ -0,0 +1 @@ +OK -- 2.7.4