[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / ppc64-toc-rel.s
blobbe9046e8389f6beaab0c68a0345131a446965725
1 # REQUIRES: ppc
3 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
4 # RUN: llvm-readobj -r %t.o | FileCheck -check-prefix=RELOCS-LE %s
5 # RUN: ld.lld %t.o -o %t
6 # RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
7 # RUN: llvm-readelf -x .got %t | FileCheck --check-prefix=HEX-LE %s
8 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=CHECK %s
10 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
11 # RUN: llvm-readobj -r %t.o | FileCheck -check-prefix=RELOCS-BE %s
12 # RUN: ld.lld %t.o -o %t
13 # RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
14 # RUN: llvm-readelf -x .got %t | FileCheck --check-prefix=HEX-BE %s
15 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=CHECK %s
17 # Make sure we calculate the offset correctly for a toc-relative access to a
18 # global variable as described by the PPC64 Elf V2 abi.
19 .abiversion 2
21 # int global_a = 55
22 .globl global_a
23 .section ".data"
24 .align 2
25 .type global_a, @object
26 .size global_a, 4
27 .p2align 2
28 global_a:
29 .long 41
32 .section ".text"
33 .align 2
34 .global _start
35 .type _start, @function
36 _start:
37 .Lfunc_gep0:
38 addis 2, 12, .TOC.-.Lfunc_gep0@ha
39 addi 2, 2, .TOC.-.Lfunc_gep0@l
40 .Lfunc_lep0:
41 .localentry _start, .Lfunc_lep0-.Lfunc_gep0
43 addis 3, 2, global_a@toc@ha
44 addi 3, 3, global_a@toc@l
45 li 0,1
46 lwa 3, 0(3)
48 .size _start,.-_start
50 # Verify the relocations that get emitted for the global variable are the
51 # expected ones.
52 # RELOCS-LE: Relocations [
53 # RELOCS-LE-NEXT: .rela.text {
54 # RELOCS-LE: 0x8 R_PPC64_TOC16_HA global_a 0x0
55 # RELOCS-LE: 0xC R_PPC64_TOC16_LO global_a 0x0
57 # RELOCS-BE: Relocations [
58 # RELOCS-BE-NEXT: .rela.text {
59 # RELOCS-BE: 0xA R_PPC64_TOC16_HA global_a 0x0
60 # RELOCS-BE: 0xE R_PPC64_TOC16_LO global_a 0x0
62 # The .TOC. symbol represents the TOC base address: .got + 0x8000 = 0x10028000,
63 # which is stored in the first entry of .got
64 # NM: 00000000100281e8 d .TOC.
65 # NM: 00000000100301f0 D global_a
66 # HEX-LE: section '.got':
67 # HEX-LE-NEXT: 0x100201e8 e8810210 00000000
68 # HEX-BE: section '.got':
69 # HEX-BE-NEXT: 0x100201e8 00000000 100281e8
71 # r2 stores the TOC base address. To access global_a with r3, it
72 # computes the address with TOC plus an offset.
73 # global_a - .TOC. = 0x100301f0 - 0x100281e8 = (1 << 16) - 32760
74 # CHECK: <_start>:
75 # CHECK: 100101d0: addis 3, 2, 1
76 # CHECK-NEXT: 100101d4: addi 3, 3, -32760