This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix asan create_odr_indicator (PR sanitizer/81923)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 1 Sep 2017 13:48:04 +0200
- Subject: [PATCH] Fix asan create_odr_indicator (PR sanitizer/81923)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7FE4F356CE
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
glibc fails to build with -fsanitize=address, because DECL_ASSEMBLER_NAME
on some variables starts with the * character (e.g. for vars with __asm
specified names). We need to strip name encoding from those before
appending after __odr_asan. Fixed thusly, bootstrapped/regtested on
x86_64-linux and i686-linux, ok for trunk?
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_.
* gcc.dg/asan/pr81923.c: New test.
--- gcc/asan.c.jj 2017-08-10 02:31:21.000000000 +0200
+++ gcc/asan.c 2017-08-29 17:25:58.337595628 +0200
@@ -2529,9 +2529,12 @@ create_odr_indicator (tree decl, tree ty
/* 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)
--- gcc/testsuite/gcc.dg/asan/pr81923.c.jj 2017-08-29 18:08:59.183881570 +0200
+++ gcc/testsuite/gcc.dg/asan/pr81923.c 2017-08-29 18:09:27.643550083 +0200
@@ -0,0 +1,10 @@
+/* PR sanitizer/81923 */
+/* { dg-do link } */
+
+int foobar __asm (__USER_LABEL_PREFIX__ "barbaz") = 34;
+
+int
+main ()
+{
+ return 0;
+}
Jakub