Add plugin visibility test
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Dec 2012 19:14:41 +0000 (19:14 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Dec 2012 19:14:41 +0000 (19:14 +0000)
* ld-plugin/func1p.c: New file.
* ld-plugin/func2i.c: Likewise.
* ld-plugin/func3h.c: Likewise.

* ld-plugin/plugin.exp (plugin_extra_elf_tests): Add plugin
visibility test.

ld/testsuite/ChangeLog
ld/testsuite/ld-plugin/func1p.c [new file with mode: 0644]
ld/testsuite/ld-plugin/func2i.c [new file with mode: 0644]
ld/testsuite/ld-plugin/func3h.c [new file with mode: 0644]
ld/testsuite/ld-plugin/plugin.exp

index c957324d1b8580dd9b178e78032dd68dc839b2fd..3a1d4371f0002ffea80fc6ccff323022a2cbdedd 100644 (file)
@@ -1,3 +1,12 @@
+2012-12-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * ld-plugin/func1p.c: New file.
+       * ld-plugin/func2i.c: Likewise.
+       * ld-plugin/func3h.c: Likewise.
+
+       * ld-plugin/plugin.exp (plugin_extra_elf_tests): Add plugin
+       visibility test.
+
 2012-12-07  H.J. Lu  <hongjiu.lu@intel.com>
 
        * lib/ld-lib.exp (check_lto_available): New.  Check if compiler
diff --git a/ld/testsuite/ld-plugin/func1p.c b/ld/testsuite/ld-plugin/func1p.c
new file mode 100644 (file)
index 0000000..917dcbb
--- /dev/null
@@ -0,0 +1,8 @@
+extern int retval;
+
+int
+__attribute__ ((visibility ("protected")))
+func1 (void)
+{
+  return retval;
+}
diff --git a/ld/testsuite/ld-plugin/func2i.c b/ld/testsuite/ld-plugin/func2i.c
new file mode 100644 (file)
index 0000000..00d7cdd
--- /dev/null
@@ -0,0 +1,8 @@
+extern int retval;
+
+int
+__attribute__ ((visibility ("internal")))
+func2 (void)
+{
+  return retval;
+}
diff --git a/ld/testsuite/ld-plugin/func3h.c b/ld/testsuite/ld-plugin/func3h.c
new file mode 100644 (file)
index 0000000..525de63
--- /dev/null
@@ -0,0 +1,8 @@
+extern int retval;
+
+int
+__attribute__ ((visibility ("hidden")))
+func3 (void)
+{
+  return retval;
+}
index d28505d85cdbaa0db7fb028795d7210a9410d33e..803ccee7242edc36af7b87ae1f2e91a70f7db085 100644 (file)
@@ -157,7 +157,11 @@ set plugin_extra_elf_tests [list \
                        -plugin-opt sym:${_}func3::0:3:0 \
                        -plugin-opt dumpresolutions \
                        -plugin-opt add:tmpdir/func.o \
-    $testobjfiles $libs --verbose=2" "" "" {{ld plugin-12.d}} "main.x" ] \
+                       -plugin-opt add:tmpdir/func1p.o \
+                       -plugin-opt add:tmpdir/func2i.o \
+                       -plugin-opt add:tmpdir/func3h.o \
+    $testobjfiles $libs --verbose=2" "" "" {{ld plugin-12.d} \
+                               {readelf -s plugin-vis-1.d}} "main.x" ] \
 ]
 
 if { !$can_compile || $failed_compile } {
@@ -174,7 +178,10 @@ if { !$can_compile || $failed_compile } {
 
 run_ld_link_tests $plugin_tests
 
-if { [is_elf_format] } {
+if { [is_elf_format] \
+     && [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func1p.c tmpdir/func1p.o] \
+     && [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func2i.c tmpdir/func2i.o] \
+     && [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func3h.c tmpdir/func3h.o] } {
     run_ld_link_tests $plugin_extra_elf_tests
 }