-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland "[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fcon…
…stant-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 llvm-svn: 343038
- Loading branch information
Kristina Brooks
committed
Sep 25, 2018
1 parent
0b7fdca
commit 34e24d5
Showing
4 changed files
with
101 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// REQUIRES: x86-registered-target | ||
|
||
// RUN: %clang_cc1 -triple x86_64-elf -DCF_BUILDING_CF -DDECL -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-CF-IN-CF-DECL | ||
// RUN: %clang_cc1 -triple x86_64-elf -DCF_BUILDING_CF -DDEFN -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-CF-IN-CF-DEFN | ||
// RUN: %clang_cc1 -triple x86_64-elf -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-CF | ||
// RUN: %clang_cc1 -triple x86_64-elf -DEXTERN -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-CF-EXTERN | ||
|
||
// RUN: %clang_cc1 -Os -triple x86_64-elf -DCF_BUILDING_CF -DDECL -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-CF-IN-CF-DECL | ||
// RUN: %clang_cc1 -Os -triple x86_64-elf -DCF_BUILDING_CF -DDEFN -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-CF-IN-CF-DEFN | ||
// RUN: %clang_cc1 -Os -triple x86_64-elf -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-CF | ||
// RUN: %clang_cc1 -Os -triple x86_64-elf -DEXTERN -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-CF-EXTERN | ||
|
||
|
||
#if defined(CF_BUILDING_CF) | ||
#if defined(DECL) | ||
extern long __CFConstantStringClassReference[]; | ||
#elif defined(DEFN) | ||
long __CFConstantStringClassReference[32]; | ||
#endif | ||
#else | ||
#if defined(EXTERN) | ||
extern long __CFConstantStringClassReference[]; | ||
#else | ||
long __CFConstantStringClassReference[]; | ||
#endif | ||
#endif | ||
|
||
typedef struct __CFString *CFStringRef; | ||
const CFStringRef string = (CFStringRef)__builtin___CFStringMakeConstantString("string"); | ||
|
||
|
||
// CHECK-CF-IN-CF-DECL: @__CFConstantStringClassReference = external global [0 x i32] | ||
// CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = common global [32 x i64] zeroinitializer, align 16 | ||
// CHECK-CF: @__CFConstantStringClassReference = common global [1 x i64] zeroinitializer, align 8 | ||
// CHECK-CF-EXTERN: @__CFConstantStringClassReference = external global [0 x i32] | ||
// CHECK-CF-EXTERN: @.str = private unnamed_addr constant [7 x i8] c"string\00", section ".rodata", align 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// REQUIRES: x86-registered-target | ||
|
||
// RUN: %clang_cc1 -triple x86_64-elf -S %s -o - | FileCheck %s -check-prefix CHECK-ELF-DATA-SECTION | ||
|
||
typedef struct __CFString *CFStringRef; | ||
const CFStringRef one = (CFStringRef)__builtin___CFStringMakeConstantString("one"); | ||
const CFStringRef two = (CFStringRef)__builtin___CFStringMakeConstantString("\xef\xbf\xbd\x74\xef\xbf\xbd\x77\xef\xbf\xbd\x6f"); | ||
|
||
// CHECK-ELF-DATA-SECTION: .type .L.str,@object | ||
// CHECK-ELF-DATA-SECTION: .section .rodata,"a",@progbits | ||
// CHECK-ELF-DATA-SECTION: .L.str: | ||
// CHECK-ELF-DATA-SECTION: .asciz "one" | ||
|
||
// CHECK-ELF-DATA-SECTION: .type .L.str.1,@object | ||
// CHECK-ELF-DATA-SECTION: .section .rodata,"a",@progbits | ||
// CHECK-ELF-DATA-SECTION: .L.str.1: | ||
// CHECK-ELF-DATA-SECTION: .short 65533 | ||
// CHECK-ELF-DATA-SECTION: .short 116 | ||
// CHECK-ELF-DATA-SECTION: .short 65533 | ||
// CHECK-ELF-DATA-SECTION: .short 119 | ||
// CHECK-ELF-DATA-SECTION: .short 65533 | ||
// CHECK-ELF-DATA-SECTION: .short 111 | ||
// CHECK-ELF-DATA-SECTION: .short 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters