From: Slava Barinov Date: Thu, 3 Aug 2017 13:14:59 +0000 (+0300) Subject: [TTC-5] Forbid section anchors for ASan build (PR sanitizer/81697) X-Git-Tag: accepted/tizen/4.0/base/20170908.223630^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d15cfb7789229fdffd17f1e83178f4c9b7a9969e;p=platform%2Fupstream%2Flinaro-gcc.git [TTC-5] Forbid section anchors for ASan build (PR sanitizer/81697) gcc/ * varasm.c (use_object_blocks_p): Forbid section anchors for ASan gcc/testsuite/ * g++.dg/asan/global-alignment.C: New test to test global variables alignment. Change-Id: I3887e356397c599ec74793de6d60bc285a2c872b Signed-off-by: Slava Barinov --- diff --git a/gcc/testsuite/g++.dg/asan/global-alignment.C b/gcc/testsuite/g++.dg/asan/global-alignment.C new file mode 100644 index 0000000..c011c70 --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/global-alignment.C @@ -0,0 +1,17 @@ +/* { dg-options "-fmerge-all-constants" } */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +#include +#include + +const char kRecoveryInstallString[] = "NEW"; +const char kRecoveryUpdateString[] = "UPDATE"; +const char kRecoveryUninstallationString[] = "UNINSTALL"; + +const std::map kStringToRequestMap = { + {kRecoveryInstallString, 0}, + {kRecoveryUpdateString, 0}, + {kRecoveryUninstallationString, 0}, +}; +/* { dg-final { scan-assembler-times {\.section\s+\.rodata\n(?:(?!\.section).)*\.(string|ascii|asciz)\s+"NEW} 1 } } */ diff --git a/gcc/varasm.c b/gcc/varasm.c index da88f5b..3220675 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -344,7 +344,8 @@ get_section (const char *name, unsigned int flags, tree decl) static bool use_object_blocks_p (void) { - return flag_section_anchors; + return (flag_section_anchors + && !(flag_sanitize & SANITIZE_ADDRESS)); } /* Return the object_block structure for section SECT. Create a new