1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
3
4## Relocation in a non .debug_* referencing a discarded TLS symbol is invalid.
5## If we happen to have no PT_TLS, we will emit an error.
6# RUN: not ld.lld %t.o --gc-sections -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
7
8# ERR: error: {{.*}}.o has an STT_TLS symbol but doesn't have an SHF_TLS section
9
10## If we happen to have a PT_TLS, we will resolve the relocation to
11## an arbitrary value (current implementation uses a negative value).
12# RUN: echo '.section .tbss,"awT"; .globl root; root: .long 0' | \
13# RUN:   llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
14# RUN: ld.lld --gc-sections -u root %t.o %t1.o -o %t
15# RUN: llvm-readelf -x .noalloc %t | FileCheck %s
16
17# CHECK:      Hex dump of section '.noalloc':
18# CHECK-NEXT: 0x00000000 {{[0-9a-f]+}} ffffffff
19
20.section .tbss,"awT",@nobits
21tls:
22  .long 0
23
24.section .noalloc,""
25  .quad tls+0x8000
26