brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 4f490ba Raw
164 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t; split-file %s %t3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo1.s -o %t/foo1.o4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo2.s -o %t/foo2.o5# RUN: %lld -dylib --icf=all -framework CoreFoundation %t/foo1.o %t/foo2.o -o %t/foo6# RUN: llvm-objdump --no-print-imm-hex --macho --rebase --bind --syms -d %t/foo | FileCheck %s --check-prefixes=CHECK,LITERALS7# RUN: %lld -dylib -framework CoreFoundation %t/foo1.o %t/foo2.o -o %t/foo8# RUN: llvm-objdump --no-print-imm-hex --macho --rebase --bind --syms -d %t/foo | FileCheck %s --check-prefix=LITERALS9 10# Check that string deduplication for symbol names is working11# RUN: %lld -dylib -framework CoreFoundation %t/foo1.o %t/foo2.o -o %t/foo_no_dedup -no-deduplicate-symbol-strings12# RUN: llvm-strings %t/foo | FileCheck %s --check-prefix=CHECK-DEDUP13# RUN: llvm-strings %t/foo_no_dedup | FileCheck %s --check-prefix=CHECK-NO-DEDUP14# CHECK-DEDUP: _named_cfstring15# CHECK-DEDUP-NOT: _named_cfstring16# CHECK-NO-DEDUP: _named_cfstring17# CHECK-NO-DEDUP: _named_cfstring18# CHECK-NO-DEDUP-NOT: _named_cfstring19 20 21# CHECK:       (__TEXT,__text) section22# CHECK-NEXT:  _foo1:23# CHECK-NEXT:  _foo2:24# CHECK-NEXT:       movq    _named_cfstring(%rip), %rax25# CHECK-NEXT:  _foo1_utf16:26# CHECK-NEXT:       movq    [[#]](%rip), %rax27# CHECK-NEXT:  _named_foo1:28# CHECK-NEXT:  _named_foo2:29# CHECK-NEXT:       movq    _named_cfstring(%rip), %rax30# CHECK-NEXT:  _foo2_utf16:31# CHECK-NEXT:       movq    [[#]](%rip), %rax32 33# CHECK:       SYMBOL TABLE:34# CHECK-DAG:   [[#%.16x,FOO:]] g     F __TEXT,__text _foo135# CHECK-DAG:   [[#FOO]]        g     F __TEXT,__text _foo236 37## Make sure we don't emit redundant bind / rebase opcodes for folded sections.38# LITERALS:       Rebase table:39# LITERALS-NEXT:  segment  section          address  type40# LITERALS-NEXT:  __DATA_CONST __cfstring   {{.*}}   pointer41# LITERALS-NEXT:  __DATA_CONST __cfstring   {{.*}}   pointer42# LITERALS-NEXT:  __DATA_CONST __cfstring   {{.*}}   pointer43# LITERALS-EMPTY:44# LITERALS-NEXT:  Bind table:45# LITERALS-NEXT:  segment      section      address  type       addend dylib            symbol46# LITERALS-NEXT:  __DATA_CONST __cfstring   {{.*}}   pointer         0 CoreFoundation   ___CFConstantStringClassReference47# LITERALS-NEXT:  __DATA_CONST __cfstring   {{.*}}   pointer         0 CoreFoundation   ___CFConstantStringClassReference48# LITERALS-NEXT:  __DATA_CONST __cfstring   {{.*}}   pointer         0 CoreFoundation   ___CFConstantStringClassReference49# LITERALS-EMPTY:50 51#--- foo1.s52.cstring53L_.str.0:54  .asciz  "bar"55## This string is at a different offset than the corresponding "foo" string in56## foo2.s. Make sure that we treat references to either string as equivalent.57L_.str:58  .asciz  "foo"59 60.section  __DATA,__cfstring61.p2align  362L__unnamed_cfstring_:63  .quad  ___CFConstantStringClassReference64  .long  1992 ## utf-865  .space  466  .quad  L_.str67  .quad  3 ## strlen68 69_named_cfstring:70  .quad  ___CFConstantStringClassReference71  .long  1992 ## utf-872  .space  473  .quad  L_.str74  .quad  3 ## strlen75 76.section  __TEXT,__ustring77l_.ustr:78  .short  102 ## f79  .short  111 ## o80  .short  0   ## \081  .short  111 ## o82  .short  0   ## \083 84## FIXME: We should be able to deduplicate UTF-16 CFStrings too.85## Note that this string contains a null byte in the middle -- any dedup code86## we add should take care to handle this correctly.87## Technically, UTF-8 should support encoding null bytes too, but since we88## atomize the __cstring section at every null byte, this isn't supported. ld6489## doesn't support it either, and clang seems to always emit a UTF-16 CFString90## if it needs to contain a null, so I think we're good here.91.section  __DATA,__cfstring92.p2align  393L__unnamed_cfstring_.2:94  .quad  ___CFConstantStringClassReference95  .long  2000 ## utf-1696  .space  497  .quad  l_.ustr98  .quad  4 ## strlen99 100.text101.globl  _foo1, _foo1_utf16, _named_foo1102_foo1:103  movq L__unnamed_cfstring_(%rip), %rax104 105_foo1_utf16:106  movq L__unnamed_cfstring_.2(%rip), %rax107 108_named_foo1:109  movq _named_cfstring(%rip), %rax110 111.subsections_via_symbols112 113#--- foo2.s114.cstring115L_.str:116  .asciz  "foo"117 118.section  __DATA,__cfstring119.p2align  3120L__unnamed_cfstring_:121  .quad  ___CFConstantStringClassReference122  .long  1992 ## utf-8123  .space  4124  .quad  L_.str125  .quad  3 ## strlen126 127_named_cfstring:128  .quad  ___CFConstantStringClassReference129  .long  1992 ## utf-8130  .space  4131  .quad  L_.str132  .quad  3 ## strlen133 134.section  __TEXT,__ustring135  .p2align  1136l_.ustr:137  .short  102 ## f138  .short  111 ## o139  .short  0   ## \0140  .short  111 ## o141  .short  0   ## \0142 143.section  __DATA,__cfstring144.p2align  3145L__unnamed_cfstring_.2:146  .quad  ___CFConstantStringClassReference147  .long  2000 ## utf-16148  .space  4149  .quad  l_.ustr150  .quad  4 ## strlen151 152.text153.globl  _foo2, _foo2_utf16, _named_foo2154_foo2:155  movq L__unnamed_cfstring_(%rip), %rax156 157_foo2_utf16:158  movq L__unnamed_cfstring_.2(%rip), %rax159 160_named_foo2:161  movq _named_cfstring(%rip), %rax162 163.subsections_via_symbols164