133 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t; split-file %s %t3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/regular.s -o %t/regular.o4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/tbss.s -o %t/tbss.o5 6# RUN: %lld -lSystem -no_pie -o %t/regular-no-pie %t/regular.o7# RUN: llvm-otool -hv %t/regular-no-pie | FileCheck %s --check-prefix=HEADER8# RUN: llvm-objdump -d --bind --rebase %t/regular-no-pie | FileCheck %s --check-prefixes=REG,LINKEDIT9# RUN: llvm-objdump --macho --section=__DATA,__thread_vars %t/regular-no-pie | \10# RUN: FileCheck %s --check-prefix=REG-TLVP11 12# RUN: %lld -lSystem %t/regular.o -o %t/regular-pie13# RUN: llvm-otool -hv %t/regular-pie | FileCheck %s --check-prefix=HEADER14# RUN: llvm-objdump -d --bind --rebase %t/regular-pie | FileCheck %s --check-prefixes=REG,LINKEDIT15# RUN: llvm-objdump --macho --section=__DATA,__thread_vars %t/regular-pie | \16# RUN: FileCheck %s --check-prefix=REG-TLVP17 18# RUN: %lld -lSystem %t/tbss.o -o %t/tbss -e _f19# RUN: llvm-objdump -d --bind --rebase %t/tbss | FileCheck %s --check-prefixes=TBSS,LINKEDIT20# RUN: llvm-objdump --macho --section=__DATA,__thread_vars %t/tbss | \21# RUN: FileCheck %s --check-prefix=TBSS-TLVP22 23# RUN: %lld -lSystem %t/regular.o %t/tbss.o -o %t/regular-and-tbss24# RUN: llvm-objdump -d --bind --rebase %t/regular-and-tbss | FileCheck %s --check-prefixes=REG,TBSS,LINKEDIT25# RUN: llvm-objdump --macho --section=__DATA,__thread_vars %t/regular-and-tbss | \26# RUN: FileCheck %s --check-prefix=REG-TBSS-TLVP27# RUN: llvm-objdump --section-headers %t/regular-and-tbss | FileCheck %s --check-prefix=SECTIONS28 29## Check that we always put __thread_bss immediately after __thread_data,30## regardless of the order of the input files.31# RUN: %lld -lSystem %t/tbss.o %t/regular.o -o %t/regular-and-tbss32# RUN: llvm-objdump --section-headers %t/regular-and-tbss | FileCheck %s --check-prefix=SECTIONS33 34# HEADER: MH_HAS_TLV_DESCRIPTORS35 36# REG: <_main>:37# REG-NEXT: leaq {{.*}}(%rip), %rax ## {{.*}} <_foo>38# REG-NEXT: leaq {{.*}}(%rip), %rax ## {{.*}} <_bar>39# REG-NEXT: retq40 41# TBSS: <_f>:42# TBSS-NEXT: leaq {{.*}}(%rip), %rax ## {{.*}} <_baz>43# TBSS-NEXT: leaq {{.*}}(%rip), %rax ## {{.*}} <_qux>44# TBSS-NEXT: leaq {{.*}}(%rip), %rax ## {{.*}} <_hoge>45# TBSS-NEXT: retq46 47# REG-TLVP: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0048# REG-TLVP-NEXT: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0049# REG-TLVP-NEXT: 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 0050 51# TBSS-TLVP: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0052# TBSS-TLVP-NEXT: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0053# TBSS-TLVP-NEXT: 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 0054 55# REG-TBSS-TLVP: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0056# REG-TBSS-TLVP-NEXT: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0057# REG-TBSS-TLVP-NEXT: 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 0058# REG-TBSS-TLVP-NEXT: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0059# REG-TBSS-TLVP-NEXT: 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0060# REG-TBSS-TLVP-NEXT: 00 00 00 00 00 00 00 00 28 00 00 00 00 00 00 0061# REG-TBSS-TLVP-NEXT: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0062# REG-TBSS-TLVP-NEXT: 30 00 00 00 00 00 00 0063 64## Make sure we don't emit rebase opcodes for relocations in __thread_vars.65# LINKEDIT: Rebase table:66# LINKEDIT-NEXT: segment section address type67# LINKEDIT-EMPTY:68# LINKEDIT-NEXT: Bind table:69# LINKEDIT: __DATA __thread_vars 0x{{[0-9a-f]*}} pointer 0 libSystem __tlv_bootstrap70# LINKEDIT: __DATA __thread_vars 0x{{[0-9a-f]*}} pointer 0 libSystem __tlv_bootstrap71 72## Make sure we have an odd number of tlv vars, and that the __thread_vars73## section starts 16-bytes aligned. This is the setup required for __thread_data74## not to be automatically 16-bytes aligned, ensuring the linker does its75## expected job of aligning _hoge$tlv$init.76# SECTIONS: __thread_vars {{[0-9]+}}8 {{[0-9]+}}077# SECTIONS: __thread_data78# SECTIONS: more_thread_data79# SECTIONS-NEXT: __thread_bss80 81#--- regular.s82.globl _main83_main:84 mov _foo@TLVP(%rip), %rax85 mov _bar@TLVP(%rip), %rax86 ret87 88.section __DATA,__thread_data,thread_local_regular89_foo$tlv$init:90 .quad 12391 92.section __DATA,more_thread_data,thread_local_regular93_bar$tlv$init:94 .quad 12395 96.section __DATA,__thread_vars,thread_local_variables97.globl _foo, _bar98_foo:99 .quad __tlv_bootstrap100 .quad 0101 .quad _foo$tlv$init102_bar:103 .quad __tlv_bootstrap104 .quad 0105 .quad _bar$tlv$init106 107#--- tbss.s108 109.globl _f110_f:111 mov _baz@TLVP(%rip), %rax112 mov _qux@TLVP(%rip), %rax113 mov _hoge@TLVP(%rip), %rax114 ret115 116.tbss _baz$tlv$init, 8, 3117.tbss _qux$tlv$init, 8, 3118.tbss _hoge$tlv$init, 16, 4119 120.section __DATA,__thread_vars,thread_local_variables121_baz:122 .quad __tlv_bootstrap123 .quad 0124 .quad _baz$tlv$init125_qux:126 .quad __tlv_bootstrap127 .quad 0128 .quad _qux$tlv$init129_hoge:130 .quad __tlv_bootstrap131 .quad 0132 .quad _hoge$tlv$init133