This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR ld/14525: __executable_start isn't defined for PIE


Hi,

This patch provides __executable_start for PIE, similar to gold. OK
to install?

Thanks.

H.J.
--
diff --git a/ld/ChangeLog.pr14525 b/ld/ChangeLog.pr14525
new file mode 100644
index 0000000..e175be7
--- /dev/null
+++ b/ld/ChangeLog.pr14525
@@ -0,0 +1,4 @@
+2012-08-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR ld/14525
+	* scripttempl/elf.sc: Also provide __executable_start for PIE.
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.pr14525 b/ld/testsuite/ChangeLog.pr14525
new file mode 100644
index 0000000..b3bad30
--- /dev/null
+++ b/ld/testsuite/ChangeLog.pr14525
@@ -0,0 +1,7 @@
+2012-08-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR ld/14525
+	* ld-elf/elf.exp: Run pr14525.
+
+	* ld-elf/pr14525.c: New.
+	* ld-elf/pr14525.out: Likewise.
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 <stdio.h>
+
+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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]