[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`.
authorKristina Brooks <kristina@nym.hush.com>
Mon, 24 Sep 2018 14:06:47 +0000 (14:06 +0000)
committerKristina Brooks <kristina@nym.hush.com>
Mon, 24 Sep 2018 14:06:47 +0000 (14:06 +0000)
commit7c142a52e2db5df508fc665c2cc28cbd0ae00ac5
treea4064294c969d49ee1b0f25d009315fd81550c09
parentedefda48d2f543f6f97b72098ba1c24720c1af6e
[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`.

[Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets
that use `-fconstant-cfstrings`. The original changes from differential
for a similar patch to PE/COFF (https://reviews.llvm.org/D44491) did not
check for an edge case where the global could be a constant which surfaced
as an issue when building for ELF because of different linkage semantics.

This patch addresses several issues with crashes related to CF builds on ELF
as well as improves data layout by ensuring string literals that back
the actual CFConstStrings end up in .rodata in line with Mach-O.

Change itself tested with CoreFoundation on Linux x86_64 but should be valid
for BSD-like systems as well that use ELF as the native object format.

Differential Revision: https://reviews.llvm.org/D52344

llvm-svn: 342883
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/cfstring-elf.c [new file with mode: 0644]