Commit 349884d1 by Jakub Jelinek Committed by Jakub Jelinek

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
parent 2f19c491
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> 2017-09-01 Martin Liska <mliska@suse.cz>
PR tree-optimization/82059 PR tree-optimization/82059
......
...@@ -2527,9 +2527,12 @@ create_odr_indicator (tree decl, tree type) ...@@ -2527,9 +2527,12 @@ create_odr_indicator (tree decl, tree type)
/* DECL_NAME theoretically might be NULL. Bail out with 0 in this case. */ /* DECL_NAME theoretically might be NULL. Bail out with 0 in this case. */
if (decl_name == NULL_TREE) if (decl_name == NULL_TREE)
return build_int_cst (uptr, 0); 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); 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 #ifndef NO_DOT_IN_LABEL
name[sizeof ("__odr_asan") - 1] = '.'; name[sizeof ("__odr_asan") - 1] = '.';
#elif !defined(NO_DOLLAR_IN_LABEL) #elif !defined(NO_DOLLAR_IN_LABEL)
......
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> 2017-09-01 Martin Liska <mliska@suse.cz>
PR tree-optimization/82059 PR tree-optimization/82059
......
/* PR sanitizer/81923 */
/* { dg-do link } */
int foobar __asm (__USER_LABEL_PREFIX__ "barbaz") = 34;
int
main ()
{
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment