* opts.c (common_handle_option): Handle -fsanitize=alignment. * ubsan.h (enum ubsan_null_ckind): Add UBSAN_CTOR_CALL. (ubsan_expand_bounds_ifn, ubsan_expand_null_ifn): Change return type to bool. * stor-layout.h (min_align_of_type): New prototype. * asan.c (pass_sanopt::execute): Don't perform gsi_next if ubsan_expand* told us not to do it. Remove the extra gsi_end_p check. * ubsan.c: Include builtins.h. (ubsan_expand_bounds_ifn): Change return type to bool, always return true. (ubsan_expand_null_ifn): Change return type to bool, change argument to gimple_stmt_iterator *. Handle both null and alignment sanitization, take type from ckind argument's type rather than first argument. (instrument_member_call): Removed. (instrument_mem_ref): Remove t argument, add mem and base arguments. Handle both null and alignment sanitization, don't say whole struct access is member access. Build 3 argument IFN_UBSAN_NULL call instead of 2 argument. (instrument_null): Adjust instrument_mem_ref caller. Don't instrument calls here. (pass_ubsan::gate, pass_ubsan::execute): Handle SANITIZE_ALIGNMENT like SANITIZE_NULL. * stor-layout.c (min_align_of_type): New function. * flag-types.h (enum sanitize_code): Add SANITIZE_ALIGNMENT. Or it into SANITIZE_UNDEFINED. * doc/invoke.texi (-fsanitize=alignment): Document. cp/ * cp-gimplify.c (cp_genericize_r): For -fsanitize=null and/or -fsanitize=alignment call ubsan_maybe_instrument_reference for casts to REFERENCE_TYPE and ubsan_maybe_instrument_member_call for calls to member functions. c-family/ * c-common.h (min_align_of_type): Removed prototype. * c-common.c (min_align_of_type): Removed. * c-ubsan.h (ubsan_maybe_instrument_reference, ubsan_maybe_instrument_member_call): New prototypes. * c-ubsan.c: Include stor-layout.h and builtins.h. (ubsan_maybe_instrument_reference_or_call, ubsan_maybe_instrument_reference, ubsan_maybe_instrument_call): New functions. testsuite/ * c-c++-common/ubsan/align-1.c: New test. * c-c++-common/ubsan/align-2.c: New test. * c-c++-common/ubsan/align-3.c: New test. * c-c++-common/ubsan/align-4.c: New test. * c-c++-common/ubsan/align-5.c: New test. * c-c++-common/ubsan/attrib-4.c: New test. * g++.dg/ubsan/align-1.C: New test. * g++.dg/ubsan/align-2.C: New test. * g++.dg/ubsan/align-3.C: New test. * g++.dg/ubsan/attrib-1.C: New test. * g++.dg/ubsan/null-1.C: New test. * g++.dg/ubsan/null-2.C: New test. From-SVN: r213406
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
align-1.c | Loading commit data... | |
align-2.c | Loading commit data... | |
align-3.c | Loading commit data... | |
align-4.c | Loading commit data... | |
align-5.c | Loading commit data... | |
attrib-1.c | Loading commit data... | |
attrib-2.c | Loading commit data... | |
attrib-4.c | Loading commit data... | |
bounds-1.c | Loading commit data... | |
bounds-2.c | Loading commit data... | |
bounds-3.c | Loading commit data... | |
bounds-4.c | Loading commit data... | |
bounds-5.c | Loading commit data... | |
bounds-6.c | Loading commit data... | |
bounds-7.c | Loading commit data... | |
const-char-1.c | Loading commit data... | |
const-expr-1.c | Loading commit data... | |
div-by-zero-1.c | Loading commit data... | |
div-by-zero-2.c | Loading commit data... | |
div-by-zero-3.c | Loading commit data... | |
div-by-zero-4.c | Loading commit data... | |
div-by-zero-5.c | Loading commit data... | |
div-by-zero-6.c | Loading commit data... | |
div-by-zero-7.c | Loading commit data... | |
float-cast-overflow-1.c | Loading commit data... | |
float-cast-overflow-10.c | Loading commit data... | |
float-cast-overflow-2.c | Loading commit data... | |
float-cast-overflow-3.c | Loading commit data... | |
float-cast-overflow-4.c | Loading commit data... | |
float-cast-overflow-5.c | Loading commit data... | |
float-cast-overflow-6.c | Loading commit data... | |
float-cast-overflow-7.c | Loading commit data... | |
float-cast-overflow-7.h | Loading commit data... | |
float-cast-overflow-8.c | Loading commit data... | |
float-cast-overflow-9.c | Loading commit data... | |
float-cast.h | Loading commit data... | |
float-div-by-zero-1.c | Loading commit data... | |
load-bool-enum.c | Loading commit data... | |
null-1.c | Loading commit data... | |
null-10.c | Loading commit data... | |
null-11.c | Loading commit data... | |
null-2.c | Loading commit data... | |
null-3.c | Loading commit data... | |
null-4.c | Loading commit data... | |
null-5.c | Loading commit data... | |
null-6.c | Loading commit data... | |
null-7.c | Loading commit data... | |
null-8.c | Loading commit data... | |
null-9.c | Loading commit data... | |
overflow-1.c | Loading commit data... | |
overflow-2.c | Loading commit data... | |
overflow-add-1.c | Loading commit data... | |
overflow-add-2.c | Loading commit data... | |
overflow-add-3.c | Loading commit data... | |
overflow-add-4.c | Loading commit data... | |
overflow-int128.c | Loading commit data... | |
overflow-mul-1.c | Loading commit data... | |
overflow-mul-2.c | Loading commit data... | |
overflow-mul-3.c | Loading commit data... | |
overflow-mul-4.c | Loading commit data... | |
overflow-negate-1.c | Loading commit data... | |
overflow-negate-2.c | Loading commit data... | |
overflow-sub-1.c | Loading commit data... | |
overflow-sub-2.c | Loading commit data... | |
pr58443-1.c | Loading commit data... | |
pr58443-2.c | Loading commit data... | |
pr58443-3.c | Loading commit data... | |
pr59333.c | Loading commit data... | |
pr59397.c | Loading commit data... | |
pr59503.c | Loading commit data... | |
pr59667.c | Loading commit data... | |
pr60613-1.c | Loading commit data... | |
pr60613-2.c | Loading commit data... | |
pr60636.c | Loading commit data... | |
save-expr-1.c | Loading commit data... | |
save-expr-2.c | Loading commit data... | |
save-expr-3.c | Loading commit data... | |
save-expr-4.c | Loading commit data... | |
shift-1.c | Loading commit data... | |
shift-2.c | Loading commit data... | |
shift-3.c | Loading commit data... | |
shift-4.c | Loading commit data... | |
shift-5.c | Loading commit data... | |
shift-6.c | Loading commit data... | |
typedef-1.c | Loading commit data... | |
undefined-1.c | Loading commit data... | |
unreachable-1.c | Loading commit data... | |
vla-1.c | Loading commit data... | |
vla-2.c | Loading commit data... | |
vla-3.c | Loading commit data... | |
vla-4.c | Loading commit data... |