From 4e0b2641d8aa8da8eb001b959940a9ec68f45f0d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Jun 2008 17:01:28 +0000 Subject: [PATCH] "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 --- lib/CodeGen/CGObjCGNU.cpp | 10 ++++++---- 1 file 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, -- 2.50.1