[PATCH] D143611: [SanitizerBinaryMetadata] Make constructors/destructors hidden
Marco Elver via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 8 15:47:14 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c469d169389: [SanitizerBinaryMetadata] Make constructors/destructors hidden (authored by melver).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143611/new/
https://reviews.llvm.org/D143611
Files:
llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
llvm/test/Instrumentation/SanitizerBinaryMetadata/ctor.ll
Index: llvm/test/Instrumentation/SanitizerBinaryMetadata/ctor.ll
===================================================================
--- llvm/test/Instrumentation/SanitizerBinaryMetadata/ctor.ll
+++ llvm/test/Instrumentation/SanitizerBinaryMetadata/ctor.ll
@@ -9,8 +9,8 @@
; CHECK: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_atomics.module_ctor, ptr @__sanitizer_metadata_atomics.module_ctor }, { i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_covered.module_ctor, ptr @__sanitizer_metadata_covered.module_ctor }]
; CHECK: @llvm.global_dtors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_atomics.module_dtor, ptr @__sanitizer_metadata_atomics.module_dtor }, { i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_covered.module_dtor, ptr @__sanitizer_metadata_covered.module_dtor }]
-; CHECK: define dso_local void @__sanitizer_metadata_covered.module_ctor() #1 comdat {
-; CHECK: define dso_local void @__sanitizer_metadata_covered.module_dtor() #1 comdat {
+; CHECK: define hidden void @__sanitizer_metadata_covered.module_ctor() #1 comdat {
+; CHECK: define hidden void @__sanitizer_metadata_covered.module_dtor() #1 comdat {
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
@@ -216,8 +216,8 @@
(MI->FunctionPrefix + "_del").str(), InitTypes, InitArgs,
/*VersionCheckName=*/StringRef(), /*Weak=*/ClWeakCallbacks)
.first;
- Constant *CtorData = nullptr;
- Constant *DtorData = nullptr;
+ Constant *CtorComdatKey = nullptr;
+ Constant *DtorComdatKey = nullptr;
if (TargetTriple.supportsCOMDAT()) {
// Use COMDAT to deduplicate constructor/destructor function. The COMDAT
// key needs to be a non-local linkage.
@@ -225,11 +225,14 @@
Dtor->setComdat(Mod.getOrInsertComdat(Dtor->getName()));
Ctor->setLinkage(GlobalValue::ExternalLinkage);
Dtor->setLinkage(GlobalValue::ExternalLinkage);
- CtorData = Ctor;
- DtorData = Dtor;
+ // DSOs should _not_ call another constructor/destructor!
+ Ctor->setVisibility(GlobalValue::HiddenVisibility);
+ Dtor->setVisibility(GlobalValue::HiddenVisibility);
+ CtorComdatKey = Ctor;
+ DtorComdatKey = Dtor;
}
- appendToGlobalCtors(Mod, Ctor, kCtorDtorPriority, CtorData);
- appendToGlobalDtors(Mod, Dtor, kCtorDtorPriority, DtorData);
+ appendToGlobalCtors(Mod, Ctor, kCtorDtorPriority, CtorComdatKey);
+ appendToGlobalDtors(Mod, Dtor, kCtorDtorPriority, DtorComdatKey);
}
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143611.495979.patch
Type: text/x-patch
Size: 2967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230208/6d96c494/attachment.bin>
More information about the llvm-commits
mailing list