Commit 513d5564 by Martin Liska Committed by Martin Liska

Add sanopt support for UBSAN_PTR.

2017-10-06  Martin Liska  <mliska@suse.cz>

	* sanopt.c (struct sanopt_tree_triplet_hash): Remove inline
	keyword for member functions.
	(struct sanopt_tree_couple): New struct.
	(struct sanopt_tree_couple_hash): New function.
	(struct sanopt_ctx): Add new hash_map.
	(has_dominating_ubsan_ptr_check): New function.
	(record_ubsan_ptr_check_stmt): Likewise.
	(maybe_optimize_ubsan_ptr_ifn): Likewise.
	(sanopt_optimize_walker): Handle IFN_UBSAN_PTR.
	(pass_sanopt::execute): Handle also SANITIZE_POINTER_OVERFLOW.
2017-10-06  Martin Liska  <mliska@suse.cz>

	* c-c++-common/ubsan/ptr-overflow-sanitization-1.c: New test.

From-SVN: r253492
parent 549d24e9
2017-10-06 Martin Liska <mliska@suse.cz>
* sanopt.c (struct sanopt_tree_triplet_hash): Remove inline
keyword for member functions.
(struct sanopt_tree_couple): New struct.
(struct sanopt_tree_couple_hash): New function.
(struct sanopt_ctx): Add new hash_map.
(has_dominating_ubsan_ptr_check): New function.
(record_ubsan_ptr_check_stmt): Likewise.
(maybe_optimize_ubsan_ptr_ifn): Likewise.
(sanopt_optimize_walker): Handle IFN_UBSAN_PTR.
(pass_sanopt::execute): Handle also SANITIZE_POINTER_OVERFLOW.
2017-10-06 Sudakshina Das <sudi.das@arm.com>
PR target/82440
2017-10-06 Martin Liska <mliska@suse.cz>
* c-c++-common/ubsan/ptr-overflow-sanitization-1.c: New test.
2017-10-06 Sudakshina Das <sudi.das@arm.com>
* gcc.target/aarch64/bic_imm_1.c: New test.
......
/* { dg-require-effective-target lp64 } */
/* { dg-options "-O -fsanitize=pointer-overflow" } */
/* { dg-skip-if "" { *-*-* } "-flto" } */
#define SMAX __PTRDIFF_MAX__
void foo(void)
{
char *p;
char *p2;
char b[1];
char c[1];
p = b + SMAX; /* pointer overflow check is needed */
p = b;
p++;
p2 = p + 1000;
p2 = p + 999;
p = b + SMAX;
p2 = p + 1; /* pointer overflow check is needed */
p = b;
p--; /* pointer overflow check is needed */
p2 = p + 1;
p2 = p + 2;
p = b - SMAX; /* pointer overflow check is needed */
p2 = p + (SMAX - 2); /* b - 2: pointer overflow check is needed */
p2 = p + (SMAX - 1); /* b - 1: pointer overflow check is needed */
p2 = p + SMAX; /* b: pointer overflow check is needed */
p2++; /* b + 1 */
p = c;
p++; /* c + 1 */
p = c - SMAX; /* pointer overflow check is needed */
p2 = p + SMAX; /* c: pointer overflow check is needed */
p2++; /* c + 1 */
}
void bar(char *ptr)
{
char *p = ptr - 1000; /* pointer overflow check is needed */
p = ptr + 1000; /* pointer overflow check is needed */
p -= 2000; /* pointer overflow check is needed */
}
void baz(char *ptr)
{
char **p = &ptr;
char **p2 = p + 20; /* pointer overflow check is needed */
p2--;
}
void positive_and_positive (char *ptr)
{
char **p = &ptr;
char **p2 = p + 100; /* pointer overflow check is needed */
p2 = p + 10;
p += 50;
}
void negative_to_positive (char *ptr)
{
char **p = &ptr;
char **p2 = p + 20; /* pointer overflow check is needed */
p2 = p - 10; /* pointer overflow check is needed */
p2 += 15;
}
void negative_to_negative (char *ptr)
{
char **p = &ptr;
char **p2 = p - 20; /* pointer overflow check is needed */
p2 = p - 20;
p2 += 5;
}
/* { dg-final { scan-assembler-times "call\\s+__ubsan_handle_pointer_overflow" 17 } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment