brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.3 KiB · f5cb683 Raw
176 lines · plain
1// REQUIRES: ppc2// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o3// RUN: ld.lld  %t.o -o %t4// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s5// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s6 7// RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR8 9/// Reject local-exec TLS relocations for -shared.10// ERR: error: relocation R_PPC64_TPREL16_HA against a cannot be used with -shared11// ERR: error: relocation R_PPC64_TPREL16_LO against a cannot be used with -shared12// ERR: error: relocation R_PPC64_TPREL16 against b cannot be used with -shared13// ERR: error: relocation R_PPC64_TPREL16_HI against b cannot be used with -shared14// ERR: error: relocation R_PPC64_TPREL16_DS against b cannot be used with -shared15// ERR: error: relocation R_PPC64_TPREL16_LO_DS against b cannot be used with -shared16// ERR: error: relocation R_PPC64_TPREL16_HIGHESTA against b cannot be used with -shared17// ERR: error: relocation R_PPC64_TPREL16_HIGHERA against b cannot be used with -shared18 19	.text20	.abiversion 221	.globl	test_local_exec                    # -- Begin function test_local_exec22	.p2align	423	.type	test_local_exec,@function24test_local_exec:                                   # @test_local_exec25.Lfunc_begin0:26# %bb.0:                                # %entry27	li 3, 028	stw 3, -12(1)29	addis 3, 13, a@tprel@ha30	addi 3, 3, a@tprel@l31	ld 3, 0(3)32	mr 4, 333	extsw 3, 434	blr35	.long	036	.quad	037.Lfunc_end0:38	.size	test_local_exec, .Lfunc_end0-.Lfunc_begin039                                        # -- End function40test_tprel:41.Lfunc_gep1:42  addis 2, 12, .TOC.-.Lfunc_gep1@ha43  addi 2, 2, .TOC.-.Lfunc_gep1@l44.Lfunc_lep1:45  .localentry test_tprel, .Lfunc_lep1-.Lfunc_gep146  addi 3, 13, b@tprel47  blr48 49 50test_hi:51.Lfunc_gep2:52  addis 2, 12, .TOC.-.Lfunc_gep2@ha53  addi  2, 2,  .TOC.-.Lfunc_gep2@l54.Lfunc_lep2:55  .localentry test_hi, .Lfunc_lep2-.Lfunc_gep256  addis 3, 13, b@tprel@h57  blr58 59test_ds:60.Lfunc_gep3:61  addis 2, 12, .TOC.-.Lfunc_gep3@ha62  addi 2, 2, .TOC.-.Lfunc_gep3@l63.Lfunc_lep3:64  .localentry test_ds, .Lfunc_lep3-.Lfunc_gep365  ld 3, b@tprel(13)66  blr67 68test_lo_ds:69.Lfunc_gep4:70  addis 2, 12, .TOC.-.Lfunc_gep4@ha71  addi 2, 2, .TOC.-.Lfunc_gep4@l72.Lfunc_lep4:73  .localentry test_lo_ds, .Lfunc_lep4-.Lfunc_gep474  ld 3, b@tprel@l(13)75  blr76 77test_highest_a:78.Lfunc_gep5:79  addis 2, 12, .TOC.-.Lfunc_gep5@ha80  addi  2, 2,  .TOC.-.Lfunc_gep5@l81.Lfunc_lep5:82  .localentry test_highest_a, .Lfunc_lep5-.Lfunc_gep583  lis 4, b@tprel@highesta84  ori 4, 4, b@tprel@highera85  lis 5, b@tprel@ha86  addi 5, 5, b@tprel@l87  sldi 4, 4, 3288  or   4, 4, 589  add  3, 13, 490  blr91 92test_highest:93.Lfunc_gep6:94  addis 2, 12, .TOC.-.Lfunc_gep6@ha95  addi  2, 2,  .TOC.-.Lfunc_gep6@l96.Lfunc_lep6:97  .localentry test_highest, .Lfunc_lep6-.Lfunc_gep698  lis 4, b@tprel@highest99  ori 4, 4, b@tprel@higher100  sldi 4, 4, 32101  oris  4, 4, b@tprel@h102  ori   4, 4, b@tprel@l103  add  3, 13, 4104  blr105 106	.type	a,@object               # @a107	.type	b,@object               # @b108	.section	.tdata,"awT",@progbits109	.p2align	3110a:111	.quad	55                      # 0x37112	.size	a, 8113 114b:115	.quad	55                      # 0x37116	.size	b, 8117 118// Verify that the input has every initial-exec tls relocation type.119// InputRelocs: Relocation section '.rela.text'120// InputRelocs: R_PPC64_TPREL16_HA {{0+}} a + 0121// InputRelocs: R_PPC64_TPREL16_LO {{0+}} a + 0122// InputRelocs: R_PPC64_TPREL16 {{0+8}} b + 0123// InputRelocs: R_PPC64_TPREL16_HI {{0+8}} b + 0124// InputRelocs: R_PPC64_TPREL16_DS {{0+8}} b + 0125// InputRelocs: R_PPC64_TPREL16_LO_DS {{0+8}} b + 0126// InputRelocs: R_PPC64_TPREL16_HIGHESTA {{0+8}} b + 0127// InputRelocs: R_PPC64_TPREL16_HIGHERA {{0+8}} b + 0128// InputRelocs: R_PPC64_TPREL16_HIGHEST {{0+8}} b + 0129// InputRelocs: R_PPC64_TPREL16_HIGHER {{0+8}} b + 0130 131// The start of the TLS storage area is 0x7000 bytes before the thread pointer (r13).132// We are building the address of the first TLS variable, relative to the thread pointer.133// #ha(a@tprel) --> (0 - 0x7000 + 0x8000) >> 16 = 0134// #lo(a@tprel)) --> (0 - 0x7000) &  0xFFFF =  -0x7000 = -28672135// Dis: <test_local_exec>:136// Dis: addis 3, 13, 0137// Dis: addi 3, 3, -28672138 139// We are building the offset for the second TLS variable140// Offset within tls storage - 0x7000141// b@tprel = 8 - 0x7000 = 28664142// Dis: <test_tprel>:143// Dis: addi 3, 13, -28664144 145// #hi(b@tprel) --> (8 - 0x7000) >> 16 = -1146// Dis: <test_hi>:147// Dis: addis 3, 13, -1148 149// b@tprel = 8 - 0x7000 = -28664150// Dis: <test_ds>:151// Dis: ld 3, -28664(13)152 153// #lo(b@tprel) --> (8 - 0x7000) & 0xFFFF = -28664154// Dis: <test_lo_ds>:155// Dis: ld 3, -28664(13)156 157// #highesta(b@tprel) --> ((0x8 - 0x7000 + 0x8000) >> 48) & 0xFFFF = 0158// #highera(b@tprel)  --> ((0x8 - 0x7000 + 0x8000) >> 32) & 0xFFFF = 0159// #ha(k@dtprel)       --> ((0x8 - 0x7000 + 0x8000) >> 16) & 0xFFFF = 0160// #lo(k@dtprel)       --> ((0x8 - 0x7000) & 0xFFFF = -28664161// Dis: <test_highest_a>:162// Dis: lis 4, 0163// Dis: ori 4, 4, 0164// Dis: lis 5, 0165// Dis: addi 5, 5, -28664166 167// #highest(b@tprel) --> ((0x8 - 0x7000) >> 48) & 0xFFFF = 0xFFFF = -1168// #higher(b@tprel)  --> ((0x8 - 0x7000) >> 32) & 0xFFFF = 0xFFFF = 65535169// #hi(k@dtprel)      --> ((0x8 - 0x7000) >> 16) & 0xFFFF = 0xFFFF = 65535170// #lo(k@dtprel)      --> ((0x8 - 0x7000) & 0xFFFF = 33796171// Dis: <test_highest>:172// Dis: lis 4, -1173// Dis: ori 4, 4, 65535174// Dis: oris 4, 4, 65535175// Dis: ori 4, 4, 36872176