From: Jakub Jelinek Date: Fri, 1 Sep 2017 13:46:14 +0000 (+0200) Subject: re PR sanitizer/81923 ([ASAN] gcc emites wrong odr asan instrumentation for glibc) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=349884d1e38b08263682b5b94dec796398444e2a;p=gcc.git re PR sanitizer/81923 ([ASAN] gcc emites wrong odr asan instrumentation for glibc) PR sanitizer/81923 * asan.c (create_odr_indicator): Strip name encoding from assembler name before appending it after __odr_asan_. * gcc.dg/asan/pr81923.c: New test. From-SVN: r251595 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 125eb928211..8d36fa6563d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-09-01 Jakub Jelinek + + PR sanitizer/81923 + * asan.c (create_odr_indicator): Strip name encoding from assembler + name before appending it after __odr_asan_. + 2017-09-01 Martin Liska PR tree-optimization/82059 diff --git a/gcc/asan.c b/gcc/asan.c index ce1e0244ec6..9f29491a7c3 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2527,9 +2527,12 @@ create_odr_indicator (tree decl, tree type) /* DECL_NAME theoretically might be NULL. Bail out with 0 in this case. */ if (decl_name == NULL_TREE) return build_int_cst (uptr, 0); - size_t len = strlen (IDENTIFIER_POINTER (decl_name)) + sizeof ("__odr_asan_"); + const char *dname = IDENTIFIER_POINTER (decl_name); + if (HAS_DECL_ASSEMBLER_NAME_P (decl)) + dname = targetm.strip_name_encoding (dname); + size_t len = strlen (dname) + sizeof ("__odr_asan_"); name = XALLOCAVEC (char, len); - snprintf (name, len, "__odr_asan_%s", IDENTIFIER_POINTER (decl_name)); + snprintf (name, len, "__odr_asan_%s", dname); #ifndef NO_DOT_IN_LABEL name[sizeof ("__odr_asan") - 1] = '.'; #elif !defined(NO_DOLLAR_IN_LABEL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0cd2a62e5e5..b3045634838 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-09-01 Jakub Jelinek + + PR sanitizer/81923 + * gcc.dg/asan/pr81923.c: New test. + 2017-09-01 Martin Liska PR tree-optimization/82059 diff --git a/gcc/testsuite/gcc.dg/asan/pr81923.c b/gcc/testsuite/gcc.dg/asan/pr81923.c new file mode 100644 index 00000000000..f81d512c96e --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr81923.c @@ -0,0 +1,10 @@ +/* PR sanitizer/81923 */ +/* { dg-do link } */ + +int foobar __asm (__USER_LABEL_PREFIX__ "barbaz") = 34; + +int +main () +{ + return 0; +}