Skip to content

Commit

Permalink
make corrected linkage with -use-separate-modules apply hidden visibi…
Browse files Browse the repository at this point in the history
…lity

Fixes odin-lang#4798

The DLL was using the type info of the host/exe, causing crashes.
This PR tries fixing by applying hidden visibility to these corrected
symbols which makes sure that the DLL can't see the type table of the host/exe.
  • Loading branch information
laytan committed Feb 6, 2025
1 parent 80d0977 commit 1053ec3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/llvm_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,17 @@ gb_internal void lb_correct_entity_linkage(lbGenerator *gen) {
other_global = LLVMGetNamedGlobal(ec.other_module->mod, ec.cname);
if (other_global) {
LLVMSetLinkage(other_global, LLVMWeakAnyLinkage);
if (!ec.e->Variable.is_export) {
LLVMSetVisibility(other_global, LLVMHiddenVisibility);
}
}
} else if (ec.e->kind == Entity_Procedure) {
other_global = LLVMGetNamedFunction(ec.other_module->mod, ec.cname);
if (other_global) {
LLVMSetLinkage(other_global, LLVMWeakAnyLinkage);
if (!ec.e->Procedure.is_export) {
LLVMSetVisibility(other_global, LLVMHiddenVisibility);
}
}
}
}
Expand Down

0 comments on commit 1053ec3

Please sign in to comment.