GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "c-family/c-common.h"
#include "gimple.h"
#include "cfghooks.h"
#include "tree-pass.h"
#include "memmodel.h"
#include "tm_p.h"
#include "ssa.h"
#include "cgraph.h"
#include "tree-pretty-print.h"
#include "stor-layout.h"
#include "cfganal.h"
#include "gimple-iterator.h"
#include "output.h"
#include "cfgloop.h"
#include "ubsan.h"
#include "expr.h"
#include "stringpool.h"
#include "attribs.h"
#include "asan.h"
#include "gimplify-me.h"
#include "dfp.h"
#include "builtins.h"
#include "tree-object-size.h"
#include "tree-cfg.h"
#include "gimple-fold.h"
#include "varasm.h"
#include "realmpfr.h"
#include "target.h"
#include "langhooks.h"
#include "gt-ubsan.h"
Data Structures | |
struct | tree_type_map |
struct | tree_type_map_cache_hasher |
Macros | |
#define | OBJSZ_MAX_OFFSET (1024 * 16) |
Variables | |
static hash_table< tree_type_map_cache_hasher > * | decl_tree_for_type |
static tree | ubsan_type_descriptor_type |
static tree | ubsan_source_location_type |
static unsigned int | ubsan_ids [2] |
static tree | ubsan_vptr_type_cache_decl |
#define OBJSZ_MAX_OFFSET (1024 * 16) |
Referenced by ubsan_expand_objsize_ifn().
Insert a mapping TYPE->DECL in the VAR_DECL for type hashtable.
References tree_type_map::decl, decl_tree_for_type, ggc_alloc(), tree_type_map::type, type(), and TYPE_UID.
Referenced by ubsan_type_descriptor().
Lookup a VAR_DECL for TYPE, and return it if we find one.
References hash_table< Descriptor, Lazy, Allocator >::create_ggc(), tree_type_map::decl, decl_tree_for_type, NULL, NULL_TREE, tree_type_map::type, type(), and TYPE_UID.
Referenced by ubsan_type_descriptor().
|
static |
This routine returns a magic number for TYPE.
References exact_log2(), gcc_assert, INTEGRAL_TYPE_P, SCALAR_FLOAT_TYPE_P, tree_to_uhwi(), TYPE_SIZE, and TYPE_UNSIGNED.
Referenced by ubsan_type_descriptor().
|
static |
Instrument loads from (non-bitfield) bool and C++ enum values to check if the memory value is outside of the range of the valid type values.
References boolean_false_node, boolean_true_node, build2(), build_fold_addr_expr, build_fold_addr_expr_loc(), build_int_cst(), build_nonstandard_integer_type(), build_pointer_type(), build_qualified_type(), builtin_decl_explicit(), create_cond_insert_point(), DECL_HARD_REGISTER, ENCODE_QUAL_ADDR_SPACE, find_fallthru_edge(), fold_convert, force_gimple_operand_gsi(), g, get_inner_reference(), GET_MODE_BITSIZE(), GET_MODE_PRECISION(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_set_lhs(), gimple_assign_set_rhs_from_tree(), gimple_assign_set_rhs_with_ops(), gimple_bb(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_location(), gimple_set_location(), gsi_after_labels(), gsi_for_stmt(), gsi_insert_after(), gsi_insert_before(), gsi_insert_on_edge_immediate(), GSI_NEW_STMT, GSI_SAME_STMT, gsi_stmt(), int_const_binop(), integer_zerop(), make_ssa_name(), NULL_TREE, offset, reference_alias_ptr_type(), SANITIZE_BOOL, SANITIZE_ENUM, sanitize_flags_p(), SCALAR_INT_TYPE_MODE, stmt_ends_bb_p(), TREE_CODE, TREE_TYPE, TYPE_ADDR_SPACE, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_PRECISION, TYPE_QUALS, ubsan_create_data(), ubsan_create_edge(), ubsan_encode_value(), UBSAN_ENCODE_VALUE_GIMPLE, ubsan_type_descriptor(), update_stmt(), and VAR_P.
|
static |
Instrument values passed to builtin functions.
References build_fold_addr_expr_loc(), build_int_cst(), build_zero_cst(), builtin_decl_explicit(), CASE_INT_FN, create_cond_insert_point(), DECL_FUNCTION_CODE(), g, gcc_fallthrough, gimple_assign_lhs(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_call_arg(), gimple_call_fndecl(), gimple_location(), gimple_set_location(), gsi_after_labels(), gsi_for_stmt(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, gsi_stmt(), integer_nonzerop(), is_gimple_val(), make_ssa_name(), NULL_TREE, SANITIZE_BUILTIN, TREE_TYPE, ubsan_create_data(), ubsan_create_edge(), and unsigned_char_type_node.
|
static |
Instrument a memory reference. BASE is the base of MEM, IS_LHS says whether the pointer is on the left hand side of the assignment.
References ADDR_SPACE_GENERIC_P, build_int_cst(), build_pointer_type(), g, gimple_build_call_internal(), gimple_location(), gimple_set_location(), gsi_safe_insert_before(), gsi_stmt(), min_align_of_type(), pointer_sized_int_node, POINTER_TYPE_P, RECORD_OR_UNION_TYPE_P, SANITIZE_ALIGNMENT, sanitize_flags_p(), SANITIZE_NULL, targetm, TREE_OPERAND, TREE_TYPE, TYPE_ADDR_SPACE, UBSAN_LOAD_OF, UBSAN_MEMBER_ACCESS, and UBSAN_STORE_OF.
Referenced by instrument_null().
|
static |
Instrument values passed to function arguments with nonnull attribute.
References build_fold_addr_expr_loc(), build_int_cst(), build_zero_cst(), builtin_decl_explicit(), create_cond_insert_point(), g, gimple_assign_lhs(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_call_arg(), gimple_call_num_args(), gimple_location(), gimple_set_location(), gsi_after_labels(), gsi_for_stmt(), gsi_insert_after(), GSI_NEW_STMT, gsi_safe_insert_before(), gsi_stmt(), i, infer_nonnull_range_by_attribute(), integer_type_node, is_gimple_val(), make_ssa_name(), NULL_TREE, POINTER_TYPE_P, SANITIZE_NONNULL_ATTRIBUTE, TREE_TYPE, ubsan_create_data(), ubsan_create_edge(), and UNKNOWN_LOCATION.
|
static |
Instrument returns in functions with returns_nonnull attribute.
References as_a(), build_fold_addr_expr_loc(), build_zero_cst(), builtin_decl_explicit(), create_cond_insert_point(), g, gimple_build_call(), gimple_build_cond(), gimple_location(), gimple_return_retval(), gimple_set_location(), gsi_after_labels(), gsi_for_stmt(), gsi_insert_after(), GSI_NEW_STMT, gsi_safe_insert_before(), gsi_stmt(), infer_nonnull_range_by_attribute(), is_gimple_val(), NULL_TREE, POINTER_TYPE_P, SANITIZE_RETURNS_NONNULL_ATTRIBUTE, TREE_TYPE, ubsan_create_data(), ubsan_create_edge(), and UNKNOWN_LOCATION.
|
static |
Perform the pointer instrumentation.
References get_base_address(), instrument_mem_ref(), NULL_TREE, TREE_CODE, and TREE_OPERAND.
|
static |
Instrument memory references. Here we check whether the pointer points to an out-of-bounds location.
References build1(), build3(), build_call_expr_loc(), build_int_cst(), build_pointer_type(), builtin_decl_explicit(), compute_builtin_object_size(), current_function_decl, DECL_BIT_FIELD_REPRESENTATIVE, decl_function_context(), DECL_P, DECL_REGISTER, fold_build2, fold_convert, force_gimple_operand(), g, get_inner_reference(), gimple_assign_cast_p(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_ssa_name_copy_p(), gimple_build_call_internal(), gimple_call_builtin_p(), gimple_location(), gimple_seq_add_seq_without_update(), gimple_set_location(), gsi_last(), gsi_safe_insert_before(), gsi_safe_insert_seq_before(), gsi_stmt(), input_location, int_size_in_bytes(), integer_zero_node, is_gimple_assign(), is_global_var(), LOCATION_LOCUS, mark_addressable(), NULL, NULL_TREE, offset, OST_DYNAMIC, pointer_sized_int_node, POINTER_TYPE_P, size_in_bytes(), sizetype, SSA_NAME_DEF_STMT, SSA_NAME_OCCURS_IN_ABNORMAL_PHI, SSA_VAR_P, TREE_ADDRESSABLE, TREE_CODE, tree_int_cst_le(), tree_int_cst_lt(), tree_int_cst_sgn(), TREE_OPERAND, TREE_TYPE, type(), TYPE_SIZE_UNIT, ubsan_create_edge(), UBSAN_LOAD_OF, UBSAN_STORE_OF, UNKNOWN_LOCATION, unsigned_char_type_node, VAR_P, and VOID_TYPE_P.
|
static |
Instrument pointer arithmetics PTR p+ OFF.
References g, gimple_build_call_internal(), gimple_location(), gimple_set_location(), gsi_safe_insert_before(), gsi_stmt(), POINTER_SIZE, sizetype, and TYPE_PRECISION.
Referenced by maybe_instrument_pointer_overflow().
|
static |
Perform the signed integer instrumentation. GSI is the iterator pointing at statement we are trying to instrument.
References a, b, build_zero_cst(), g, GET_MODE_BITSIZE(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_set_rhs1(), gimple_build_call_internal(), gimple_call_set_lhs(), gimple_location(), gimple_set_location(), gsi_insert_before(), gsi_replace(), GSI_SAME_STMT, gsi_stmt(), INTEGRAL_TYPE_P, make_ssa_name(), TREE_CODE, TREE_TYPE, TYPE_MODE, TYPE_OVERFLOW_WRAPS, TYPE_PRECISION, update_stmt(), and VECTOR_TYPE_P.
Return true if T is a call to a libubsan routine.
References BUILT_IN_NORMAL, DECL_NAME, fndecl_built_in_p(), IDENTIFIER_POINTER, and TREE_CODE.
gimple_opt_pass * make_pass_ubsan | ( | gcc::context * | ctxt | ) |
|
static |
Instrument pointer arithmetics if any.
References bits_to_bytes_round_down, build1(), build_int_cst(), build_pointer_type(), decl_binds_to_current_def_p(), DECL_P, DECL_REGISTER, DECL_SIZE, fold_build2, fold_convert, force_gimple_operand(), get_inner_reference(), gimple_seq_add_seq_without_update(), gsi_safe_insert_seq_before(), handled_component_p(), instrument_pointer_overflow(), integer_zerop(), is_global_var(), known_eq, known_ge, NULL_TREE, offset, POINTER_SIZE, POINTER_TYPE_P, poly_int_tree_p(), size_int, sizetype, TREE_ADDRESSABLE, TREE_CODE, TREE_OPERAND, TREE_TYPE, TYPE_PRECISION, and VAR_P.
Shared between *build_builtin_unreachable.
References build_fold_addr_expr_loc(), builtin_decl_explicit(), NULL_TREE, sanitize_flags_p(), SANITIZE_UNREACHABLE, and ubsan_create_data().
Referenced by build_builtin_unreachable(), and gimple_build_builtin_unreachable().
tree ubsan_build_overflow_builtin | ( | tree_code | code, |
location_t | loc, | ||
tree | lhstype, | ||
tree | op0, | ||
tree | op1, | ||
tree * | datap ) |
Build an ubsan builtin call for the signed-integer-overflow sanitization. CODE says what kind of builtin are we building, LOC is a location, LHSTYPE is the type of LHS, OP0 and OP1 are operands of the binary operation.
References build_call_expr_loc(), build_fold_addr_expr_loc(), builtin_decl_explicit(), gcc_unreachable, NULL_TREE, SANITIZE_SI_OVERFLOW, ubsan_create_data(), ubsan_encode_value(), UBSAN_ENCODE_VALUE_RTL, and ubsan_type_descriptor().
Referenced by expand_addsub_overflow(), expand_mul_overflow(), and expand_neg_overflow().
tree ubsan_create_data | ( | const char * | name, |
int | loccnt, | ||
const location_t * | ploc, | ||
... ) |
Create a structure for the ubsan library. NAME is a name of the new structure. LOCCNT is number of locations, PLOC points to array of locations. The arguments in ... are of __ubsan_type_descriptor type and there are at most two of them, followed by NULL_TREE, followed by optional extra arguments and another NULL_TREE.
References build_constructor(), build_decl(), build_pointer_type(), CONSTRUCTOR_APPEND_ELT, DECL_ARTIFICIAL, DECL_CHAIN, DECL_CONTEXT, DECL_EXTERNAL, DECL_IGNORED_P, DECL_INITIAL, fields, varpool_node::finalize_decl(), gcc_checking_assert, get_identifier(), i, initialize_sanitizer_builtins(), input_location, layout_type(), LOCATION_LOCUS, make_node(), NULL, NULL_TREE, TREE_CONSTANT, TREE_PUBLIC, TREE_STATIC, TREE_TYPE, TYPE_ARTIFICIAL, TYPE_FIELDS, TYPE_NAME, TYPE_STUB_DECL, ubsan_get_source_location_type(), ubsan_get_type_descriptor_type(), ubsan_ids, ubsan_source_location(), UNKNOWN_LOCATION, vec_alloc(), vec_safe_length(), and vec_safe_push().
Referenced by instrument_bool_enum_load(), instrument_builtin(), instrument_nonnull_arg(), instrument_nonnull_return(), sanitize_unreachable_fn(), ubsan_build_overflow_builtin(), ubsan_expand_bounds_ifn(), ubsan_expand_null_ifn(), ubsan_expand_objsize_ifn(), ubsan_expand_ptr_ifn(), ubsan_expand_vptr_ifn(), and ubsan_instrument_float_cast().
|
static |
Create a callgraph edge for statement STMT.
References basic_block_def::count, cgraph_node::create_edge(), current_function_decl, dyn_cast(), cgraph_node::get(), cgraph_node::get_create(), gimple_bb(), and gimple_call_fndecl().
Referenced by instrument_bool_enum_load(), instrument_builtin(), instrument_nonnull_arg(), instrument_nonnull_return(), and instrument_object_size().
tree ubsan_encode_value | ( | tree | t, |
enum ubsan_encode_value_phase | phase ) |
Helper routine, which encodes a value in the pointer_sized_int_node. Arguments with precision <= POINTER_SIZE are passed directly, the rest is passed by reference. T is a value we are to encode. PHASE determines when this function is called.
References assign_stack_temp_for_type(), build2(), build4(), build_fold_addr_expr, build_nonstandard_integer_type(), build_zero_cst(), create_tmp_var, create_tmp_var_raw(), current_function_decl, DECL_CONTEXT, DECL_P, expand_assignment(), fold_build1, fold_convert, gcc_unreachable, GET_MODE_BITSIZE(), GET_MODE_SIZE(), mark_addressable(), MAX_FIXED_MODE_SIZE, NULL_TREE, POINTER_SIZE, pointer_sized_int_node, SCALAR_TYPE_MODE, SET_DECL_RTL, TREE_ADDRESSABLE, TREE_CODE, TREE_TYPE, TYPE_PRECISION, TYPE_UNSIGNED, UBSAN_ENCODE_VALUE_GENERIC, UBSAN_ENCODE_VALUE_RTL, and void_type_node.
Referenced by instrument_bool_enum_load(), ubsan_build_overflow_builtin(), ubsan_expand_bounds_ifn(), and ubsan_instrument_float_cast().
bool ubsan_expand_bounds_ifn | ( | gimple_stmt_iterator * | gsi | ) |
Expand the UBSAN_BOUNDS special builtin function.
References build_fold_addr_expr_loc(), builtin_decl_explicit(), create_cond_insert_point(), fold_convert, force_gimple_operand_gsi(), g, gcc_assert, gimple_build_call(), gimple_build_cond(), gimple_call_arg(), gimple_call_num_args(), gimple_location(), gimple_set_location(), gsi_after_labels(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, gsi_remove(), GSI_SAME_STMT, gsi_start_bb(), gsi_stmt(), NULL_TREE, SANITIZE_BOUNDS, TREE_TYPE, ubsan_create_data(), ubsan_encode_value(), UBSAN_ENCODE_VALUE_GIMPLE, UBSAN_PRINT_ARRAY, ubsan_type_descriptor(), and unlink_stmt_vdef().
bool ubsan_expand_null_ifn | ( | gimple_stmt_iterator * | gsip | ) |
Expand UBSAN_NULL internal call. The type is kept on the ckind argument which is a constant, because the middle-end treats pointer conversions as useless and therefore the type of the first argument could be changed to any other pointer type.
References add_bb_to_loop(), ADDR_SPACE_GENERIC_P, build_fold_addr_expr_loc(), build_int_cst(), build_zero_cst(), builtin_decl_implicit(), CDI_DOMINATORS, compare_tree_int(), basic_block_def::count, create_empty_bb(), dom_info_available_p(), find_edge(), fold_convert, g, gcc_assert, get_pointer_alignment(), gimple_assign_lhs(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_call_arg(), gimple_call_num_args(), gimple_location(), gimple_set_location(), gsi_bb(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, gsi_remove(), gsi_replace(), GSI_SAME_STMT, gsi_start_bb(), gsi_stmt(), integer_zerop(), basic_block_def::loop_father, LOOPS_NEED_FIXUP, loops_state_set(), make_edge(), make_single_succ_edge(), make_ssa_name(), MAX, NULL_TREE, pointer_sized_int_node, POINTER_TYPE_P, SANITIZE_ALIGNMENT, sanitize_flags_p(), SANITIZE_NULL, set_immediate_dominator(), split_block(), targetm, tree_log2(), tree_to_uhwi(), TREE_TYPE, TYPE_ADDR_SPACE, ubsan_create_data(), UBSAN_PRINT_POINTER, ubsan_type_descriptor(), unlink_stmt_vdef(), unsigned_char_type_node, profile_probability::very_likely(), and profile_probability::very_unlikely().
bool ubsan_expand_objsize_ifn | ( | gimple_stmt_iterator * | gsi | ) |
Expand UBSAN_OBJECT_SIZE internal call.
References build_fold_addr_expr_loc(), build_zero_cst(), builtin_decl_explicit(), create_cond_insert_point(), g, gcc_assert, gimple_assign_lhs(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_call_arg(), gimple_call_num_args(), gimple_location(), gimple_set_location(), gsi_after_labels(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, gsi_remove(), GSI_SAME_STMT, gsi_start_bb(), gsi_stmt(), integer_all_onesp(), make_ssa_name(), NULL_TREE, OBJSZ_MAX_OFFSET, offset, pointer_sized_int_node, SANITIZE_OBJECT_SIZE, wi::to_widest(), TREE_CODE, TREE_TYPE, ubsan_create_data(), UBSAN_PRINT_POINTER, ubsan_type_descriptor(), unlink_stmt_vdef(), and unsigned_char_type_node.
bool ubsan_expand_ptr_ifn | ( | gimple_stmt_iterator * | gsip | ) |
Expand UBSAN_PTR internal call.
References add_bb_to_loop(), build_fold_addr_expr_loc(), builtin_decl_implicit(), CDI_DOMINATORS, basic_block_def::count, create_empty_bb(), dom_info_available_p(), profile_probability::even(), fold_build1, g, gcc_assert, get_range_pos_neg(), gimple_build(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_call_arg(), gimple_call_num_args(), gimple_location(), gimple_set_location(), gsi_bb(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, gsi_remove(), gsi_replace(), GSI_SAME_STMT, gsi_start_bb(), gsi_stmt(), integer_zerop(), basic_block_def::loop_father, LOOPS_NEED_FIXUP, loops_state_set(), make_edge(), make_single_succ_edge(), make_ssa_name(), wi::neg_p(), NULL, NULL_TREE, pointer_sized_int_node, SANITIZE_POINTER_OVERFLOW, set_immediate_dominator(), sizetype, split_block(), ssize_int, ssizetype, wi::to_wide(), TREE_CODE, ubsan_create_data(), unlink_stmt_vdef(), profile_probability::very_likely(), and profile_probability::very_unlikely().
bool ubsan_expand_vptr_ifn | ( | gimple_stmt_iterator * | gsip | ) |
Expand UBSAN_VPTR internal call. The type is kept on the ckind argument which is a constant, because the middle-end treats pointer conversions as useless and therefore the type of the first argument could be changed to any other pointer type.
References build4_loc(), build_array_type_nelts(), build_decl(), build_fold_addr_expr_loc(), build_int_cst(), build_zero_cst(), builtin_decl_explicit(), create_cond_insert_point(), DECL_ARTIFICIAL, DECL_EXTERNAL, DECL_IGNORED_P, DECL_VISIBILITY, DECL_VISIBILITY_SPECIFIED, varpool_node::finalize_decl(), g, gcc_assert, get_identifier(), gimple_assign_lhs(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_call_arg(), gimple_call_num_args(), gimple_location(), gimple_set_location(), gsi_after_labels(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, gsi_remove(), GSI_SAME_STMT, gsi_start_bb(), gsi_stmt(), integer_type_node, make_ssa_name(), NULL, NULL_TREE, pointer_sized_int_node, SANITIZE_VPTR, TREE_PUBLIC, TREE_STATIC, tree_to_uhwi(), TREE_TYPE, ubsan_create_data(), UBSAN_DOWNCAST_POINTER, ubsan_type_descriptor(), ubsan_vptr_type_cache_decl, wi::uhwi(), UNKNOWN_LOCATION, unlink_stmt_vdef(), unsigned_char_type_node, useless_type_conversion_p(), VISIBILITY_DEFAULT, and wide_int_to_tree().
tree ubsan_get_source_location_type | ( | void | ) |
Build struct __ubsan_source_location { const char *__filename; unsigned int __line; unsigned int __column; } type.
References build_decl(), build_pointer_type(), build_qualified_type(), char_type_node, DECL_ARTIFICIAL, DECL_CHAIN, DECL_CONTEXT, DECL_IGNORED_P, fields, get_identifier(), i, input_location, layout_type(), make_node(), TYPE_ARTIFICIAL, TYPE_FIELDS, TYPE_NAME, TYPE_QUAL_CONST, TYPE_STUB_DECL, ubsan_source_location_type, UNKNOWN_LOCATION, and unsigned_type_node.
Referenced by asan_add_global(), asan_protect_global(), ubsan_create_data(), and ubsan_source_location().
|
static |
Build struct __ubsan_type_descriptor { unsigned short __typekind; unsigned short __typeinfo; char __typename[]; } type.
References build_array_type(), build_decl(), build_range_type(), char_type_node, DECL_ARTIFICIAL, DECL_CHAIN, DECL_CONTEXT, DECL_IGNORED_P, fields, get_identifier(), i, input_location, layout_type(), make_node(), NULL_TREE, short_unsigned_type_node, size_zero_node, sizetype, TYPE_ARTIFICIAL, TYPE_FIELDS, TYPE_NAME, TYPE_STUB_DECL, ubsan_type_descriptor_type, and UNKNOWN_LOCATION.
Referenced by ubsan_create_data(), and ubsan_type_descriptor().
Instrument float point-to-integer conversion. TYPE is an integer type of destination, EXPR is floating-point expression.
References b, boolean_type_node, build_call_expr_loc(), build_fold_addr_expr_loc(), build_minus_one_cst(), build_real(), builtin_decl_explicit(), dconst1, dconstm1, decimal_real_from_string(), fold_build2, fold_build3, gcc_assert, HONOR_NANS(), input_location, integer_zero_node, integer_zerop(), NULL, NULL_TREE, real_arithmetic(), real_compare(), real_convert(), REAL_EXP, real_isinf(), REAL_MODE_FORMAT, REAL_VALUE_TYPE, SANITIZE_FLOAT_CAST, SET_REAL_EXP, TREE_TYPE, TYPE_MODE, TYPE_PRECISION, TYPE_UNSIGNED, ubsan_create_data(), ubsan_encode_value(), ubsan_type_descriptor(), ubsan_use_new_style_p(), UNKNOWN_LOCATION, and void_type_node.
Referenced by convert_to_integer_1().
bool ubsan_instrument_unreachable | ( | gimple_stmt_iterator * | gsi | ) |
Rewrite a gcall to __builtin_unreachable for -fsanitize=unreachable. Called by the sanopt pass.
References g, gimple_build_builtin_unreachable(), gimple_location(), gsi_replace(), and gsi_stmt().
|
static |
Helper routine that returns a CONSTRUCTOR of __ubsan_source_location type with its fields filled from a location_t LOC.
References build_array_type_nelts(), build_constructor_va(), build_fold_addr_expr, build_int_cst(), build_string(), char_type_node, expand_location(), NULL, NULL_TREE, ptr_type_node, TREE_CONSTANT, TREE_READONLY, TREE_STATIC, TREE_TYPE, ubsan_get_source_location_type(), and unsigned_type_node.
Referenced by ubsan_create_data().
tree ubsan_type_descriptor | ( | tree | type, |
enum ubsan_print_style | pstyle ) |
Helper routine that returns ADDR_EXPR of a VAR_DECL of a type descriptor. It first looks into the hash table; if not found, create the VAR_DECL, put it into the hash table and return the ADDR_EXPR of it. TYPE describes a particular type. PSTYLE is an enum controlling how we want to print the type.
References wi::add(), build_array_type_nelts(), build_constructor_va(), build_decl(), build_fold_addr_expr, build_int_cst(), build_nonstandard_integer_type(), build_qualified_type(), build_string(), char_type_node, DECL_ARTIFICIAL, DECL_EXTERNAL, decl_for_type_insert(), decl_for_type_lookup(), DECL_IGNORED_P, DECL_INITIAL, DECL_NAME, DECL_SIZE, DECL_SIZE_UNIT, double_type_node, varpool_node::finalize_decl(), float_type_node, gcc_assert, varpool_node::get(), get_identifier(), get_ubsan_type_info_for_type(), IDENTIFIER_POINTER, long_double_type_node, MAX_FIXED_MODE_SIZE, NULL, NULL_TREE, POINTER_TYPE_P, pp_formatted_text(), pp_left_bracket, pp_printf(), pp_quote, pp_right_bracket, pp_space, pp_star, pp_string(), pp_unsigned_wide_integer, pp_wide_int(), short_unsigned_type_node, size_binop, strip_array_types(), wi::to_widest(), TREE_CODE, TREE_CONSTANT, tree_fits_uhwi_p(), TREE_PUBLIC, TREE_READONLY, TREE_STATIC, tree_to_uhwi(), TREE_TYPE, type(), TYPE_ATOMIC, TYPE_DOMAIN, TYPE_MAIN_VARIANT, TYPE_MAX_VALUE, TYPE_METHOD_BASETYPE, TYPE_MODE, TYPE_NAME, TYPE_PRECISION, TYPE_QUAL_CONST, TYPE_READONLY, TYPE_RESTRICT, TYPE_SIGN, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_UNSIGNED, TYPE_VOLATILE, ubsan_get_type_descriptor_type(), ubsan_ids, UBSAN_PRINT_ARRAY, UBSAN_PRINT_FORCE_INT, UBSAN_PRINT_NORMAL, UBSAN_PRINT_POINTER, and UNKNOWN_LOCATION.
Referenced by instrument_bool_enum_load(), ubsan_build_overflow_builtin(), ubsan_expand_bounds_ifn(), ubsan_expand_null_ifn(), ubsan_expand_objsize_ifn(), ubsan_expand_vptr_ifn(), and ubsan_instrument_float_cast().
|
static |
Determine if we can propagate given LOCATION to ubsan_data descriptor to use new style handlers. Libubsan uses heuristics to destinguish between old and new styles and relies on these properties for filename: a) Location's filename must not be NULL. b) Location's filename must not be equal to "". c) Location's filename must not be equal to "\1". d) First two bytes of filename must not contain '\xff' symbol.
References expand_location(), NULL, startswith(), and UNKNOWN_LOCATION.
Referenced by ubsan_instrument_float_cast().
|
static |
Referenced by decl_for_type_insert(), and decl_for_type_lookup().
|
static |
Counters for internal labels. ubsan_ids[0] for Lubsan_type, ubsan_ids[1] for Lubsan_data labels.
Referenced by ubsan_create_data(), and ubsan_type_descriptor().
|
static |
Cached ubsan_get_source_location_type () return value.
Referenced by ubsan_get_source_location_type().
|
static |
Cached ubsan_get_type_descriptor_type () return value.
Referenced by ubsan_get_type_descriptor_type().
|
static |
Cached __ubsan_vptr_type_cache decl.
Referenced by ubsan_expand_vptr_ifn().