1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=i386 %s -o %t.o 3 4# RUN: ld.lld -shared -z now %t.o -o %t.so 5# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=LD-REL %s 6# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.so | FileCheck --check-prefix=LD %s 7 8# RUN: ld.lld -z now %t.o -o %t 9# RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s 10# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s 11 12## Check _TLS_MODULE_BASE_ used by LD produces a dynamic relocation with a value of 0. 13# LD-REL: .rel.dyn { 14# LD-REL-NEXT: R_386_TLS_DESC - 15# LD-REL-NEXT: } 16 17## 0x2318-0x1267 = 4273 18## dtpoff(a) = 8, dtpoff(b) = 12 19# LD: leal -8(%ebx), %eax 20# LD-NEXT: calll *(%eax) 21# LD-NEXT: leal 8(%eax), %ecx 22# LD-NEXT: leal 12(%eax), %edx 23 24## When producing an executable, the LD code sequence can be relaxed to LE. 25## It is the same as GD->LE. 26## tpoff(_TLS_MODULE_BASE_) = 0, tpoff(a) = -8, tpoff(b) = -4 27 28# NOREL: no relocations 29 30# LE: leal 0, %eax 31# LE-NEXT: nop 32# LE-NEXT: leal -8(%eax), %ecx 33# LE-NEXT: leal -4(%eax), %edx 34# LE-NEXT: addl %gs:0, %ecx 35# LE-NEXT: addl %gs:0, %edx 36 37leal _TLS_MODULE_BASE_@tlsdesc(%ebx), %eax 38call *_TLS_MODULE_BASE_@tlscall(%eax) 39leal a@dtpoff(%eax), %ecx 40leal b@dtpoff(%eax), %edx 41addl %gs:0, %ecx 42addl %gs:0, %edx 43 44.section .tbss 45.zero 8 46a: 47.zero 4 48b: 49.zero 4 50