summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/ModuleUtils.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2011-12-15 21:59:03 +0000
committerKostya Serebryany <kcc@google.com>2011-12-15 21:59:03 +0000
commit7bcfc9950bac0f411f9671e8d6ce483bd219727e (patch)
treee611f4c3924e5cb266389fe9b1bd4ec93430db9f /lib/Transforms/Utils/ModuleUtils.cpp
parent276ed0344c05822617934fa4a6a9920d864193a5 (diff)
downloadllvm-7bcfc9950bac0f411f9671e8d6ce483bd219727e.tar.gz
llvm-7bcfc9950bac0f411f9671e8d6ce483bd219727e.tar.bz2
llvm-7bcfc9950bac0f411f9671e8d6ce483bd219727e.tar.xz
[asan] fix a bug (issue 19) where dlclose and the following mmap caused a false positive. compiler part.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146688 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/ModuleUtils.cpp')
-rw-r--r--lib/Transforms/Utils/ModuleUtils.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/ModuleUtils.cpp b/lib/Transforms/Utils/ModuleUtils.cpp
index 5e294a3a8e..8491c5582d 100644
--- a/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/lib/Transforms/Utils/ModuleUtils.cpp
@@ -19,7 +19,8 @@
using namespace llvm;
-void llvm::appendToGlobalCtors(Module &M, Function *F, int Priority) {
+static void appendToGlobalArray(const char *Array,
+ Module &M, Function *F, int Priority) {
IRBuilder<> IRB(M.getContext());
FunctionType *FnTy = FunctionType::get(IRB.getVoidTy(), false);
StructType *Ty = StructType::get(
@@ -31,7 +32,7 @@ void llvm::appendToGlobalCtors(Module &M, Function *F, int Priority) {
// Get the current set of static global constructors and add the new ctor
// to the list.
SmallVector<Constant *, 16> CurrentCtors;
- if (GlobalVariable * GVCtor = M.getNamedGlobal("llvm.global_ctors")) {
+ if (GlobalVariable * GVCtor = M.getNamedGlobal(Array)) {
if (Constant *Init = GVCtor->getInitializer()) {
unsigned n = Init->getNumOperands();
CurrentCtors.reserve(n + 1);
@@ -51,6 +52,13 @@ void llvm::appendToGlobalCtors(Module &M, Function *F, int Priority) {
// Create the new global variable and replace all uses of
// the old global variable with the new one.
(void)new GlobalVariable(M, NewInit->getType(), false,
- GlobalValue::AppendingLinkage, NewInit,
- "llvm.global_ctors");
+ GlobalValue::AppendingLinkage, NewInit, Array);
+}
+
+void llvm::appendToGlobalCtors(Module &M, Function *F, int Priority) {
+ appendToGlobalArray("llvm.global_ctors", M, F, Priority);
+}
+
+void llvm::appendToGlobalDtors(Module &M, Function *F, int Priority) {
+ appendToGlobalArray("llvm.global_dtors", M, F, Priority);
}