aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-06-24 17:01:28 +0000
committerChris Lattner <sabre@nondot.org>2008-06-24 17:01:28 +0000
commit4e0b2641d8aa8da8eb001b959940a9ec68f45f0d (patch)
tree7522673769e1885ed0e44e9734b4953812a36f87
parentbe78424edfbc6095c4acb83c7ae7f53a42f0c870 (diff)
"This is a small fix for a bug where static object instances were being incorrectly generated. The bug was caused by my inability to read the GNU libobjc source and is only apparent when JITing code (static compilation does not expose the bug due to the data layout of other globals)."
Patch by David Chisnall! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52680 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index f2cfdcab82..2f02b13ee6 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -755,10 +755,12 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
llvm::StructType::get(PtrToInt8Ty, StaticsArrayTy, NULL);
llvm::Constant *Statics =
MakeGlobal(StaticsListTy, Elements, ".objc_statics");
- Statics = new
- llvm::GlobalVariable(llvm::PointerType::getUnqual(StaticsListTy), false,
- llvm::GlobalValue::InternalLinkage, Statics, ".objc_statics_ptr",
- &TheModule);
+ llvm::ArrayType *StaticsListArrayTy =
+ llvm::ArrayType::get(llvm::PointerType::getUnqual(StaticsListTy), 2);
+ Elements.clear();
+ Elements.push_back(Statics);
+ Elements.push_back(llvm::ConstantPointerNull::get(llvm::PointerType::getUnqual(StaticsListTy)));
+ Statics = MakeGlobal(StaticsListArrayTy, Elements, ".objc_statics_ptr");
Statics = llvm::ConstantExpr::getBitCast(Statics, PtrTy);
// Array of classes, categories, and constant objects
llvm::ArrayType *ClassListTy = llvm::ArrayType::get(PtrToInt8Ty,