mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-13 13:53:43 +00:00
Support @(link_section=<string>) for procedures
This commit is contained in:
@@ -1485,6 +1485,11 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
||||
e->deprecated_message = ac.deprecated_message;
|
||||
e->warning_message = ac.warning_message;
|
||||
ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix, ac.link_suffix);
|
||||
|
||||
if (ac.link_section.len > 0) {
|
||||
e->Procedure.link_section = ac.link_section;
|
||||
}
|
||||
|
||||
if (ac.has_disabled_proc) {
|
||||
if (ac.disabled_proc) {
|
||||
e->flags |= EntityFlag_Disabled;
|
||||
|
||||
@@ -4179,6 +4179,17 @@ gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (name == "link_section") {
|
||||
ExactValue ev = check_decl_attribute_value(c, value);
|
||||
if (ev.kind == ExactValue_String) {
|
||||
ac->link_section = ev.value_string;
|
||||
if (!is_foreign_name_valid(ac->link_section)) {
|
||||
error(elem, "Invalid link section: %.*s", LIT(ac->link_section));
|
||||
}
|
||||
} else {
|
||||
error(elem, "Expected a string value for '%.*s'", LIT(name));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -249,6 +249,7 @@ struct Entity {
|
||||
String link_name;
|
||||
String link_prefix;
|
||||
String link_suffix;
|
||||
String link_section;
|
||||
String objc_selector_name;
|
||||
Entity *objc_class;
|
||||
DeferredProcedure deferred_procedure;
|
||||
|
||||
@@ -253,6 +253,9 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
|
||||
lb_set_wasm_procedure_import_attributes(p->value, entity, p->name);
|
||||
}
|
||||
|
||||
if (entity->Procedure.link_section.len > 0) {
|
||||
LLVMSetSection(p->value, alloc_cstring(permanent_allocator(), entity->Procedure.link_section));
|
||||
}
|
||||
|
||||
// NOTE(bill): offset==0 is the return value
|
||||
isize offset = 1;
|
||||
|
||||
Reference in New Issue
Block a user