Bug 55435 - [asan] implement an attribute to disable asan instrumentation for a particular function
Summary: [asan] implement an attribute to disable asan instrumentation for a particula...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 4.8.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-22 03:28 UTC by Konstantin Serebryany
Modified: 2012-11-23 16:50 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Serebryany 2012-11-22 03:28:26 UTC
The clang implementation of asan has __attribute__((no_address_safety_analysis)): 

(http://clang.llvm.org/docs/AddressSanitizer.html#no_address_safety_analysis)
====
Some code should not be instrumented by AddressSanitizer. One may use the function attribute no_address_safety_analysis to disable instrumentation of a particular function. This attribute may not be supported by other compilers, so we suggest to use it together with __has_feature(address_sanitizer). Note: currently, this attribute will be lost if the function is inlined.
====

The gcc implementation needs a similar attribute (preferably, with the same syntax and semantics)

One example where this attribute is used: V8 stack profiler which touches random bytes on the stack.
Comment 1 Jakub Jelinek 2012-11-23 09:02:34 UTC
Author: jakub
Date: Fri Nov 23 09:02:28 2012
New Revision: 193748

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193748
Log:
	PR sanitizer/55435
	* c-common.c (handle_no_address_safety_analysis_attribute): New
	function.
	(c_common_attribute_table): Add no_address_safety_analysis.

	* asan.c (gate_asan): Don't instrument functions with
	no_address_safety_analysis attribute.
	(gate_asan_O0): Use !optimize && gate_asan ().
	* doc/extend.texi (no_address_safety_analysis): Document new
	function attribute.

	* c-c++-common/asan/attrib-1.c: New test.

Added:
    trunk/gcc/testsuite/c-c++-common/asan/attrib-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/asan.c
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/doc/extend.texi
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jakub Jelinek 2012-11-23 16:50:55 UTC
Fixed.