aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-05-07 14:12:59 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-05-07 14:12:59 +0000
commit310fd250b9bdab1eae5303f363577e30b2932a77 (patch)
tree728a50e468368a77342a5f692954d19fc0c938d6 /ld/testsuite
parent70778fc76803fd416f0bb898773811f12baa0714 (diff)
downloadgdb-310fd250b9bdab1eae5303f363577e30b2932a77.zip
gdb-310fd250b9bdab1eae5303f363577e30b2932a77.tar.gz
gdb-310fd250b9bdab1eae5303f363577e30b2932a77.tar.bz2
Reverse copy .ctors/.dtors sections if needed.
bfd/ 2011-05-07 H.J. Lu <hongjiu.lu@intel.com> PR ld/12730 * elf.c (_bfd_elf_section_offset): Check SEC_ELF_REVERSE_COPY. * elflink.c (elf_link_input_bfd): Reverse copy .ctors/.dtors sections if needed. * section.c (SEC_ELF_REVERSE_COPY): New. * bfd-in2.h: Regenerated. ld/testsuite/ 2011-05-07 H.J. Lu <hongjiu.lu@intel.com> PR ld/12730 * ld-elf/elf.exp (array_tests): Add "pr12730". (array_tests_pie): New. (array_tests_static): Add -static for "static init array mixed". Add "static pr12730". Run array_tests_pie for Linux. * ld-elf/init-mixed.c (ctor1007): Renamed to ... (ctor1007a): This. (ctor1007b): New. (ctors1007): Remove ctor1007. Add ctor1007b and ctor1007a. (dtor1007): Renamed to ... (dtor1007a): This. (dtor1007b): New. (dtors1007): Remove dtor1007. Add dtor1007b and dtor1007a. (ctor65535): Renamed to ... (ctor65535a): This. (ctor65535b): New. (ctors65535): Remove ctor65535. Add ctor65535b and ctor65535a. (dtor65535): Renamed to ... (dtor65535a): This. (dtor65535b): New. (dtors65535): Remove dtor65535. Add dtor65535b and dtor65535a. * ld-elf/pr12730.cc: New. * ld-elf/pr12730.out: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog28
-rw-r--r--ld/testsuite/ld-elf/elf.exp17
-rw-r--r--ld/testsuite/ld-elf/init-mixed.c46
-rw-r--r--ld/testsuite/ld-elf/pr12730.cc38
-rw-r--r--ld/testsuite/ld-elf/pr12730.out1
5 files changed, 120 insertions, 10 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 6b9320b..c312749 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,31 @@
+2011-05-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/12730
+ * ld-elf/elf.exp (array_tests): Add "pr12730".
+ (array_tests_pie): New.
+ (array_tests_static): Add -static for "static init array mixed".
+ Add "static pr12730". Run array_tests_pie for Linux.
+
+ * ld-elf/init-mixed.c (ctor1007): Renamed to ...
+ (ctor1007a): This.
+ (ctor1007b): New.
+ (ctors1007): Remove ctor1007. Add ctor1007b and ctor1007a.
+ (dtor1007): Renamed to ...
+ (dtor1007a): This.
+ (dtor1007b): New.
+ (dtors1007): Remove dtor1007. Add dtor1007b and dtor1007a.
+ (ctor65535): Renamed to ...
+ (ctor65535a): This.
+ (ctor65535b): New.
+ (ctors65535): Remove ctor65535. Add ctor65535b and ctor65535a.
+ (dtor65535): Renamed to ...
+ (dtor65535a): This.
+ (dtor65535b): New.
+ (dtors65535): Remove dtor65535. Add dtor65535b and dtor65535a.
+
+ * ld-elf/pr12730.cc: New.
+ * ld-elf/pr12730.out: Likewise.
+
2011-05-06 Richard Sandiford <richard.sandiford@linaro.org>
* ld-arm/cortex-a8-fix-b-plt.s, ld-arm/cortex-a8-fix-b-plt.d,
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index 73a417c..6808d8a 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -81,17 +81,32 @@ set array_tests {
{"init array" "" "" {init.c} "init" "init.out"}
{"fini array" "" "" {fini.c} "fini" "fini.out"}
{"init array mixed" "" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
+ {"pr12730" "" "" {pr12730.cc} "pr12730" "pr12730.out" "" "c++"}
+}
+set array_tests_pie {
+ {"PIE preinit array" "-pie" "" {preinit.c} "preinit" "preinit.out" "-fPIE" }
+ {"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 pr12730" "-pie" "" {pr12730.cc} "pr12730" "pr12730.out" "-fPIE" "c++"}
}
set array_tests_static {
{"static preinit array" "-static" "" {preinit.c} "preinit" "preinit.out"}
{"static init array" "-static" "" {init.c} "init" "init.out"}
{"static fini array" "-static" "" {fini.c} "fini" "fini.out"}
- {"static init array mixed" "" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
+ {"static init array mixed" "-static" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
+ {"static pr12730" "-static" "" {pr12730.cc} "pr12730" "pr12730.out" "" "c++"}
}
# NetBSD ELF systems do not currently support the .*_array sections.
set xfails [list "*-*-netbsdelf*"]
run_ld_link_exec_tests $xfails $array_tests
+
+# Run PIE tests only on Linux.
+if { [istarget "*-*-linux*"] } {
+ run_ld_link_exec_tests $xfails $array_tests_pie
+}
+
# Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc.
switch -regexp $target_triplet {
^\[^-\]*-\[^-\]*-gnu.*$ {
diff --git a/ld/testsuite/ld-elf/init-mixed.c b/ld/testsuite/ld-elf/init-mixed.c
index 1d0c727..770a4b5 100644
--- a/ld/testsuite/ld-elf/init-mixed.c
+++ b/ld/testsuite/ld-elf/init-mixed.c
@@ -27,25 +27,39 @@ void (*const fini_array1005[]) ()
= { fini1005 };
static void
-ctor1007 ()
+ctor1007a ()
{
if (count != 1005)
abort ();
+ count = 1006;
+}
+static void
+ctor1007b ()
+{
+ if (count != 1006)
+ abort ();
count = 1007;
}
void (*const ctors1007[]) ()
__attribute__ ((section (".ctors.64528"), aligned (sizeof (void *))))
- = { ctor1007 };
+ = { ctor1007b, ctor1007a };
static void
-dtor1007 ()
+dtor1007a ()
{
- if (count != 1007)
+ if (count != 1006)
abort ();
count = 1005;
}
+static void
+dtor1007b ()
+{
+ if (count != 1007)
+ abort ();
+ count = 1006;
+}
void (*const dtors1007[]) ()
__attribute__ ((section (".dtors.64528"), aligned (sizeof (void *))))
- = { dtor1007 };
+ = { dtor1007b, dtor1007a };
static void
init65530 ()
@@ -69,17 +83,31 @@ void (*const fini_array65530[]) ()
= { fini65530 };
static void
-ctor65535 ()
+ctor65535a ()
{
if (count != 65530)
abort ();
count = 65535;
}
+static void
+ctor65535b ()
+{
+ if (count != 65535)
+ abort ();
+ count = 65536;
+}
void (*const ctors65535[]) ()
__attribute__ ((section (".ctors"), aligned (sizeof (void *))))
- = { ctor65535 };
+ = { ctor65535b, ctor65535a };
+static void
+dtor65535b ()
+{
+ if (count != 65536)
+ abort ();
+ count = 65535;
+}
static void
-dtor65535 ()
+dtor65535a ()
{
if (count != 65535)
abort ();
@@ -87,7 +115,7 @@ dtor65535 ()
}
void (*const dtors65535[]) ()
__attribute__ ((section (".dtors"), aligned (sizeof (void *))))
- = { dtor65535 };
+ = { dtor65535b, dtor65535a };
#endif
int
diff --git a/ld/testsuite/ld-elf/pr12730.cc b/ld/testsuite/ld-elf/pr12730.cc
new file mode 100644
index 0000000..69f57f9
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr12730.cc
@@ -0,0 +1,38 @@
+#include <iostream>
+
+class Hello
+{
+public:
+ Hello ()
+ {}
+
+ ~Hello ()
+ {}
+
+ void act ()
+ { std::cout << "Hello, world!" << std::endl; }
+};
+
+
+template <class T>
+struct Foo
+{
+ T* _M_allocate_single_object ()
+ {
+ return new T;
+ }
+};
+
+static void __attribute__ (( constructor )) PWLIB_StaticLoader() {
+ Foo<Hello> allocator;
+ Hello* salut = allocator._M_allocate_single_object ();
+ salut->act ();
+}
+
+
+int
+main (int /*argc*/,
+ char* /*argv*/[])
+{
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/pr12730.out b/ld/testsuite/ld-elf/pr12730.out
new file mode 100644
index 0000000..af5626b
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr12730.out
@@ -0,0 +1 @@
+Hello, world!