summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-27 18:48:30 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-01-27 18:48:30 +0000
commitee49ca6a1c66c03e3b8ba494c78c02f0f92de050 (patch)
tree368b5c8a00ed9b3e4a5b5d67306390a2880e97da
parentd7993d8d848f2cf92aecfa0ff586bb7b222e204a (diff)
downloadgcc-ee49ca6a1c66c03e3b8ba494c78c02f0f92de050.tar.gz
PR lto/69254
* sanitizer.def: Add BEGIN_SANITIZER_BUILTINS and END_SANITIZER_BUILTINS markers using DEF_BUILTIN_STUB. * asan.c (DEF_BUILTIN_STUB): Temporarily define. * tree-streamer-in.c: Include asan.h. (streamer_get_builtin_tree): For builtins in sanitizer range call initialize_sanitizer_builtins and retry. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232891 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/asan.c3
-rw-r--r--gcc/sanitizer.def7
-rw-r--r--gcc/tree-streamer-in.c21
4 files changed, 35 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 60322afb7a6..197306031a7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2016-01-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR lto/69254
+ * sanitizer.def: Add BEGIN_SANITIZER_BUILTINS and
+ END_SANITIZER_BUILTINS markers using DEF_BUILTIN_STUB.
+ * asan.c (DEF_BUILTIN_STUB): Temporarily define.
+ * tree-streamer-in.c: Include asan.h.
+ (streamer_get_builtin_tree): For builtins in sanitizer
+ range call initialize_sanitizer_builtins and retry.
+
2016-01-27 Ian Lance Taylor <iant@google.com>
* common.opt (fkeep-gc-roots-live): New undocumented option.
diff --git a/gcc/asan.c b/gcc/asan.c
index 2f9f92fa676..1c266492fbe 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -2370,6 +2370,8 @@ initialize_sanitizer_builtins (void)
/* ECF_COLD missing */ ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST
#undef ATTR_PURE_NOTHROW_LEAF_LIST
#define ATTR_PURE_NOTHROW_LEAF_LIST ECF_PURE | ATTR_NOTHROW_LEAF_LIST
+#undef DEF_BUILTIN_STUB
+#define DEF_BUILTIN_STUB(ENUM, NAME)
#undef DEF_SANITIZER_BUILTIN
#define DEF_SANITIZER_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
decl = add_builtin_function ("__builtin_" NAME, TYPE, ENUM, \
@@ -2389,6 +2391,7 @@ initialize_sanitizer_builtins (void)
ATTR_PURE_NOTHROW_LEAF_LIST)
#undef DEF_SANITIZER_BUILTIN
+#undef DEF_BUILTIN_STUB
}
/* Called via htab_traverse. Count number of emitted
diff --git a/gcc/sanitizer.def b/gcc/sanitizer.def
index 3a71801cad8..303c1e46df4 100644
--- a/gcc/sanitizer.def
+++ b/gcc/sanitizer.def
@@ -20,12 +20,16 @@ along with GCC; see the file COPYING3. If not see
/* Before including this file, you should define a macro:
+ DEF_BUILTIN_STUB(ENUM, NAME)
DEF_SANITIZER_BUILTIN (ENUM, NAME, TYPE, ATTRS)
See builtins.def for details.
The builtins are created by the C-family of FEs in c-family/c-common.c,
for other FEs by asan.c. */
+/* This has to come before all the sanitizer builtins. */
+DEF_BUILTIN_STUB(BEGIN_SANITIZER_BUILTINS, (const char *)0)
+
/* Address Sanitizer */
DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_INIT, "__asan_init",
BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
@@ -515,3 +519,6 @@ DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS_ABORT,
DEF_SANITIZER_BUILTIN(BUILT_IN_SANITIZER_COV_TRACE_PC,
"__sanitizer_cov_trace_pc",
BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
+
+/* This has to come after all the sanitizer builtins. */
+DEF_BUILTIN_STUB(END_SANITIZER_BUILTINS, (const char *)0)
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index 3c8558e67ae..91c72eb293e 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see
#include "builtins.h"
#include "ipa-chkp.h"
#include "gomp-constants.h"
+#include "asan.h"
/* Read a STRING_CST from the string table in DATA_IN using input
@@ -1136,13 +1137,21 @@ streamer_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
fatal_error (input_location,
"machine independent builtin code out of range");
result = builtin_decl_explicit (fcode);
- if (!result
- && fcode > BEGIN_CHKP_BUILTINS
- && fcode < END_CHKP_BUILTINS)
+ if (!result)
{
- fcode = (enum built_in_function) (fcode - BEGIN_CHKP_BUILTINS - 1);
- result = builtin_decl_explicit (fcode);
- result = chkp_maybe_clone_builtin_fndecl (result);
+ if (fcode > BEGIN_CHKP_BUILTINS && fcode < END_CHKP_BUILTINS)
+ {
+ fcode = (enum built_in_function)
+ (fcode - BEGIN_CHKP_BUILTINS - 1);
+ result = builtin_decl_explicit (fcode);
+ result = chkp_maybe_clone_builtin_fndecl (result);
+ }
+ else if (fcode > BEGIN_SANITIZER_BUILTINS
+ && fcode < END_SANITIZER_BUILTINS)
+ {
+ initialize_sanitizer_builtins ();
+ result = builtin_decl_explicit (fcode);
+ }
}
gcc_assert (result);
}