145 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t; split-file %s %t3 4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libtlv.s -o %t/libtlv.o5# RUN: %lld -dylib -install_name @executable_path/libtlv.dylib \6# RUN: -lSystem -o %t/libtlv.dylib %t/libtlv.o7# RUN: llvm-objdump --macho --exports-trie --rebase %t/libtlv.dylib | \8# RUN: FileCheck %s --check-prefix=DYLIB9# DYLIB-DAG: _foo [per-thread]10# DYLIB-DAG: _bar [per-thread]11## Make sure we don't emit rebase opcodes for relocations in __thread_vars.12# DYLIB: Rebase table:13# DYLIB-NEXT: segment section address type14# DYLIB-EMPTY:15 16# RUN: %lld -dylib -install_name @executable_path/libtlv.dylib \17# RUN: -lSystem -fixup_chains -o %t/libtlv.dylib %t/libtlv.o18## Make sure we don't emit fixups in __thread_vars.19# RUN: llvm-objdump --macho --chained-fixups %t/libtlv.dylib | \20# RUN: FileCheck %s --check-prefix=CHAINED21# CHAINED-NOT: __thread_vars22 23# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o24# RUN: %lld -lSystem -L%t -ltlv %t/test.o -o %t/test25# RUN: llvm-objdump --no-print-imm-hex --bind -d --no-show-raw-insn %t/test | FileCheck %s26 27# CHECK: movq [[#]](%rip), %rax ## 0x[[#%x, FOO:]]28# CHECK-NEXT: movq [[#]](%rip), %rax ## 0x[[#%x, BAR:]]29# CHECK-NEXT: movq [[#]](%rip), %rax ## 0x[[#%x, BAZ:]]30 31# CHECK-LABEL: Bind table:32# CHECK-DAG: __DATA __thread_ptrs 0x{{0*}}[[#%x, FOO]] pointer 0 libtlv _foo33# CHECK-DAG: __DATA __thread_ptrs 0x{{0*}}[[#%x, BAR]] pointer 0 libtlv _bar34# CHECK-DAG: __DATA_CONST __got 0x{{0*}}[[#%x, BAZ]] pointer 0 libtlv _baz35 36## Check `type` on the various TLV sections, and check that37## nothing's after S_THREAD_LOCAL_ZEROFILL.38# RUN: llvm-otool -lv %t/test | FileCheck --check-prefix=FLAGS %s39# FLAGS: sectname __got40# FLAGS-NEXT: segname __DATA_CONST41# FLAGS-NEXT: addr42# FLAGS-NEXT: size 0x000000000000000843# FLAGS-NEXT: offset44# FLAGS-NEXT: align 2^3 (8)45# FLAGS-NEXT: reloff 046# FLAGS-NEXT: nreloc 047# FLAGS-NEXT: type S_NON_LAZY_SYMBOL_POINTERS48# FLAGS: sectname __thread_vars49# FLAGS-NEXT: segname __DATA50# FLAGS-NEXT: addr51# FLAGS-NEXT: size 0x000000000000003052# FLAGS-NEXT: offset53# FLAGS-NEXT: align 2^3 (8)54# FLAGS-NEXT: reloff 055# FLAGS-NEXT: nreloc 056# FLAGS-NEXT: type S_THREAD_LOCAL_VARIABLES57# FLAGS: sectname __thread_ptrs58# FLAGS-NEXT: segname __DATA59# FLAGS-NEXT: addr60# FLAGS-NEXT: size 0x000000000000001061# FLAGS-NEXT: offset62# FLAGS-NEXT: align 2^3 (8)63# FLAGS-NEXT: reloff 064# FLAGS-NEXT: nreloc 065# FLAGS-NEXT: type S_THREAD_LOCAL_VARIABLE_POINTERS66# FLAGS: sectname __thread_data67# FLAGS-NEXT: segname __DATA68# FLAGS-NEXT: addr69# FLAGS-NEXT: size 0x000000000000000870# FLAGS-NEXT: offset71# FLAGS-NEXT: align72# FLAGS-NEXT: reloff 073# FLAGS-NEXT: nreloc 074# FLAGS-NEXT: type S_THREAD_LOCAL_REGULAR75# FLAGS: sectname __thread_bss76# FLAGS-NEXT: segname __DATA77# FLAGS-NEXT: addr78# FLAGS-NEXT: size 0x000000000000000879# FLAGS-NEXT: offset 080# FLAGS-NEXT: align 2^3 (8)81# FLAGS-NEXT: reloff 082# FLAGS-NEXT: nreloc 083# FLAGS-NEXT: type S_THREAD_LOCAL_ZEROFILL84# FLAGS: sectname __common85# FLAGS-NEXT: segname __DATA86# FLAGS-NEXT: addr87# FLAGS-NEXT: size 0x000000000000400088# FLAGS-NEXT: offset 089# FLAGS-NEXT: align 2^14 (16384)90# FLAGS-NEXT: reloff 091# FLAGS-NEXT: nreloc 092# FLAGS-NEXT: type S_ZEROFILL93# FLAGS: sectname __bss94# FLAGS-NEXT: segname __DATA95# FLAGS-NEXT: addr96# FLAGS-NEXT: size 0x000000000000200097# FLAGS-NEXT: offset 098# FLAGS-NEXT: align 2^0 (1)99# FLAGS-NEXT: reloff 0100# FLAGS-NEXT: nreloc 0101# FLAGS-NEXT: type S_ZEROFILL102 103#--- libtlv.s104.section __DATA,__thread_vars,thread_local_variables105.globl _foo, _bar, _baz106_foo:107_bar:108 109.text110_baz:111 112#--- test.s113.globl _main114_main:115 mov _foo@TLVP(%rip), %rax116 mov _bar@TLVP(%rip), %rax117## Add a GOT entry to make sure we don't mix it up with TLVs118 mov _baz@GOTPCREL(%rip), %rax119 ret120 121## Add some TLVs to test too, so that we can test the ordering122## of __thread_ptrs, __thread_data, and __thread_bss.123## Also add a .bss and a .comm for good measure too. Since they124## are both zerofill, they end up after __thread_bss.125.comm _com, 0x4000126.bss127.zero 0x2000128 129.section __DATA,__thread_data,thread_local_regular130_tfoo$tlv$init:131 .quad 123132 133.tbss _tbaz$tlv$init, 8, 3134 135.section __DATA,__thread_vars,thread_local_variables136.globl _tfoo, _tbar137_tfoo:138 .quad __tlv_bootstrap139 .quad 0140 .quad _tfoo$tlv$init141_tbaz:142 .quad __tlv_bootstrap143 .quad 0144 .quad _tbaz$tlv$init145