aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog8
-rw-r--r--ld/testsuite/ld-gc/gc.exp5
-rw-r--r--ld/testsuite/ld-gc/pr14265.c20
-rw-r--r--ld/testsuite/ld-gc/pr14265.d13
-rw-r--r--ld/testsuite/ld-gc/pr14265.t22
5 files changed, 68 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 34edbe1..28c978c 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2012-08-14 Nick Clifton <nickc@redhat.com>
+
+ PR ld/14265
+ * ld-gc/gc.exp: Add a new test.
+ * ld-gc/pr14265.c: Source file for the new test.
+ * ld-gc/pr14265.t: Linker script for the new test.
+ * ld-gc/pr14265.d: Expected symbol dump.
+
2012-08-13 Maciej W. Rozycki <macro@codesourcery.com>
* ld-mips-elf/export-class-call16-o32.dd: New test.
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index 7a59ad3..ddbbd51 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -131,3 +131,8 @@ if { [is_remote host] || [which $CC] != 0 } {
ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o
run_dump_test "pr13683"
}
+
+if { [is_remote host] || [which $CC] != 0 } {
+ ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o
+ run_dump_test "pr14265"
+}
diff --git a/ld/testsuite/ld-gc/pr14265.c b/ld/testsuite/ld-gc/pr14265.c
new file mode 100644
index 0000000..6bb8f9a
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr14265.c
@@ -0,0 +1,20 @@
+int foo0 __attribute__((used,section(".foo0.0")));
+int foo1 __attribute__((used,section(".foo1.0")));
+int foo2 __attribute__((used,section(".foo2.0")));
+
+extern unsigned long __foo0_start;
+extern unsigned long __foo0_end;
+
+extern unsigned long __foo1_start;
+extern unsigned long __foo1_end;
+
+extern unsigned long __foo2_start;
+extern unsigned long __foo2_end;
+
+int
+main (void)
+{
+ return ((__foo0_end - __foo0_start) -
+ (__foo1_end - __foo1_start) -
+ (__foo2_end - __foo2_start));
+}
diff --git a/ld/testsuite/ld-gc/pr14265.d b/ld/testsuite/ld-gc/pr14265.d
new file mode 100644
index 0000000..04af982
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr14265.d
@@ -0,0 +1,13 @@
+#name: --gc-sections with KEEP
+#source: dummy.s
+#ld: --gc-sections -T pr14265.t -e 0 tmpdir/pr14265.o
+#nm: --format=bsd --numeric-sort
+
+#...
+[0-9a-f]+[ ]d[ ]_*foo1_start
+[0-9a-f]+[ ]D[ ]_*foo1
+[0-9a-f]+[ ]d[ ]_*foo1_end
+[0-9a-f]+[ ]d[ ]_*foo2_start
+[0-9a-f]+[ ]D[ ]_*foo2
+[0-9a-f]+[ ]d[ ]_*foo2_end
+#...
diff --git a/ld/testsuite/ld-gc/pr14265.t b/ld/testsuite/ld-gc/pr14265.t
new file mode 100644
index 0000000..12a2d67
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr14265.t
@@ -0,0 +1,22 @@
+SECTIONS
+{
+ .text : { *(.text) }
+
+ __foo0_start = .;
+ .foo0 : { *(.foo0.*) }
+ __foo0_end = .;
+
+ __foo1_start = .;
+ .foo1 : { KEEP(*(.foo1.*)) }
+ __foo1_end = .;
+
+ .foo2 : {
+ __foo2_start = .;
+ KEEP(*(.foo2.*))
+ __foo2_end = .;
+ }
+ /DISCARD/ : { *(*) }
+}
+
+ASSERT (__foo1_start < __foo1_end, "foo1 not KEPT");
+ASSERT ((__foo1_end - __foo1_start) == (__foo2_end - __foo2_start),"foo2 not KEPT");