]> granicus.if.org Git - clang/commit
Give explicit sections for string constants used in NSStrings.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 20 Jan 2014 20:33:18 +0000 (20:33 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 20 Jan 2014 20:33:18 +0000 (20:33 +0000)
commit68aa3e10547409a98d865dc56fec9af8243a192f
treeaead80ac22a971e91dab34c1c5afaabff66447cd
parentc50bf3d128af641f9249f7d1dc37e42b9fd31b81
Give explicit sections for string constants used in NSStrings.

Without them they can be merged with non unnamed_addr constants during LTO.
The resulting constant is not unnamed_addr and goes in a different section,
which causes ld64 to crash.

A testcase that would crash before:

* file1.mm:
void g(id notification) {
  [notification valueForKey:@"name"];
}

* file2.cpp:
extern const char js_name_str[] = "name";

* file3.cpp
extern bool JS_GetProperty(const char *name);
extern const char js_name_str[];
bool js_ReportUncaughtException() { JS_GetProperty(js_name_str); }

run

clang file1.mm  -o file1.o -c -w -emit-llvm
clang file2.cpp -o file2.o -c -w -emit-llvm
clang file3.cpp -o file3.o -c -w

ld -dylib -o XUL file1.o file2.o file3.o -undefined dynamic_lookup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199688 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CodeGenModule.cpp
test/CodeGen/cfstring.c
test/CodeGen/darwin-string-literals.c
test/CodeGen/utf16-cfstrings.c
test/CodeGenObjC/2009-08-05-utf16.m
test/CodeGenObjC/2010-02-01-utf16-with-null.m
test/CodeGenObjC/constant-strings.m