From dfe06d3e7f7719d2fc8ef7b7c7ca88e7277e7593 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 12 Nov 2012 16:51:34 +0100 Subject: Initial asan cleanups This patch defines a new asan_shadow_offset target macro, instead of having a mere macro in the asan.c file. It becomes thus cleaner to define the target macro for targets that supports asan, namely x86 for now. The ASAN_SHADOW_SHIFT (which, along with the asan_shadow_offset constant, is used to compute the address of the shadow memory byte for a given memory address) is defined in asan.h. gcc/ChangeLog * toplev.c (process_options): Warn and turn off -faddress-sanitizer if not supported by target. * asan.c: Include target.h. (asan_scale, asan_offset_log_32, asan_offset_log_64, asan_offset_log): Removed. (build_check_stmt): Use ASAN_SHADOW_SHIFT and targetm.asan_shadow_offset (). (asan_instrument): Don't initialize asan_offset_log. * asan.h (ASAN_SHADOW_SHIFT): Define. * target.def (TARGET_ASAN_SHADOW_OFFSET): New hook. * doc/tm.texi.in (TARGET_ASAN_SHADOW_OFFSET): Add it. * doc/tm.texi: Regenerated. * Makefile.in (asan.o): Depend on $(TARGET_H). * config/i386/i386.c (ix86_asan_shadow_offset): New function. (TARGET_ASAN_SHADOW_OFFSET): Define. From-SVN: r193433 --- gcc/toplev.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/toplev.c') diff --git a/gcc/toplev.c b/gcc/toplev.c index 3ca0736..d9dfb2a 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1541,6 +1541,13 @@ process_options (void) flag_omit_frame_pointer = 0; } + /* Address Sanitizer needs porting to each target architecture. */ + if (flag_asan && targetm.asan_shadow_offset == NULL) + { + warning (0, "-faddress-sanitizer not supported for this target"); + flag_asan = 0; + } + /* Enable -Werror=coverage-mismatch when -Werror and -Wno-error have not been set. */ if (!global_options_set.x_warnings_are_errors -- cgit v1.1