Hi. I'm going to install following 3 revision in order to fix GCC.x branch:
0001-Backport-r249728.patch 0002-Backport-r249833.patch 0003-Backport-r250561.patch Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Martin
>From ce5f2421462ebf6bc02eec9729502671c3483883 Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 26 Jul 2017 08:52:37 +0000 Subject: [PATCH 3/3] Backport r250561 gcc/ChangeLog: 2017-07-26 Martin Liska <mli...@suse.cz> PR sanitize/81186 * function.c (expand_function_start): Make expansion of nonlocal_goto_save_area after parm_birth_insn. gcc/testsuite/ChangeLog: 2017-07-26 Martin Liska <mli...@suse.cz> PR sanitize/81186 * gcc.dg/asan/pr81186.c: New test. --- gcc/function.c | 20 ++++++++++---------- gcc/testsuite/gcc.dg/asan/pr81186.c | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr81186.c diff --git a/gcc/function.c b/gcc/function.c index f625489205b..9cfe58afe90 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -5263,6 +5263,16 @@ expand_function_start (tree subr) } } + /* The following was moved from init_function_start. + The move is supposed to make sdb output more accurate. */ + /* Indicate the beginning of the function body, + as opposed to parm setup. */ + emit_note (NOTE_INSN_FUNCTION_BEG); + + gcc_assert (NOTE_P (get_last_insn ())); + + parm_birth_insn = get_last_insn (); + /* If the function receives a non-local goto, then store the bits we need to restore the frame pointer. */ if (cfun->nonlocal_goto_save_area) @@ -5284,16 +5294,6 @@ expand_function_start (tree subr) update_nonlocal_goto_save_area (); } - /* The following was moved from init_function_start. - The move is supposed to make sdb output more accurate. */ - /* Indicate the beginning of the function body, - as opposed to parm setup. */ - emit_note (NOTE_INSN_FUNCTION_BEG); - - gcc_assert (NOTE_P (get_last_insn ())); - - parm_birth_insn = get_last_insn (); - if (crtl->profile) { #ifdef PROFILE_HOOK diff --git a/gcc/testsuite/gcc.dg/asan/pr81186.c b/gcc/testsuite/gcc.dg/asan/pr81186.c new file mode 100644 index 00000000000..7f0f672ca40 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr81186.c @@ -0,0 +1,18 @@ +/* PR sanitizer/81186 */ +/* { dg-do run } */ + +int +main () +{ + __label__ l; + void f () + { + int a[123]; + + goto l; + } + + f (); +l: + return 0; +} -- 2.13.3
>From dfb00296c1467623c3a5355834276309ba5ee3f9 Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri, 30 Jun 2017 08:51:00 +0000 Subject: [PATCH 2/3] Backport r249833 gcc/ChangeLog: 2017-06-30 Martin Liska <mli...@suse.cz> PR sanitizer/81021 * tree-eh.c (lower_resx): Call BUILT_IN_ASAN_HANDLE_NO_RETURN before BUILT_IN_UNWIND_RESUME when ASAN is used. gcc/testsuite/ChangeLog: 2017-06-30 Martin Liska <mli...@suse.cz> PR sanitizer/81021 * g++.dg/asan/pr81021.C: New test. --- gcc/testsuite/g++.dg/asan/pr81021.C | 33 +++++++++++++++++++++++++++++++++ gcc/tree-eh.c | 15 +++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/g++.dg/asan/pr81021.C diff --git a/gcc/testsuite/g++.dg/asan/pr81021.C b/gcc/testsuite/g++.dg/asan/pr81021.C new file mode 100644 index 00000000000..4904f19bf84 --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr81021.C @@ -0,0 +1,33 @@ +// { dg-do run } + +#include <string> + +struct ConfigFile { + ConfigFile(std::string filename, std::string delimiter) { throw "error"; } + ConfigFile(std::string filename) {} +}; + +struct Configuration { + ConfigFile _configFile; + + Configuration(const std::string &root, const char *baseName) + : _configFile(root + baseName, "=") { } + Configuration(const std::string &root, const char *a, const char *b) + : _configFile(root + a + b) { } +}; + + +void test() { + std::string root("etc"); + try { + Configuration config(root, "notthere"); + } + catch (...) { + // exception is thrown, caught here and ignored... + } + Configuration config(root, "a", "b"); // ASAN error during constructor here +} + +int main(int argc, const char *argv[]) { + test(); +} diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index fc016d795b7..ad50b32220e 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "cfgloop.h" #include "gimple-low.h" +#include "asan.h" /* In some instances a tree and a gimple need to be stored in a same table, i.e. in hash tables. This is a structure to do this. */ @@ -3304,6 +3305,20 @@ lower_resx (basic_block bb, gresx *stmt, gimple_call_set_lhs (x, var); gsi_insert_before (&gsi, x, GSI_SAME_STMT); + /* When exception handling is delegated to a caller function, we + have to guarantee that shadow memory variables living on stack + will be cleaner before control is given to a parent function. */ + if ((flag_sanitize & SANITIZE_ADDRESS) != 0 + && !lookup_attribute ("no_sanitize_address", + DECL_ATTRIBUTES (current_function_decl))) + { + tree decl + = builtin_decl_implicit (BUILT_IN_ASAN_HANDLE_NO_RETURN); + gimple *g = gimple_build_call (decl, 0); + gimple_set_location (g, gimple_location (stmt)); + gsi_insert_before (&gsi, g, GSI_SAME_STMT); + } + fn = builtin_decl_implicit (BUILT_IN_UNWIND_RESUME); x = gimple_build_call (fn, 1, var); gsi_insert_before (&gsi, x, GSI_SAME_STMT); -- 2.13.3
>From dd9a8255aefdc139f688110c8dc021e198b33ddb Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 28 Jun 2017 07:59:23 +0000 Subject: [PATCH 1/3] Backport r249728 gcc/ChangeLog: 2017-06-28 Martin Liska <mli...@suse.cz> PR sanitizer/81224 * asan.c (instrument_derefs): Bail out inner references that are hard register variables. gcc/testsuite/ChangeLog: 2017-06-28 Martin Liska <mli...@suse.cz> PR sanitizer/81224 * gcc.dg/asan/pr81224.c: New test. --- gcc/asan.c | 3 +++ gcc/testsuite/gcc.dg/asan/pr81224.c | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/asan/pr81224.c diff --git a/gcc/asan.c b/gcc/asan.c index bf564a46b28..31bc060eaf1 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1877,6 +1877,9 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, || bitsize != size_in_bytes * BITS_PER_UNIT) return; + if (VAR_P (inner) && DECL_HARD_REGISTER (inner)) + return; + if (VAR_P (inner) && offset == NULL_TREE && bitpos >= 0 diff --git a/gcc/testsuite/gcc.dg/asan/pr81224.c b/gcc/testsuite/gcc.dg/asan/pr81224.c new file mode 100644 index 00000000000..def5cb69aec --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr81224.c @@ -0,0 +1,11 @@ +/* PR sanitizer/80659 */ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-msse2" } */ + +int a; +int +b () +{ + register __attribute__ ((__vector_size__ (4 * sizeof (int)))) int c asm("xmm0"); + return c[a]; +} -- 2.13.3