aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-09-01 15:46:14 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-09-01 15:46:14 +0200
commit349884d1e38b08263682b5b94dec796398444e2a (patch)
tree7e143c64e24a4c5d7eeeed6fc2952351215af285 /gcc
parent2f19c491dee57eac5a93a271726c096529c5729b (diff)
downloadgcc-349884d1e38b08263682b5b94dec796398444e2a.zip
gcc-349884d1e38b08263682b5b94dec796398444e2a.tar.gz
gcc-349884d1e38b08263682b5b94dec796398444e2a.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/asan.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/asan/pr81923.c10
4 files changed, 26 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 125eb92..8d36fa6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ 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 <mliska@suse.cz>
PR tree-optimization/82059
diff --git a/gcc/asan.c b/gcc/asan.c
index ce1e024..9f29491 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 0cd2a62..b304563 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR sanitizer/81923
+ * gcc.dg/asan/pr81923.c: New test.
+
2017-09-01 Martin Liska <mliska@suse.cz>
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 0000000..f81d512
--- /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;
+}