re PR sanitizer/78651 (Incorrect exception handling when catch clause uses local...
authorMaxim Ostapenko <m.ostapenko@samsung.com>
Mon, 19 Mar 2018 19:59:56 +0000 (19:59 +0000)
committerMaxim Ostapenko <chefmax@gcc.gnu.org>
Mon, 19 Mar 2018 19:59:56 +0000 (21:59 +0200)
2018-03-19  Maxim Ostapenko  <m.ostapenko@samsung.com>

gcc/

PR sanitizer/78651
* dwarf2asm.c (dw2_output_indirect_constant_1): Disable ASan before
calling assemble_variable.

gcc/testsuite/

PR sanitizer/78651
* g++.dg/asan/pr78651.C: New test.

From-SVN: r258658

gcc/ChangeLog
gcc/dwarf2asm.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/asan/pr78651.C [new file with mode: 0644]

index 713e9642833ad74859e93cb3a7bf493f72307d00..7745ef615481de93a7f46163d9ac571f21bf0ed2 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-19  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+       PR sanitizer/78651
+       * dwarf2asm.c (dw2_output_indirect_constant_1): Disable ASan before
+       calling assemble_variable.
+
 2018-03-19  Sudakshina Das  <sudi.das@arm.com>
 
        PR target/81647
index e9b18b8b78520131116ced6d0431db568af1b307..2e108acc0d78ef4a6b33d1ead837f4ccd48671dc 100644 (file)
@@ -967,7 +967,13 @@ dw2_output_indirect_constant_1 (const char *sym, tree id)
     }
 
   sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
+  /* Disable ASan for decl because redzones cause ABI breakage between GCC and
+     libstdc++ for `.LDFCM*' variables.  See PR 78651 for details.  */
+  unsigned int save_flag_sanitize = flag_sanitize;
+  flag_sanitize &= ~(SANITIZE_ADDRESS | SANITIZE_USER_ADDRESS
+                    | SANITIZE_KERNEL_ADDRESS);
   assemble_variable (decl, 1, 1, 1);
+  flag_sanitize = save_flag_sanitize;
   assemble_integer (sym_ref, POINTER_SIZE_UNITS, POINTER_SIZE, 1);
 
   return 0;
index 0a15d69cccd4878a6bd3bee93dc49b9b0dc3e3d2..e3309b33d1b5367be4b0d42cd51d6b8787b17ea6 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-19  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+       PR sanitizer/78651
+       * g++.dg/asan/pr78651.C: New test.
+
 2018-03-19  Tom de Vries  <tom@codesourcery.com>
 
        * gcc.dg/tree-ssa/pr84512.c: Don't require effective target
diff --git a/gcc/testsuite/g++.dg/asan/pr78651.C b/gcc/testsuite/g++.dg/asan/pr78651.C
new file mode 100644 (file)
index 0000000..09f1be5
--- /dev/null
@@ -0,0 +1,26 @@
+// PR sanitizer/78651
+// { dg-do run }
+// { dg-additional-options "-fpic" { target fpic } }
+
+struct A { };
+
+namespace {
+
+void thisThrows () {
+  throw A();
+}
+
+struct SomeRandomType {};
+}
+
+int main() {
+  try {
+    thisThrows();
+  }
+  catch (SomeRandomType) {
+    throw;
+  }
+  catch (A) {
+  }
+  return 0;
+}