diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-11-29 13:30:36 +0100 |
---|---|---|
committer | Yury Gribov <ygribov@gcc.gnu.org> | 2013-11-29 12:30:36 +0000 |
commit | 35814b034651b543b2521f9bd028c35f1fcaac1a (patch) | |
tree | 0cc2ab434efd00fd5b66854aa66871625d4c011b /gcc | |
parent | 08c5a7c685a97e0870fe278a1113523763b7af5f (diff) | |
download | gcc-35814b034651b543b2521f9bd028c35f1fcaac1a.zip gcc-35814b034651b543b2521f9bd028c35f1fcaac1a.tar.gz gcc-35814b034651b543b2521f9bd028c35f1fcaac1a.tar.bz2 |
re PR sanitizer/59063 (ASAN: segfault in __interceptor_clock_gettime)
gcc/
2013-11-29 Jakub Jelinek <jakub@redhat.com>
Yury Gribov <y.gribov@samsung.com>
PR sanitizer/59063
* config/gnu-user.h: Removed old code for setting up sanitizer
libs.
* gcc.c: Using libsanitizer spec instead of explicit libs.
gcc/testsuite/
2013-11-29 Jakub Jelinek <jakub@redhat.com>
Yury Gribov <y.gribov@samsung.com>
PR sanitizer/59063
* c-c++-common/asan/pr59063-1.c: New test.
* c-c++-common/asan/pr59063-2.c: Likewise.
* lib/asan-dg.exp: Add path to libsanitizer.spec to cflags.
* lib/ubsan-dg.exp: Likewise.
libsanitizer/
2013-11-29 Jakub Jelinek <jakub@redhat.com>
Yury Gribov <y.gribov@samsung.com>
PR sanitizer/59063
* libsanitizer.spec.in: Add spec file to hold link flags for
various sanitizer libs.
* configure.ac: Check whether clock_* routines come from librt.
* asan/Makefile.am (libasan_la_LDFLAGS): Libs now come from
configure.ac.
* tsan/Makefile.am (libtsan_la_LDFLAGS): Likewise.
* ubsan/Makefile.am (libubsan_la_LDFLAGS): Likewise.
* lsan/Makefile.am (liblsan_la_LDFLAGS): Likewise.
* asan/Makefile.in: Regenerate.
* interception/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
* Makefile.in: Regenerate.
* configure: Regenerate.
Co-Authored-By: Yury Gribov <y.gribov@samsung.com>
From-SVN: r205524
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/gnu-user.h | 16 | ||||
-rw-r--r-- | gcc/gcc.c | 52 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/asan/pr59063-1.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/asan/pr59063-2.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/lib/asan-dg.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/lib/ubsan-dg.exp | 2 |
8 files changed, 60 insertions, 52 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b40ff36..33fa159 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2013-11-29 Jakub Jelinek <jakub@redhat.com> + Yury Gribov <y.gribov@samsung.com> + + PR sanitizer/59063 + * config/gnu-user.h: Removed old code for setting up sanitizer + libs. + * gcc.c: Using libsanitizer spec instead of explicit libs. + 2013-11-29 Ilya Enkovich <ilya.enkovich@intel.com> Reverted: diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h index 157e147..60eb30d 100644 --- a/gcc/config/gnu-user.h +++ b/gcc/config/gnu-user.h @@ -126,19 +126,3 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \ LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}" #endif - -/* Additional libraries needed by -static-libasan. */ -#undef STATIC_LIBASAN_LIBS -#define STATIC_LIBASAN_LIBS "-ldl -lpthread" - -/* Additional libraries needed by -static-libtsan. */ -#undef STATIC_LIBTSAN_LIBS -#define STATIC_LIBTSAN_LIBS "-ldl -lpthread" - -/* Additional libraries needed by -static-liblsan. */ -#undef STATIC_LIBLSAN_LIBS -#define STATIC_LIBLSAN_LIBS "-ldl -lpthread" - -/* Additional libraries needed by -static-libubsan. */ -#undef STATIC_LIBUBSAN_LIBS -#define STATIC_LIBUBSAN_LIBS "-ldl -lpthread" @@ -535,20 +535,16 @@ proper position among the other output files. */ #define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}" #ifndef LIBASAN_SPEC -#ifdef STATIC_LIBASAN_LIBS -#define ADD_STATIC_LIBASAN_LIBS \ - " %{static-libasan:" STATIC_LIBASAN_LIBS "}" -#else -#define ADD_STATIC_LIBASAN_LIBS -#endif +#define STATIC_LIBASAN_LIBS \ + " %{static-libasan:%:include(libsanitizer.spec)%(link_libasan)}" #ifdef LIBASAN_EARLY_SPEC -#define LIBASAN_SPEC ADD_STATIC_LIBASAN_LIBS +#define LIBASAN_SPEC STATIC_LIBASAN_LIBS #elif defined(HAVE_LD_STATIC_DYNAMIC) #define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \ "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \ - ADD_STATIC_LIBASAN_LIBS + STATIC_LIBASAN_LIBS #else -#define LIBASAN_SPEC "-lasan" ADD_STATIC_LIBASAN_LIBS +#define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS #endif #endif @@ -557,20 +553,16 @@ proper position among the other output files. */ #endif #ifndef LIBTSAN_SPEC -#ifdef STATIC_LIBTSAN_LIBS -#define ADD_STATIC_LIBTSAN_LIBS \ - " %{static-libtsan:" STATIC_LIBTSAN_LIBS "}" -#else -#define ADD_STATIC_LIBTSAN_LIBS -#endif +#define STATIC_LIBTSAN_LIBS \ + " %{static-libtsan:%:include(libsanitizer.spec)%(link_libtsan)}" #ifdef LIBTSAN_EARLY_SPEC -#define LIBTSAN_SPEC ADD_STATIC_LIBTSAN_LIBS +#define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS #elif defined(HAVE_LD_STATIC_DYNAMIC) #define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \ "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ - ADD_STATIC_LIBTSAN_LIBS + STATIC_LIBTSAN_LIBS #else -#define LIBTSAN_SPEC "-ltsan" ADD_STATIC_LIBTSAN_LIBS +#define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS #endif #endif @@ -579,34 +571,26 @@ proper position among the other output files. */ #endif #ifndef LIBLSAN_SPEC -#ifdef STATIC_LIBLSAN_LIBS -#define ADD_STATIC_LIBLSAN_LIBS \ - " %{static-liblsan:" STATIC_LIBLSAN_LIBS "}" -#else -#define ADD_STATIC_LIBLSAN_LIBS -#endif +#define STATIC_LIBLSAN_LIBS \ + " %{static-liblsan:%:include(libsanitizer.spec)%(link_liblsan)}" #ifdef HAVE_LD_STATIC_DYNAMIC #define LIBLSAN_SPEC "%{!shared:%{static-liblsan:" LD_STATIC_OPTION \ "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ - ADD_STATIC_LIBLSAN_LIBS "}" + STATIC_LIBLSAN_LIBS "}" #else -#define LIBLSAN_SPEC "%{!shared:-llsan" ADD_STATIC_LIBLSAN_LIBS "}" +#define LIBLSAN_SPEC "%{!shared:-llsan" STATIC_LIBLSAN_LIBS "}" #endif #endif #ifndef LIBUBSAN_SPEC -#ifdef STATIC_LIBUBSAN_LIBS -#define ADD_STATIC_LIBUBSAN_LIBS \ - " %{static-libubsan:" STATIC_LIBUBSAN_LIBS "}" -#else -#define ADD_STATIC_LIBUBSAN_LIBS -#endif +#define STATIC_LIBUBSAN_LIBS \ + " %{static-libubsan:%:include(libsanitizer.spec)%(link_libubsan)}" #ifdef HAVE_LD_STATIC_DYNAMIC #define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \ "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ - ADD_STATIC_LIBUBSAN_LIBS + STATIC_LIBUBSAN_LIBS #else -#define LIBUBSAN_SPEC "-lubsan" ADD_STATIC_LIBUBSAN_LIBS +#define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS #endif #endif diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 713980f..75ccd01 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2013-11-29 Jakub Jelinek <jakub@redhat.com> + Yury Gribov <y.gribov@samsung.com> + + PR sanitizer/59063 + * c-c++-common/asan/pr59063-1.c: New test. + * c-c++-common/asan/pr59063-2.c: Likewise. + * lib/asan-dg.exp: Add path to libsanitizer.spec to cflags. + * lib/ubsan-dg.exp: Likewise. + 2013-11-29 Eric Botcazou <ebotcazou@adacore.com> * gnat.dg/opt29.ad[sb]: New test. diff --git a/gcc/testsuite/c-c++-common/asan/pr59063-1.c b/gcc/testsuite/c-c++-common/asan/pr59063-1.c new file mode 100644 index 0000000..a4e01f7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr59063-1.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ + +#include <time.h> +static int weak_gettime (clockid_t clk_id, struct timespec *tp) + __attribute__((__weakref__("clock_gettime"))); +int main() { + if (!clock_gettime) + return 0; + struct timespec ts; + return weak_gettime(CLOCK_MONOTONIC, &ts); +} diff --git a/gcc/testsuite/c-c++-common/asan/pr59063-2.c b/gcc/testsuite/c-c++-common/asan/pr59063-2.c new file mode 100644 index 0000000..64354ea --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr59063-2.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-static-libasan" } */ + +#include <time.h> +static int weak_gettime (clockid_t clk_id, struct timespec *tp) + __attribute__((__weakref__("clock_gettime"))); +int main() { + if (!clock_gettime) + return 0; + struct timespec ts; + return weak_gettime(CLOCK_MONOTONIC, &ts); +} diff --git a/gcc/testsuite/lib/asan-dg.exp b/gcc/testsuite/lib/asan-dg.exp index e0bf2da..823265c 100644 --- a/gcc/testsuite/lib/asan-dg.exp +++ b/gcc/testsuite/lib/asan-dg.exp @@ -39,9 +39,9 @@ proc asan_link_flags { paths } { set shlib_ext [get_shlib_extension] if { $gccpath != "" } { + append flags " -B${gccpath}/libsanitizer/asan/ " if { [file exists "${gccpath}/libsanitizer/asan/.libs/libasan.a"] || [file exists "${gccpath}/libsanitizer/asan/.libs/libasan.${shlib_ext}"] } { - append flags " -B${gccpath}/libsanitizer/asan/ " append flags " -L${gccpath}/libsanitizer/asan/.libs " append ld_library_path ":${gccpath}/libsanitizer/asan/.libs" } diff --git a/gcc/testsuite/lib/ubsan-dg.exp b/gcc/testsuite/lib/ubsan-dg.exp index 4ec5fdf..2e6b272 100644 --- a/gcc/testsuite/lib/ubsan-dg.exp +++ b/gcc/testsuite/lib/ubsan-dg.exp @@ -30,9 +30,9 @@ proc ubsan_link_flags { paths } { set shlib_ext [get_shlib_extension] if { $gccpath != "" } { + append flags " -B${gccpath}/libsanitizer/ubsan/ " if { [file exists "${gccpath}/libsanitizer/ubsan/.libs/libubsan.a"] || [file exists "${gccpath}/libsanitizer/ubsan/.libs/libubsan.${shlib_ext}"] } { - append flags " -B${gccpath}/libsanitizer/ubsan/ " append flags " -L${gccpath}/libsanitizer/ubsan/.libs" append ld_library_path ":${gccpath}/libsanitizer/ubsan/.libs" } |