i386: Add hidden weak undefined tests
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 22 Jun 2017 22:13:15 +0000 (15:13 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 22 Jun 2017 22:13:15 +0000 (15:13 -0700)
* testsuite/ld-i386/i386.exp: Run weakundef1 tests.
* testsuite/ld-i386/weakundef1.c: New file.

ld/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/weakundef1.c [new file with mode: 0644]

index 2dfc0a49481278fa0dc7d7a9740823547b6e4133..1f752e77cd1922e5fed75646bd8a7bb6a1873949 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * testsuite/ld-i386/i386.exp: Run weakundef1 tests.
+       * testsuite/ld-i386/weakundef1.c: New file.
+
 2017-06-22  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/21090
index ac4fe33d33fbf1ac478fd16cc9dae6a99c739747..6c53046193ae75f9ecee484900bc7e05838d1fcc 100644 (file)
@@ -1235,6 +1235,32 @@ if { [isnative]
     }
 }
 
+# Must be native with the C compiler.
+if { [isnative]
+     && [istarget "i?86-*-*"]
+     && [which $CC] != 0 } {
+    run_ld_link_exec_tests [list \
+       [list \
+           "Run weakundef1 without PIE" \
+           "$NOPIE_LDFLAGS" \
+           "" \
+           { weakundef1.c } \
+           "weakundef1pie" \
+           "pass.out" \
+           "$NOPIE_CFLAGS" \
+       ] \
+       [list \
+           "Run weakundef1 with PIE" \
+           "-pie" \
+           "" \
+           { weakundef1.c } \
+           "weakundef1pie" \
+           "pass.out" \
+           "-fPIE" \
+       ] \
+    ]
+}
+
 if { !([istarget "i?86-*-linux*"]
        || [istarget "x86_64-*-linux*"]) } {
     return
diff --git a/ld/testsuite/ld-i386/weakundef1.c b/ld/testsuite/ld-i386/weakundef1.c
new file mode 100644 (file)
index 0000000..ca54a5e
--- /dev/null
@@ -0,0 +1,16 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+extern int visibility_var_weak
+  __attribute__ ((weak, visibility ("hidden")));
+
+int
+main ()
+{
+  if (&visibility_var_weak != NULL)
+    abort ();
+
+  printf ("PASS\n");
+
+  return 0;
+}