diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-04-23 22:33:39 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-04-23 22:33:39 +0000 |
commit | ec951e0c2fc0db00c36bc60c900331dde32c1b43 (patch) | |
tree | 98a849b14840915f1953d4acb4a0ada3bdcf7b8c | |
parent | 88465d3e996e627bbaa11099b039ddab66d5af2c (diff) |
More -fno-constant-cfstrings API work.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102219 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/TargetInfo.h | 6 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 13 |
2 files changed, 15 insertions, 4 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index 455b745270..19987508ba 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -345,6 +345,12 @@ public: return "__OBJC,__cstring_object,regular,no_dead_strip"; } + /// getNSStringNonFragileABISection - Return the section to use for + /// NSString literals, or 0 if no special section is used (NonFragile ABI). + virtual const char *getNSStringNonFragileABISection() const { + return "__DATA, __objc_stringobj, regular, no_dead_strip"; + } + /// isValidSectionSpecifier - This is an optional hook that targets can /// implement to perform semantic checking on attribute((section("foo"))) /// specifiers. In this case, "foo" is passed in to be checked. If the diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index ee02e9374e..599df96723 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1610,12 +1610,14 @@ CodeGenModule::GetAddrOfConstantNSString(const StringLiteral *Literal) { llvm::Constant::getNullValue(llvm::Type::getInt32Ty(VMContext)); llvm::Constant *Zeros[] = { Zero, Zero }; - // If we don't already have it, get __NSConstantStringClassReference. + // If we don't already have it, get _NSConstantStringClassReference. if (!NSConstantStringClassRef) { const llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy); Ty = llvm::ArrayType::get(Ty, 0); - llvm::Constant *GV = CreateRuntimeVariable(Ty, - "__NSConstantStringClassReference"); + llvm::Constant *GV = CreateRuntimeVariable(Ty, + Features.ObjCNonFragileABI ? + "OBJC_CLASS_$_NSConstantString" : + "_NSConstantStringClassReference"); // Decay array -> ptr NSConstantStringClassRef = llvm::ConstantExpr::getGetElementPtr(GV, Zeros, 2); @@ -1666,7 +1668,10 @@ CodeGenModule::GetAddrOfConstantNSString(const StringLiteral *Literal) { llvm::GlobalVariable::PrivateLinkage, C, "_unnamed_nsstring_"); // FIXME. Fix section. - if (const char *Sect = getContext().Target.getNSStringSection()) + if (const char *Sect = + Features.ObjCNonFragileABI + ? getContext().Target.getNSStringNonFragileABISection() + : getContext().Target.getNSStringSection()) GV->setSection(Sect); Entry.setValue(GV); |