1
Fork 0

Preserve ___asan_globals_registered symbol during LTO.

Fixes https://github.com/rust-lang/rust/issues/113404
This commit is contained in:
Lukasz Anforowicz 2023-08-08 19:47:36 +00:00
parent c587fd4185
commit e6dddbda35
2 changed files with 50 additions and 0 deletions

View file

@ -1058,6 +1058,13 @@ extern "C" void LLVMRustPrintPasses() {
extern "C" void LLVMRustRunRestrictionPass(LLVMModuleRef M, char **Symbols,
size_t Len) {
auto PreserveFunctions = [=](const GlobalValue &GV) {
// Preserve LLVM-injected, ASAN-related symbols.
// See also https://github.com/rust-lang/rust/issues/113404.
if (GV.getName() == "___asan_globals_registered") {
return true;
}
// Preserve symbols exported from Rust modules.
for (size_t I = 0; I < Len; I++) {
if (GV.getName() == Symbols[I]) {
return true;