Merge pull request #5102 from Lperlind/attribute-no-sanitize-address

Add attribute @(no_sanitize_address)
This commit is contained in:
gingerBill
2025-05-01 12:16:10 +01:00
committed by GitHub
5 changed files with 11 additions and 2 deletions
+1
View File
@@ -1229,6 +1229,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
e->Procedure.has_instrumentation = has_instrumentation; e->Procedure.has_instrumentation = has_instrumentation;
e->Procedure.no_sanitize_address = ac.no_sanitize_address;
e->deprecated_message = ac.deprecated_message; e->deprecated_message = ac.deprecated_message;
e->warning_message = ac.warning_message; e->warning_message = ac.warning_message;
+6
View File
@@ -3711,6 +3711,12 @@ gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
} }
ac->instrumentation_exit = true; ac->instrumentation_exit = true;
return 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; return false;
} }
+1
View File
@@ -139,6 +139,7 @@ struct AttributeContext {
bool entry_point_only : 1; bool entry_point_only : 1;
bool instrumentation_enter : 1; bool instrumentation_enter : 1;
bool instrumentation_exit : 1; bool instrumentation_exit : 1;
bool no_sanitize_address : 1;
bool rodata : 1; bool rodata : 1;
bool ignore_duplicates : 1; bool ignore_duplicates : 1;
u32 optimization_mode; // ProcedureOptimizationMode u32 optimization_mode; // ProcedureOptimizationMode
+1
View File
@@ -258,6 +258,7 @@ struct Entity {
bool is_memcpy_like : 1; bool is_memcpy_like : 1;
bool uses_branch_location : 1; bool uses_branch_location : 1;
bool is_anonymous : 1; bool is_anonymous : 1;
bool no_sanitize_address : 1;
} Procedure; } Procedure;
struct { struct {
Array<Entity *> entities; Array<Entity *> entities;
+1 -1
View File
@@ -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 (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"); lb_add_attribute_to_proc(m, p->value, "sanitize_address");
} }
if (build_context.sanitizer_flags & SanitizerFlag_Memory) { if (build_context.sanitizer_flags & SanitizerFlag_Memory) {