test: add test for gcc issue with weak hidden symbol on powerpc
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 20 May 2016 17:02:47 +0000 (13:02 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 20 May 2016 17:10:49 +0000 (13:10 -0400)
On Ubuntu 32-bit powerpc, gcc 4.4, 4.6, 4.8, gcc -O1 (and O2) causes
weak hidden symbols to have different addresses within the same module.
It seems to be fixed in gcc 4.9 on powerpc.

This issue causes some tracepoints to be silently hidden from LTTng.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
.gitignore
configure.ac
tests/Makefile.am
tests/gcc-weak-hidden/Makefile.am [new file with mode: 0644]
tests/gcc-weak-hidden/b.c [new file with mode: 0644]
tests/gcc-weak-hidden/c.c [new file with mode: 0644]
tests/gcc-weak-hidden/d.c [new file with mode: 0644]
tests/gcc-weak-hidden/main.c [new file with mode: 0644]
tests/gcc-weak-hidden/test_gcc_weak_hidden.in [new file with mode: 0755]

index a5c33fb5416b2bef8f3338ba8f5425b5a065358c..327e5cc40aa9e4b3de6c3d3e36dc8e66cc0c4acc 100644 (file)
@@ -65,6 +65,8 @@ tests/benchmark/bench1
 tests/benchmark/bench2
 tests/ctf-types/ctf-types
 tests/test-app-ctx/hello
+tests/gcc-weak-hidden/test-gcc-wh
+tests/gcc-weak-hidden/test_gcc_weak_hidden
 
 # Java agent library
 *.class
index 91354bf9daa72e6207325a3e4d7ddcec11cd30af..6a19fc2026c053373e4ce19a57b86daf18faaaf8 100644 (file)
@@ -477,6 +477,7 @@ AC_CONFIG_FILES([
        tests/benchmark/Makefile
        tests/utils/Makefile
        tests/test-app-ctx/Makefile
+       tests/gcc-weak-hidden/Makefile
        lttng-ust.pc
 ])
 
index fd2eac397a04e3e5a64f20fea5dec32748772620..935c7546bbb94c2b62eefbf0b4006d321abf8fc8 100644 (file)
@@ -1,5 +1,5 @@
 SUBDIRS = utils hello same_line_tracepoint snprintf benchmark ust-elf \
-               ctf-types test-app-ctx
+               ctf-types test-app-ctx gcc-weak-hidden
 
 if CXX_WORKS
 SUBDIRS += hello.cxx
@@ -10,7 +10,8 @@ LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
        $(top_srcdir)/config/tap-driver.sh
 
 TESTS = snprintf/test_snprintf \
-       ust-elf/test_ust_elf
+       ust-elf/test_ust_elf \
+       gcc-weak-hidden/test_gcc_weak_hidden
 
 check-loop:
        while [ 0 ]; do \
diff --git a/tests/gcc-weak-hidden/Makefile.am b/tests/gcc-weak-hidden/Makefile.am
new file mode 100644 (file)
index 0000000..ccd7e7d
--- /dev/null
@@ -0,0 +1,17 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/tests/utils
+
+noinst_LTLIBRARIES = libgcc-wh.la
+libgcc_wh_la_SOURCES = c.c d.c
+
+noinst_PROGRAMS = test-gcc-wh
+test_gcc_wh_SOURCES = main.c b.c
+test_gcc_wh_LDADD = $(top_builddir)/tests/utils/libtap.a \
+       $(builddir)/libgcc-wh.la
+
+noinst_SCRIPTS = test_gcc_weak_hidden
+CLEANFILES = $(noinst_SCRIPTS)
+EXTRA_DIST = test_gcc_weak_hidden.in
+
+$(noinst_SCRIPTS): %: %.in
+       sed "s#@ABSTOPSRCDIR@#$(abs_top_srcdir)#g" < $< > $@
+       chmod +x $@
diff --git a/tests/gcc-weak-hidden/b.c b/tests/gcc-weak-hidden/b.c
new file mode 100644 (file)
index 0000000..2419ed9
--- /dev/null
@@ -0,0 +1,6 @@
+char testsym[9] __attribute__((weak, visibility("hidden")));
+
+void *fct1(void)
+{
+       return testsym;
+}
diff --git a/tests/gcc-weak-hidden/c.c b/tests/gcc-weak-hidden/c.c
new file mode 100644 (file)
index 0000000..59f9046
--- /dev/null
@@ -0,0 +1,6 @@
+char testsym[9] __attribute__((weak, visibility("hidden")));
+
+void *fctlib1(void)
+{
+       return testsym;
+}
diff --git a/tests/gcc-weak-hidden/d.c b/tests/gcc-weak-hidden/d.c
new file mode 100644 (file)
index 0000000..bb16bdb
--- /dev/null
@@ -0,0 +1,6 @@
+char testsym[9] __attribute__((weak, visibility("hidden")));
+
+void *fctlib2(void)
+{
+       return testsym;
+}
diff --git a/tests/gcc-weak-hidden/main.c b/tests/gcc-weak-hidden/main.c
new file mode 100644 (file)
index 0000000..a2f3175
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any
+ * purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is
+ * granted, provided the above notices are retained, and a notice that
+ * the code was modified is included with the above copyright notice.
+ */
+#include "tap.h"
+
+#define NUM_TESTS 2
+
+char testsym[9] __attribute__((weak, visibility("hidden")));
+
+void *fct1(void);
+void *fctlib1(void);
+void *fctlib2(void);
+
+int main()
+{
+       plan_tests(NUM_TESTS);
+       ok(fct1() == testsym,
+               "Address of weak symbol with hidden visibility match between compile units within same module for main program");
+       ok(fctlib1() == fctlib2(),
+               "Address of weak symbol with hidden visibility match between compile units within same module for shared library");
+       return 0;
+}
diff --git a/tests/gcc-weak-hidden/test_gcc_weak_hidden.in b/tests/gcc-weak-hidden/test_gcc_weak_hidden.in
new file mode 100755 (executable)
index 0000000..7ad101f
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+TEST_DIR=$(dirname $0)
+./${TEST_DIR}/test-gcc-wh
This page took 0.028638 seconds and 4 git commands to generate.