[TTC-5] Forbid section anchors for ASan build (PR sanitizer/81697) 36/143336/3 accepted/tizen/base/20170908.223910 submit/tizen_base/20170905.003244 submit/tizen_base/20170907.223110
authorSlava Barinov <v.barinov@samsung.com>
Thu, 3 Aug 2017 13:14:59 +0000 (16:14 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Mon, 4 Sep 2017 06:06:09 +0000 (06:06 +0000)
       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 <v.barinov@samsung.com>
gcc/testsuite/g++.dg/asan/global-alignment.C [new file with mode: 0644]
gcc/varasm.c

diff --git a/gcc/testsuite/g++.dg/asan/global-alignment.C b/gcc/testsuite/g++.dg/asan/global-alignment.C
new file mode 100644 (file)
index 0000000..c011c70
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-options "-fmerge-all-constants" } */
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+
+#include <string>
+#include <map>
+
+const char kRecoveryInstallString[] = "NEW";
+const char kRecoveryUpdateString[] = "UPDATE";
+const char kRecoveryUninstallationString[] = "UNINSTALL";
+
+const std::map<std::string, int> kStringToRequestMap = {
+  {kRecoveryInstallString, 0},
+  {kRecoveryUpdateString, 0},
+  {kRecoveryUninstallationString, 0},
+};
+/* { dg-final { scan-assembler-times {\.section\s+\.rodata\n(?:(?!\.section).)*\.(string|ascii|asciz)\s+"NEW} 1 } } */
index da88f5b..3220675 100644 (file)
@@ -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