re PR sanitizer/58411 (no_sanitize_undefined function attribute)
2013-09-18 Marek Polacek <polacek@redhat.com> PR sanitizer/58411 * doc/extend.texi: Document no_sanitize_undefined attribute. * builtins.c (fold_builtin_0): Don't sanitize function if it has the no_sanitize_undefined attribute. From-SVN: r202682
This commit is contained in:
parent
d30d00a2f1
commit
ce6923c53d
|
@ -1,3 +1,10 @@
|
|||
2013-09-18 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR sanitizer/58411
|
||||
* doc/extend.texi: Document no_sanitize_undefined attribute.
|
||||
* builtins.c (fold_builtin_0): Don't sanitize function if it has the
|
||||
no_sanitize_undefined attribute.
|
||||
|
||||
2013-09-18 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* config/msp430/msp430.h (ASM_SPEC): Pass -md on to the assembler.
|
||||
|
|
|
@ -10313,7 +10313,10 @@ fold_builtin_0 (location_t loc, tree fndecl, bool ignore ATTRIBUTE_UNUSED)
|
|||
return fold_builtin_classify_type (NULL_TREE);
|
||||
|
||||
case BUILT_IN_UNREACHABLE:
|
||||
if (flag_sanitize & SANITIZE_UNREACHABLE)
|
||||
if (flag_sanitize & SANITIZE_UNREACHABLE
|
||||
&& (current_function_decl == NULL
|
||||
|| !lookup_attribute ("no_sanitize_undefined",
|
||||
DECL_ATTRIBUTES (current_function_decl))))
|
||||
return ubsan_instrument_unreachable (loc);
|
||||
break;
|
||||
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2013-09-18 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR sanitizer/58411
|
||||
* c-common.c (handle_no_sanitize_undefined_attribute): New function.
|
||||
Declare it.
|
||||
(struct attribute_spec c_common_att): Add no_sanitize_undefined.
|
||||
|
||||
2013-09-14 Iain Sandoe <iain@codesourcery.com>
|
||||
|
||||
PR target/48094
|
||||
|
|
|
@ -311,6 +311,8 @@ static tree handle_no_sanitize_address_attribute (tree *, tree, tree,
|
|||
int, bool *);
|
||||
static tree handle_no_address_safety_analysis_attribute (tree *, tree, tree,
|
||||
int, bool *);
|
||||
static tree handle_no_sanitize_undefined_attribute (tree *, tree, tree, int,
|
||||
bool *);
|
||||
static tree handle_noinline_attribute (tree *, tree, tree, int, bool *);
|
||||
static tree handle_noclone_attribute (tree *, tree, tree, int, bool *);
|
||||
static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
|
||||
|
@ -722,6 +724,9 @@ const struct attribute_spec c_common_attribute_table[] =
|
|||
{ "no_sanitize_address", 0, 0, true, false, false,
|
||||
handle_no_sanitize_address_attribute,
|
||||
false },
|
||||
{ "no_sanitize_undefined", 0, 0, true, false, false,
|
||||
handle_no_sanitize_undefined_attribute,
|
||||
false },
|
||||
{ "warning", 1, 1, true, false, false,
|
||||
handle_error_attribute, false },
|
||||
{ "error", 1, 1, true, false, false,
|
||||
|
@ -6575,6 +6580,22 @@ handle_no_address_safety_analysis_attribute (tree *node, tree name, tree, int,
|
|||
return NULL_TREE;
|
||||
}
|
||||
|
||||
/* Handle a "no_sanitize_undefined" attribute; arguments as in
|
||||
struct attribute_spec.handler. */
|
||||
|
||||
static tree
|
||||
handle_no_sanitize_undefined_attribute (tree *node, tree name, tree, int,
|
||||
bool *no_add_attrs)
|
||||
{
|
||||
if (TREE_CODE (*node) != FUNCTION_DECL)
|
||||
{
|
||||
warning (OPT_Wattributes, "%qE attribute ignored", name);
|
||||
*no_add_attrs = true;
|
||||
}
|
||||
|
||||
return NULL_TREE;
|
||||
}
|
||||
|
||||
/* Handle a "noinline" attribute; arguments as in
|
||||
struct attribute_spec.handler. */
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2013-09-18 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR sanitizer/58411
|
||||
* c-typeck.c (build_binary_op): Don't sanitize function if it has the
|
||||
no_sanitize_undefined attribute.
|
||||
|
||||
2013-09-13 Kai Tietz <ktietz@redhat.com>
|
||||
|
||||
PR target/57848
|
||||
|
|
|
@ -10498,6 +10498,8 @@ build_binary_op (location_t location, enum tree_code code,
|
|||
|
||||
if (flag_sanitize & SANITIZE_UNDEFINED
|
||||
&& current_function_decl != 0
|
||||
&& !lookup_attribute ("no_sanitize_undefined",
|
||||
DECL_ATTRIBUTES (current_function_decl))
|
||||
&& (doing_div_or_mod || doing_shift))
|
||||
{
|
||||
/* OP0 and/or OP1 might have side-effects. */
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2013-09-18 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR sanitizer/58411
|
||||
* typeck.c (cp_build_binary_op): Don't sanitize function if it has the
|
||||
no_sanitize_undefined attribute.
|
||||
|
||||
2013-09-17 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/58435
|
||||
|
|
|
@ -4887,6 +4887,8 @@ cp_build_binary_op (location_t location,
|
|||
if ((flag_sanitize & SANITIZE_UNDEFINED)
|
||||
&& !processing_template_decl
|
||||
&& current_function_decl != 0
|
||||
&& !lookup_attribute ("no_sanitize_undefined",
|
||||
DECL_ATTRIBUTES (current_function_decl))
|
||||
&& (doing_div_or_mod || doing_shift))
|
||||
{
|
||||
/* OP0 and/or OP1 might have side-effects. */
|
||||
|
|
|
@ -2136,6 +2136,7 @@ attributes are currently defined for functions on all targets:
|
|||
@code{warn_unused_result}, @code{nonnull}, @code{gnu_inline},
|
||||
@code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
|
||||
@code{no_sanitize_address}, @code{no_address_safety_analysis},
|
||||
@code{no_sanitize_undefined},
|
||||
@code{error} and @code{warning}.
|
||||
Several other attributes are defined for functions on particular
|
||||
target systems. Other attributes, including @code{section} are
|
||||
|
@ -3500,6 +3501,12 @@ The @code{no_address_safety_analysis} is a deprecated alias of the
|
|||
@code{no_sanitize_address} attribute, new code should use
|
||||
@code{no_sanitize_address}.
|
||||
|
||||
@item no_sanitize_undefined
|
||||
@cindex @code{no_sanitize_undefined} function attribute
|
||||
The @code{no_sanitize_undefined} attribute on functions is used
|
||||
to inform the compiler that it should not check for undefined behavior
|
||||
in the function when compiling with the @option{-fsanitize=undefined} option.
|
||||
|
||||
@item regparm (@var{number})
|
||||
@cindex @code{regparm} attribute
|
||||
@cindex functions that are passed arguments in registers on the 386
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2013-09-18 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR sanitizer/58411
|
||||
* c-c++-common/ubsan/attrib-1.c: New test.
|
||||
|
||||
2013-09-17 Cong Hou <congh@google.com>
|
||||
|
||||
* gcc.dg/vect/vect-reduc-dot-s16c.c: Add a test case with dot product
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/* PR sanitizer/58411 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-fsanitize=undefined -w" } */
|
||||
|
||||
__attribute__((no_sanitize_undefined)) int
|
||||
f1 (int i)
|
||||
{
|
||||
return 16 << i;
|
||||
}
|
||||
|
||||
int f2 (int i);
|
||||
int f2 (int i) __attribute__((no_sanitize_undefined));
|
||||
int f2 (int i) __attribute__((no_sanitize_undefined));
|
||||
int f2 (int i);
|
||||
|
||||
int
|
||||
f2 (int i)
|
||||
{
|
||||
return 1 / i;
|
||||
}
|
||||
|
||||
void f3 (void);
|
||||
__typeof (f3) f3 __attribute__((__no_sanitize_undefined__));
|
||||
|
||||
void
|
||||
f3 (void)
|
||||
{
|
||||
__builtin_unreachable ();
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-not "__ubsan_handle_shift_out_of_bounds" } } */
|
||||
/* { dg-final { scan-assembler-not "__ubsan_handle_divrem_overflow" } } */
|
||||
/* { dg-final { scan-assembler-not "__ubsan_handle_builtin_unreachable" } } */
|
Loading…
Reference in New Issue