diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-01-10 08:46:39 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-01-10 08:46:39 +0000 |
commit | 1bf7a3fcc4e2ad30688f7b0db464ad1ccabe77e2 (patch) | |
tree | dd5cabf9dba41214b2dcc602b703c343c12b77ed /lib/CodeGen/CodeGenModule.cpp | |
parent | 7ead5c7b6fd48cf549e55b4db499c26ecf88ae75 (diff) |
The `-fwritable-strings' flag doesn't make the backing store strings of all
CFStrings writable.
The strings (both Unicode and ASCII) should reside in a read-only section. E.g.,
__TEXT,__cstring instead of __DATA,__data. This is done by making the global
variable created for the strings constant despite the value of that flag.
<rdar://problem/10657500>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 9e772b40c4..76918dd448 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1848,24 +1848,20 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) { llvm::Constant *C = llvm::ConstantArray::get(VMContext, Entry.getKey().str()); llvm::GlobalValue::LinkageTypes Linkage; - bool isConstant; - if (isUTF16) { + if (isUTF16) // FIXME: why do utf strings get "_" labels instead of "L" labels? Linkage = llvm::GlobalValue::InternalLinkage; - // Note: -fwritable-strings doesn't make unicode CFStrings writable, but - // does make plain ascii ones writable. - isConstant = true; - } else { + else // FIXME: With OS X ld 123.2 (xcode 4) and LTO we would get a linker error // when using private linkage. It is not clear if this is a bug in ld // or a reasonable new restriction. Linkage = llvm::GlobalValue::LinkerPrivateLinkage; - isConstant = !Features.WritableStrings; - } + // Note: -fwritable-strings doesn't make the backing store strings of + // CFStrings writable. (See <rdar://problem/10657500>) llvm::GlobalVariable *GV = - new llvm::GlobalVariable(getModule(), C->getType(), isConstant, Linkage, C, - ".str"); + new llvm::GlobalVariable(getModule(), C->getType(), /*isConstant=*/true, + Linkage, C, ".str"); GV->setUnnamedAddr(true); if (isUTF16) { CharUnits Align = getContext().getTypeAlignInChars(getContext().ShortTy); |