1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
# REQUIRES: x86
# RUN: rm -rf %t; split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libtlv.s -o %t/libtlv.o
# RUN: %lld -dylib -install_name @executable_path/libtlv.dylib \
# RUN: -lSystem -o %t/libtlv.dylib %t/libtlv.o
# RUN: llvm-objdump --macho --exports-trie --rebase %t/libtlv.dylib | \
# RUN: FileCheck %s --check-prefix=DYLIB
# DYLIB-DAG: _foo [per-thread]
# DYLIB-DAG: _bar [per-thread]
## Make sure we don't emit rebase opcodes for relocations in __thread_vars.
# DYLIB: Rebase table:
# DYLIB-NEXT: segment section address type
# DYLIB-EMPTY:
# RUN: %lld -dylib -install_name @executable_path/libtlv.dylib \
# RUN: -lSystem -fixup_chains -o %t/libtlv.dylib %t/libtlv.o
## Make sure we don't emit fixups in __thread_vars.
# RUN: llvm-objdump --macho --chained-fixups %t/libtlv.dylib | \
# RUN: FileCheck %s --check-prefix=CHAINED
# CHAINED-NOT: __thread_vars
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
# RUN: %lld -lSystem -L%t -ltlv %t/test.o -o %t/test
# RUN: llvm-objdump --no-print-imm-hex --bind -d --no-show-raw-insn %t/test | FileCheck %s
# CHECK: movq [[#]](%rip), %rax ## 0x[[#%x, FOO:]]
# CHECK-NEXT: movq [[#]](%rip), %rax ## 0x[[#%x, BAR:]]
# CHECK-NEXT: movq [[#]](%rip), %rax ## 0x[[#%x, BAZ:]]
# CHECK-LABEL: Bind table:
# CHECK-DAG: __DATA __thread_ptrs 0x{{0*}}[[#%x, FOO]] pointer 0 libtlv _foo
# CHECK-DAG: __DATA __thread_ptrs 0x{{0*}}[[#%x, BAR]] pointer 0 libtlv _bar
# CHECK-DAG: __DATA_CONST __got 0x{{0*}}[[#%x, BAZ]] pointer 0 libtlv _baz
## Check `type` on the various TLV sections, and check that
## nothing's after S_THREAD_LOCAL_ZEROFILL.
# RUN: llvm-otool -lv %t/test | FileCheck --check-prefix=FLAGS %s
# FLAGS: sectname __got
# FLAGS-NEXT: segname __DATA_CONST
# FLAGS-NEXT: addr
# FLAGS-NEXT: size 0x0000000000000008
# FLAGS-NEXT: offset
# FLAGS-NEXT: align 2^3 (8)
# FLAGS-NEXT: reloff 0
# FLAGS-NEXT: nreloc 0
# FLAGS-NEXT: type S_NON_LAZY_SYMBOL_POINTERS
# FLAGS: sectname __thread_vars
# FLAGS-NEXT: segname __DATA
# FLAGS-NEXT: addr
# FLAGS-NEXT: size 0x0000000000000030
# FLAGS-NEXT: offset
# FLAGS-NEXT: align 2^3 (8)
# FLAGS-NEXT: reloff 0
# FLAGS-NEXT: nreloc 0
# FLAGS-NEXT: type S_THREAD_LOCAL_VARIABLES
# FLAGS: sectname __thread_ptrs
# FLAGS-NEXT: segname __DATA
# FLAGS-NEXT: addr
# FLAGS-NEXT: size 0x0000000000000010
# FLAGS-NEXT: offset
# FLAGS-NEXT: align 2^3 (8)
# FLAGS-NEXT: reloff 0
# FLAGS-NEXT: nreloc 0
# FLAGS-NEXT: type S_THREAD_LOCAL_VARIABLE_POINTERS
# FLAGS: sectname __thread_data
# FLAGS-NEXT: segname __DATA
# FLAGS-NEXT: addr
# FLAGS-NEXT: size 0x0000000000000008
# FLAGS-NEXT: offset
# FLAGS-NEXT: align
# FLAGS-NEXT: reloff 0
# FLAGS-NEXT: nreloc 0
# FLAGS-NEXT: type S_THREAD_LOCAL_REGULAR
# FLAGS: sectname __thread_bss
# FLAGS-NEXT: segname __DATA
# FLAGS-NEXT: addr
# FLAGS-NEXT: size 0x0000000000000008
# FLAGS-NEXT: offset 0
# FLAGS-NEXT: align 2^3 (8)
# FLAGS-NEXT: reloff 0
# FLAGS-NEXT: nreloc 0
# FLAGS-NEXT: type S_THREAD_LOCAL_ZEROFILL
# FLAGS: sectname __common
# FLAGS-NEXT: segname __DATA
# FLAGS-NEXT: addr
# FLAGS-NEXT: size 0x0000000000004000
# FLAGS-NEXT: offset 0
# FLAGS-NEXT: align 2^14 (16384)
# FLAGS-NEXT: reloff 0
# FLAGS-NEXT: nreloc 0
# FLAGS-NEXT: type S_ZEROFILL
# FLAGS: sectname __bss
# FLAGS-NEXT: segname __DATA
# FLAGS-NEXT: addr
# FLAGS-NEXT: size 0x0000000000002000
# FLAGS-NEXT: offset 0
# FLAGS-NEXT: align 2^0 (1)
# FLAGS-NEXT: reloff 0
# FLAGS-NEXT: nreloc 0
# FLAGS-NEXT: type S_ZEROFILL
#--- libtlv.s
.section __DATA,__thread_vars,thread_local_variables
.globl _foo, _bar, _baz
_foo:
_bar:
.text
_baz:
#--- test.s
.globl _main
_main:
mov _foo@TLVP(%rip), %rax
mov _bar@TLVP(%rip), %rax
## Add a GOT entry to make sure we don't mix it up with TLVs
mov _baz@GOTPCREL(%rip), %rax
ret
## Add some TLVs to test too, so that we can test the ordering
## of __thread_ptrs, __thread_data, and __thread_bss.
## Also add a .bss and a .comm for good measure too. Since they
## are both zerofill, they end up after __thread_bss.
.comm _com, 0x4000
.bss
.zero 0x2000
.section __DATA,__thread_data,thread_local_regular
_tfoo$tlv$init:
.quad 123
.tbss _tbaz$tlv$init, 8, 3
.section __DATA,__thread_vars,thread_local_variables
.globl _tfoo, _tbar
_tfoo:
.quad __tlv_bootstrap
.quad 0
.quad _tfoo$tlv$init
_tbaz:
.quad __tlv_bootstrap
.quad 0
.quad _tbaz$tlv$init
|