145 lines · plain
1# REQUIRES: ppc2# RUN: split-file %s %t3# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o4# RUN: ld.lld -T %t/lds --shared -soname=t-ld %t.o -o %t-ld.so5# RUN: ld.lld -T %t/lds %t.o -o %t-ldtole6 7# RUN: llvm-readelf -r %t-ld.so | FileCheck %s --check-prefix=LD-RELOC8# RUN: llvm-readelf -s %t-ld.so | FileCheck %s --check-prefix=LD-SYM9# RUN: llvm-readelf -x .got %t-ld.so | FileCheck %s --check-prefix=LD-GOT10# RUN: llvm-objdump -d --no-show-raw-insn %t-ld.so | FileCheck %s --check-prefix=LD11 12# RUN: llvm-readelf -r %t-ldtole | FileCheck %s --check-prefix=LDTOLE-RELOC13# RUN: llvm-readelf -s %t-ldtole | FileCheck %s --check-prefix=LDTOLE-SYM14# RUN: llvm-readelf -x .got %t-ldtole 2>&1 | FileCheck %s --check-prefix=LDTOLE-GOT15# RUN: llvm-objdump -d --no-show-raw-insn %t-ldtole | FileCheck %s --check-prefix=LDTOLE16 17## This test checks the Local Dynamic PC Relative TLS implementation for lld.18## LD - Local Dynamic with no relaxation possible19## LDTOLE - Local Dynamic relaxed to Local Exec20 21# LD-RELOC: Relocation section '.rela.dyn' at offset 0x10080 contains 1 entries:22# LD-RELOC: 0000000001004178 0000000000000044 R_PPC64_DTPMOD64 023 24# LD-SYM: Symbol table '.symtab' contains 11 entries:25# LD-SYM: 0000000000000000 0 TLS LOCAL DEFAULT 13 x26# LD-SYM: 0000000000000004 0 TLS LOCAL DEFAULT 13 y27 28# LD-GOT: section '.got':29# LD-GOT-NEXT: 0x01004170 70c10001 00000000 00000000 0000000030# LD-GOT-NEXT: 0x01004180 00000000 0000000031 32# LDTOLE-RELOC: There are no relocations in this file.33 34# LDTOLE-SYM: Symbol table '.symtab' contains 9 entries:35# LDTOLE-SYM: 0000000000000000 0 TLS LOCAL DEFAULT 6 x36# LDTOLE-SYM: 0000000000000004 0 TLS LOCAL DEFAULT 6 y37 38# LDTOLE-GOT: section '.got':39# LDTOLE-GOT-NEXT: 0x01004020 20c00001 0000000040 41//--- lds42SECTIONS {43 .text_addr 0x1001000 : { *(.text_addr) }44 .text_val 0x1002000 : { *(.text_val) }45 .text_twoval 0x1003000 : { *(.text_twoval) }46 .text_incrval 0x1004000 : { *(.text_incrval) }47}48 49//--- asm50# LD-LABEL: <LDAddr>:51# LD: paddi 3, 0, 12660, 152# LD-NEXT: bl 0x100102053# LD-NEXT: paddi 3, 3, -32768, 054# LD-NEXT: blr55# LDTOLE-LABEL: <LDAddr>:56# LDTOLE: paddi 3, 13, 4096, 057# LDTOLE-NEXT: nop58# LDTOLE-NEXT: paddi 3, 3, -32768, 059# LDTOLE-NEXT: blr60.section .text_addr, "ax", %progbits61LDAddr:62 ## TODO: Adding a reference to .TOC. since LLD doesn't gracefully handle the63 ## case where we define a .got section but have no references to the toc base64 ## yet.65 addis 2, 12, .TOC.-LDAddr@ha66 paddi 3, 0, x@got@tlsld@pcrel, 167 bl __tls_get_addr@notoc(x@tlsld)68 paddi 3, 3, x@dtprel, 069 blr70 71# LD-LABEL: <LDVal>:72# LD: paddi 3, 0, 8568, 173# LD-NEXT: bl 0x100102074# LD-NEXT: paddi 3, 3, -32768, 075# LD-NEXT: lwz 3, 0(3)76# LD-NEXT: blr77# LDTOLE-LABEL: <LDVal>:78# LDTOLE: paddi 3, 13, 4096, 079# LDTOLE-NEXT: nop80# LDTOLE-NEXT: paddi 3, 3, -32768, 081# LDTOLE-NEXT: lwz 3, 0(3)82# LDTOLE-NEXT: blr83.section .text_val, "ax", %progbits84LDVal:85 paddi 3, 0, x@got@tlsld@pcrel, 186 bl __tls_get_addr@notoc(x@tlsld)87 paddi 3, 3, x@dtprel, 088 lwz 3, 0(3)89 blr90 91# LD-LABEL: <LDTwoVal>:92# LD: paddi 3, 0, 4472, 193# LD-NEXT: bl 0x100102094# LD-NEXT: paddi 3, 3, -32768, 095# LD-NEXT: lwz 2, 0(3)96# LD-NEXT: paddi 3, 3, -32764, 097# LD-NEXT: lwz 3, 0(3)98# LD-NEXT: blr99# LDTOLE-LABEL: <LDTwoVal>:100# LDTOLE: paddi 3, 13, 4096, 0101# LDTOLE-NEXT: nop102# LDTOLE-NEXT: paddi 3, 3, -32768, 0103# LDTOLE-NEXT: lwz 2, 0(3)104# LDTOLE-NEXT: paddi 3, 3, -32764, 0105# LDTOLE-NEXT: lwz 3, 0(3)106# LDTOLE-NEXT: blr107.section .text_twoval, "ax", %progbits108LDTwoVal:109 paddi 3, 0, x@got@tlsld@pcrel, 1110 bl __tls_get_addr@notoc(x@tlsld)111 paddi 3, 3, x@dtprel, 0112 lwz 2, 0(3)113 paddi 3, 3, y@dtprel, 0114 lwz 3, 0(3)115 blr116 117# LD-LABEL: <LDIncrementVal>:118# LD: paddi 3, 0, 376, 1119# LD-NEXT: bl 0x1001020120# LD-NEXT: paddi 9, 3, -32764, 0121# LD-NEXT: lwz 4, 0(9)122# LD-NEXT: stw 5, 0(9)123# LD-NEXT: blr124# LDTOLE-LABEL: <LDIncrementVal>:125# LDTOLE: paddi 3, 13, 4096, 0126# LDTOLE-NEXT: nop127# LDTOLE-NEXT: paddi 9, 3, -32764, 0128# LDTOLE-NEXT: lwz 4, 0(9)129# LDTOLE-NEXT: stw 5, 0(9)130# LDTOLE-NEXT: blr131.section .text_incrval, "ax", %progbits132LDIncrementVal:133 paddi 3, 0, y@got@tlsld@pcrel, 1134 bl __tls_get_addr@notoc(y@tlsld)135 paddi 9, 3, y@dtprel, 0136 lwz 4, 0(9)137 stw 5, 0(9)138 blr139 140.section .tbss,"awT",@nobits141x:142 .long 0143y:144 .long 0145