From: Mathieu Desnoyers Date: Fri, 20 May 2016 17:02:47 +0000 (-0400) Subject: test: add test for gcc issue with weak hidden symbol on powerpc X-Git-Tag: v2.8.0~2 X-Git-Url: http://git.liburcu.org/?p=lttng-ust.git;a=commitdiff_plain;h=73de71c37c352edfcd67a9122d4b9eb1347a5f66 test: add test for gcc issue with weak hidden symbol on powerpc 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 --- diff --git a/.gitignore b/.gitignore index a5c33fb5..327e5cc4 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/configure.ac b/configure.ac index 289fc255..8da540f4 100644 --- a/configure.ac +++ b/configure.ac @@ -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 ]) diff --git a/tests/Makefile.am b/tests/Makefile.am index fd2eac39..935c7546 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 00000000..ccd7e7d6 --- /dev/null +++ b/tests/gcc-weak-hidden/Makefile.am @@ -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 index 00000000..2419ed9f --- /dev/null +++ b/tests/gcc-weak-hidden/b.c @@ -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 index 00000000..59f9046d --- /dev/null +++ b/tests/gcc-weak-hidden/c.c @@ -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 index 00000000..bb16bdb3 --- /dev/null +++ b/tests/gcc-weak-hidden/d.c @@ -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 index 00000000..a2f31756 --- /dev/null +++ b/tests/gcc-weak-hidden/main.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2016 - Mathieu Desnoyers + * + * 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 index 00000000..7ad101f7 --- /dev/null +++ b/tests/gcc-weak-hidden/test_gcc_weak_hidden.in @@ -0,0 +1,4 @@ +#!/bin/bash + +TEST_DIR=$(dirname $0) +./${TEST_DIR}/test-gcc-wh