backport: re PR sanitizer/81923 ([ASAN] gcc emites wrong odr asan instrumentation for glibc)

Backported from mainline
	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.

From-SVN: r251854
This commit is contained in:
Jakub Jelinek 2017-09-07 22:29:04 +02:00 committed by Jakub Jelinek
parent 9e2e13bd6d
commit f7b87491a9
4 changed files with 26 additions and 2 deletions

View File

@ -1,6 +1,12 @@
2017-09-07 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
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-08-09 Jakub Jelinek <jakub@redhat.com>
PR c/81687

View File

@ -2315,9 +2315,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)

View File

@ -1,6 +1,11 @@
2017-09-07 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2017-09-01 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/81923
* gcc.dg/asan/pr81923.c: New test.
2017-08-03 Jakub Jelinek <jakub@redhat.com>
PR target/81621

View File

@ -0,0 +1,10 @@
/* PR sanitizer/81923 */
/* { dg-do link } */
int foobar __asm (__USER_LABEL_PREFIX__ "barbaz") = 34;
int
main ()
{
return 0;
}