Add testcases for PR ld/14323
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 10 Jul 2012 04:51:53 +0000 (04:51 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 10 Jul 2012 04:51:53 +0000 (04:51 +0000)
PR ld/14323
* ld-elf/pr14323-1.c: New.
* ld-elf/pr14323-2.c: Likewise.

* ld-elf/shared.exp (build_tests): Add libpr14323-2.so.
(run_tests): Add pr14323.

ld/testsuite/ChangeLog
ld/testsuite/ld-elf/pr14323-1.c [new file with mode: 0644]
ld/testsuite/ld-elf/pr14323-2.c [new file with mode: 0644]
ld/testsuite/ld-elf/shared.exp

index c1cfb34..f04cf04 100644 (file)
@@ -1,3 +1,12 @@
+2012-07-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/14323
+       * ld-elf/pr14323-1.c: New.
+       * ld-elf/pr14323-2.c: Likewise.
+
+       * ld-elf/shared.exp (build_tests): Add libpr14323-2.so.
+       (run_tests): Add pr14323.
+
 2012-07-03  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/3351
diff --git a/ld/testsuite/ld-elf/pr14323-1.c b/ld/testsuite/ld-elf/pr14323-1.c
new file mode 100644 (file)
index 0000000..9f63f4c
--- /dev/null
@@ -0,0 +1,17 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+extern int foo_alias;
+extern char *bar ();
+
+int
+main ()
+{
+  if (foo_alias != 0)
+    abort ();
+  bar ();
+  if (foo_alias != -1)
+    abort ();
+  printf ("PASS\n");
+  return 0;
+}
diff --git a/ld/testsuite/ld-elf/pr14323-2.c b/ld/testsuite/ld-elf/pr14323-2.c
new file mode 100644 (file)
index 0000000..34753d1
--- /dev/null
@@ -0,0 +1,13 @@
+int foo __attribute__ ((section ("_data_foo"))) = 0;
+extern int foo_alias __attribute__ ((weak, alias ("foo")));
+extern char __start__data_foo;
+asm (".type __start__data_foo,%object");
+int x1 = 1;
+int x2 = 2;
+
+char *
+bar ()
+{
+  foo = -1;
+  return &__start__data_foo;
+}
index aaaa85b..c00f3e5 100644 (file)
@@ -170,6 +170,9 @@ set build_tests {
   {"Build libpr13250-3.o"
    "-r -nostdlib" ""
    {pr13250-3.c} {} "libpr13250-3.o"}
+  {"Build libpr14323-2.so"
+   "-shared" "-fPIC"
+   {pr14323-2.c} {} "libpr14323-2.so"}
 }
 
 run_cc_link_tests $build_tests
@@ -302,6 +305,9 @@ set run_tests {
     {"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so"
      "--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" ""
      {dummy.c} "pr13250" "pass.out"}
+    {"Run with pr14323-1.c pr14323-2.so"
+     "tmpdir/libpr14323-2.so" ""
+     {pr14323-1.c} "pr14323" "pass.out"}
 }
 
 # NetBSD ELF systems do not currently support the .*_array sections.