On Fri, Jun 10, 2016 at 02:12:37PM +0300, Maxim Ostapenko wrote: > gcc/ChangeLog: > > 2016-06-10 Maxim Ostapenko <m.ostape...@samsung.com> > > PR sanitizer/71480 > * varasm.c (place_block_symbol): Adjust alignment for asan protected > STRING_CSTs even if TREE_CONSTANT_POOL_ADDRESS_P.
This is ok. > diff --git a/gcc/testsuite/c-c++-common/asan/pr71480.c > b/gcc/testsuite/c-c++-common/asan/pr71480.c > new file mode 100644 > index 0000000..cf08ec6 > --- /dev/null > +++ b/gcc/testsuite/c-c++-common/asan/pr71480.c > @@ -0,0 +1,41 @@ > +/* { dg-do compile { target { arm*-*-* powerpc*-*-linux* } } } */ > +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ > + > +#ifdef __cplusplus > +extern "C" { > +#endif > +extern int > +strcmp(const char *s1, const char *s2); > +#ifdef __cplusplus > +} > +#endif Doesn't just using __builtin_strcmp and leaving out the prototype work too? > + > +__attribute__ ((noinline, noclone)) int > +foo (char *c) > +{ > + return 1; > +} > + > +__attribute__ ((noinline, noclone)) void > +bar (char *c) > +{ > + return; > +} > + > +int main (void) > +{ > + char tpl[20] = "/tmp/test.XXXXXX"; > + int fd = foo (tpl); > + > + if (fd == -1) > + return 1; > + > + bar (tpl); > + > + if (strcmp (tpl, "/tmp/test.XXXXXX") == 0) > + return 1; > + > + return 0; > +} > + But more importantly, the scan-assembler stuff is IMHO too fragile. Does the bug reproduce actually at runtime, by asan false positive on something or missing needed diagnostics? If you need to add some aligned variable into the block before and/or after the STRING_CST, so that it is really misaligned, it shouldn't be that hard to do so. And the testcase then should be usable on all architectures. Jakub