re PR sanitizer/81923 ([ASAN] gcc emites wrong odr asan instrumentation for glibc)
authorJakub Jelinek <jakub@redhat.com>
Fri, 1 Sep 2017 13:46:14 +0000 (15:46 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 1 Sep 2017 13:46:14 +0000 (15:46 +0200)
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

gcc/ChangeLog
gcc/asan.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/asan/pr81923.c [new file with mode: 0644]

index 125eb92..8d36fa6 100644 (file)
@@ -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
index ce1e024..9f29491 100644 (file)
@@ -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)
index 0cd2a62..b304563 100644 (file)
@@ -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 (file)
index 0000000..f81d512
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR sanitizer/81923 */
+/* { dg-do link } */
+
+int foobar __asm (__USER_LABEL_PREFIX__ "barbaz") = 34;
+
+int
+main ()
+{
+  return 0;
+}