]> granicus.if.org Git - clang/commit
Reland "[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`"
authorKristina Brooks <kristina@nym.hush.com>
Tue, 25 Sep 2018 22:27:40 +0000 (22:27 +0000)
committerKristina Brooks <kristina@nym.hush.com>
Tue, 25 Sep 2018 22:27:40 +0000 (22:27 +0000)
commit23803581eda14735c2035e89a8bc8a212e2561b8
tree56acc5e4abf026cb7d764227adc1ac1b98900d70
parent7c8e954f273730037b454edf94c8d13123dbedf6
Reland "[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`"

Relanding rL342883 with more fragmented tests to test ELF-specific
section emission separately from broad-scope CFString tests. Now this
tests the following separately

1). CoreFoundation builds and linkage for ELF while building it.
2). CFString ELF section emission outside CF in assembly output.
3). Broad scope `cfstring3.c` tests which cover all object formats at
    bitcode level and assembly level (including ELF).

This fixes 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343038 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CodeGenModule.cpp
test/CodeGen/cfstring-elf-cfbuild-x86_64.c [new file with mode: 0644]
test/CodeGen/cfstring-elf-sections-x86_64.c [new file with mode: 0644]
test/CodeGen/cfstring3.c [moved from test/CodeGen/CFStrings.c with 89% similarity]