1# REQUIRES: hexagon
2# RUN: llvm-mc -filetype=obj -defsym GDPLT=1 -triple=hexagon-unknown-elf %s -o %t.o
3# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t1.o
4# RUN: ld.lld -shared %t.o -o %t.so
5# RUN: ld.lld -shared %t1.o -o %t1.so
6# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.so | \
7# RUN:   FileCheck --check-prefix=CHECK_GDPLT %s
8# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t1.so | FileCheck %s
9# RUN: llvm-readobj -r %t.so | FileCheck -check-prefix=RELA_GDPLT  %s
10
11## Make sure __tls_get_addr is not present unless there is a GDPLT relocation.
12# RUN: llvm-readobj -r %t1.so | FileCheck -check-prefix=RELA \
13# RUN:   --implicit-check-not="__tls_get_addr" %s
14
15.globl _start
16.type _start, @function
17
18_start:
19.ifdef GDPLT
20                        call x@gdplt
21# CHECK_GDPLT:  101ec: { call 0x10220 }
22.else
23                  call x
24# CHECK:  101b8: { call 0x101e0 }
25.endif
26
27# CHECK_GDPLT:        10220: { immext(#0x20040)
28# CHECK_GDPLT-NEXT:   10224:   r14 = add(pc,##0x2007c) }
29# CHECK_GDPLT-NEXT:   10228: { r28 = memw(r14+#0x0) }
30# CHECK_GDPLT-NEXT:   1022c: { jumpr r28 }
31
32
33## Looking at the above check, 0x10220+0x2007c must equal the entry for
34##  __tls_get_addr, 0x3029C
35
36# RELA_GDPLT: Relocations [
37# RELA_GDPLT-NEXT:  Section (5) .rela.plt {
38# RELA_GDPLT-NEXT:    0x30298 R_HEX_JMP_SLOT x 0x0
39# RELA_GDPLT-NEXT:    0x3029C R_HEX_JMP_SLOT __tls_get_addr 0x0
40# RELA_GDPLT-NEXT:  }
41# RELA_GDPLT-NEXT:]
42
43# RELA: Relocations [
44# RELA-NEXT:  Section (5) .rela.plt {
45# RELA-NEXT:    0x30258 R_HEX_JMP_SLOT x 0x0
46# RELA-NEXT:  }
47# RELA-NEXT:]
48