1# RUN: ld64.lld -macosx_version_min 10.7 -arch x86_64 -print_atoms %s -o %t | FileCheck %s 2# RUN: not ld64.lld -macosx_version_min 10.6 -arch x86_64 -o %t %s 2> %t2 3# RUN: FileCheck < %t2 %s --check-prefix=CHECK-ERROR 4# RUN: llvm-objdump --macho --private-headers %t | FileCheck %s --check-prefix=CHECK-LOADCMDS 5# 6# Test parsing of x86_64 tlv relocations. 7 8--- !mach-o 9arch: x86_64 10file-type: MH_OBJECT 11flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ] 12compat-version: 0.0 13current-version: 0.0 14has-UUID: false 15OS: unknown 16sections: 17 - segment: __TEXT 18 section: __text 19 type: S_REGULAR 20 attributes: [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ] 21 alignment: 16 22 address: 0x0000000000000000 23 content: [ 0x55, 0x48, 0x89, 0xE5, 0x48, 0x8B, 0x3D, 0x00, 24 0x00, 0x00, 0x00, 0xFF, 0x17, 0x8B, 0x00, 0x5D, 25 0xC3 ] 26 relocations: 27 - offset: 0x00000007 28 type: X86_64_RELOC_TLV 29 length: 2 30 pc-rel: true 31 extern: true 32 symbol: 2 33 - segment: __DATA 34 section: __thread_bss 35 type: S_THREAD_LOCAL_ZEROFILL 36 attributes: [ ] 37 alignment: 4 38 address: 0x0000000000000014 39 size: 4 40 - segment: __DATA 41 section: __thread_vars 42 type: S_THREAD_LOCAL_VARIABLES 43 attributes: [ ] 44 address: 0x0000000000000018 45 content: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ] 48 relocations: 49 - offset: 0x00000010 50 type: X86_64_RELOC_UNSIGNED 51 length: 3 52 pc-rel: false 53 extern: true 54 symbol: 0 55 - offset: 0x00000000 56 type: X86_64_RELOC_UNSIGNED 57 length: 3 58 pc-rel: false 59 extern: true 60 symbol: 3 61 - segment: __DATA 62 section: __dummy 63 type: S_REGULAR 64 attributes: [ ] 65 alignment: 8 66 address: 0x00000000000000C0 67 content: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ] 70local-symbols: 71 - name: '_x$tlv$init' 72 type: N_SECT 73 sect: 2 74 value: 0x0000000000000014 75global-symbols: 76 - name: _main 77 type: N_SECT 78 scope: [ N_EXT ] 79 sect: 1 80 value: 0x0000000000000000 81 - name: _x 82 type: N_SECT 83 scope: [ N_EXT ] 84 sect: 3 85 value: 0x0000000000000018 86 - name: '__tlv_bootstrap' 87 type: N_SECT 88 scope: [ N_EXT ] 89 sect: 4 90 value: 0x00000000000000C0 91 - name: 'dyld_stub_binder' 92 type: N_SECT 93 scope: [ N_EXT ] 94 sect: 4 95 value: 0x00000000000000C8 96 - name: 'start' 97 type: N_SECT 98 scope: [ N_EXT ] 99 sect: 4 100 value: 0x00000000000000D0 101page-size: 0x00000000 102... 103 104# CHECK: - name: _x 105# CHECK-NEXT: scope: global 106# CHECK-NEXT: type: tlv-thunk 107# CHECK-NOT: - name: 108# CHECK: references: 109# CHECK-NEXT: - kind: pointer64 110# CHECK-NEXT: offset: 0 111# CHECK-NEXT: target: __tlv_bootstrap 112# CHECK-NEXT: - kind: tlvInitSectionOffset 113# CHECK-NEXT: offset: 16 114# CHECK-NEXT: target: '_x$tlv$init' 115# CHECK: - name: '_x$tlv$init' 116# CHECK-NEXT: type: tlv-zero-fill 117# CHECK: - name: _main 118# CHECK-NOT: - name: 119# CHECK: references: 120# CHECK-NEXT: - kind: ripRel32 121# CHECK-NEXT: offset: 7 122# CHECK-NEXT: target: L[[ID:[0-9]+]] 123# CHECK: - ref-name: L[[ID]] 124# CHECK-NEXT: scope: hidden 125# CHECK-NEXT: type: tlv-initializer-ptr 126# CHECK-NEXT: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ] 127# CHECK-NEXT: alignment: 8 128# CHECK-NEXT: permissions: rw- 129# CHECK-NEXT: references: 130# CHECK-NEXT: - kind: pointer64 131# CHECK-NEXT: offset: 0 132# CHECK-NEXT: target: _x 133 134# CHECK-ERROR: targeted OS version does not support use of thread local variables in _main for architecture x86_64 135 136# CHECK-LOADCMDS: sectname __thread_bss 137# CHECK-LOADCMDS: segname __DATA 138# CHECK-LOADCMDS: addr 0x{{[0-9A-F]*}} 139# CHECK-LOADCMDS: size 0x0000000000000004 140# CHECK-LOADCMDS: offset 0 141# CHECK-LOADCMDS: align 2^2 (4) 142# CHECK-LOADCMDS: reloff 0 143# CHECK-LOADCMDS: nreloc 0 144# CHECK-LOADCMDS: type S_THREAD_LOCAL_ZEROFILL 145