diff options
Diffstat (limited to 'gcc-4.9/gcc/c-family/c-ubsan.c')
-rw-r--r-- | gcc-4.9/gcc/c-family/c-ubsan.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc-4.9/gcc/c-family/c-ubsan.c b/gcc-4.9/gcc/c-family/c-ubsan.c index 610c010bd..e89ebc187 100644 --- a/gcc-4.9/gcc/c-family/c-ubsan.c +++ b/gcc-4.9/gcc/c-family/c-ubsan.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "ubsan.h" #include "c-family/c-common.h" #include "c-family/c-ubsan.h" +#include "asan.h" /* Instrument division by zero and INT_MIN / -1. If not instrumenting, return NULL_TREE. */ @@ -73,7 +74,7 @@ ubsan_instrument_division (location_t loc, tree op0, tree op1) make sure it gets evaluated before the condition. */ t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), op0, t); tree data = ubsan_create_data ("__ubsan_overflow_data", - loc, NULL, + &loc, NULL, ubsan_type_descriptor (type, false), NULL_TREE); data = build_fold_addr_expr_loc (loc, data); @@ -142,7 +143,7 @@ ubsan_instrument_shift (location_t loc, enum tree_code code, make sure it gets evaluated before the condition. */ t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), op0, t); tree data = ubsan_create_data ("__ubsan_shift_data", - loc, NULL, + &loc, NULL, ubsan_type_descriptor (type0, false), ubsan_type_descriptor (type1, false), NULL_TREE); @@ -169,7 +170,7 @@ ubsan_instrument_vla (location_t loc, tree size) t = fold_build2 (LE_EXPR, boolean_type_node, size, build_int_cst (type, 0)); tree data = ubsan_create_data ("__ubsan_vla_data", - loc, NULL, + &loc, NULL, ubsan_type_descriptor (type, false), NULL_TREE); data = build_fold_addr_expr_loc (loc, data); @@ -185,7 +186,11 @@ ubsan_instrument_vla (location_t loc, tree size) tree ubsan_instrument_return (location_t loc) { - tree data = ubsan_create_data ("__ubsan_missing_return_data", loc, + /* It is possible that PCH zapped table with definitions of sanitizer + builtins. Reinitialize them if needed. */ + initialize_sanitizer_builtins (); + + tree data = ubsan_create_data ("__ubsan_missing_return_data", &loc, NULL, NULL_TREE); tree t = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_MISSING_RETURN); return build_call_expr_loc (loc, t, 1, build_fold_addr_expr_loc (loc, data)); |