mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 13:00:28 +00:00
Add attribute @(no_sanitize_address)
The purposes of this attribute is to let procedures opt-out of being instrumented with asan. Typically an allocator that includes 'in-band' meta-data will be accessing poisoned values (such as tlsf). Making asan work with these allocators becomes very challenging so just being to ignore asan within specific allocator procedures makes it easier to reason and removes the need to temporarily poison and unpoison allocator data.
This commit is contained in:
@@ -1229,6 +1229,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
||||
|
||||
e->Procedure.has_instrumentation = has_instrumentation;
|
||||
|
||||
e->Procedure.no_sanitize_address = ac.no_sanitize_address;
|
||||
|
||||
e->deprecated_message = ac.deprecated_message;
|
||||
e->warning_message = ac.warning_message;
|
||||
|
||||
@@ -3711,6 +3711,12 @@ gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
|
||||
}
|
||||
ac->instrumentation_exit = true;
|
||||
return true;
|
||||
} else if (name == "no_sanitize_address") {
|
||||
if (value != nullptr) {
|
||||
error(value, "'%.*s' expects no parameter", LIT(name));
|
||||
}
|
||||
ac->no_sanitize_address = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -139,6 +139,7 @@ struct AttributeContext {
|
||||
bool entry_point_only : 1;
|
||||
bool instrumentation_enter : 1;
|
||||
bool instrumentation_exit : 1;
|
||||
bool no_sanitize_address : 1;
|
||||
bool rodata : 1;
|
||||
bool ignore_duplicates : 1;
|
||||
u32 optimization_mode; // ProcedureOptimizationMode
|
||||
@@ -629,4 +630,4 @@ gb_internal void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap
|
||||
gb_internal GenTypesData *ensure_polymorphic_record_entity_has_gen_types(CheckerContext *ctx, Type *original_type);
|
||||
|
||||
|
||||
gb_internal void init_map_internal_types(Type *type);
|
||||
gb_internal void init_map_internal_types(Type *type);
|
||||
|
||||
@@ -258,6 +258,7 @@ struct Entity {
|
||||
bool is_memcpy_like : 1;
|
||||
bool uses_branch_location : 1;
|
||||
bool is_anonymous : 1;
|
||||
bool no_sanitize_address : 1;
|
||||
} Procedure;
|
||||
struct {
|
||||
Array<Entity *> entities;
|
||||
|
||||
@@ -333,7 +333,7 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
|
||||
}
|
||||
|
||||
if (p->body && entity->pkg && ((entity->pkg->kind == Package_Normal) || (entity->pkg->kind == Package_Init))) {
|
||||
if (build_context.sanitizer_flags & SanitizerFlag_Address) {
|
||||
if (build_context.sanitizer_flags & SanitizerFlag_Address && !entity->Procedure.no_sanitize_address) {
|
||||
lb_add_attribute_to_proc(m, p->value, "sanitize_address");
|
||||
}
|
||||
if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
|
||||
|
||||
Reference in New Issue
Block a user