File: ppc64-toc-relax-constants.s

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (61 lines) | stat: -rw-r--r-- 2,126 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# REQUIRES: ppc

# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unkown-linux %p/Inputs/ppc64-toc-relax-shared.s -o %t.o
# RUN: ld.lld -shared -soname=t.so %t.o -o %t.so
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-toc-relax.s -o %t2.o
# RUN: llvm-readobj -r %t1.o | FileCheck --check-prefix=RELOCS %s
# RUN: ld.lld %t1.o %t2.o %t.so -o %t
# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SECTIONS %s
# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
# RUN: llvm-objdump -D %t | FileCheck %s

# In most cases, .toc contains exclusively addresses relocated by R_PPC64_ADDR16.
# Rarely .toc contain constants or variables.
# Test we can still perform toc-indirect to toc-relative relaxation.

# RELOCS:      .rela.text {
# RELOCS-NEXT:   0x0 R_PPC64_TOC16_HA .toc 0x0
# RELOCS-NEXT:   0x4 R_PPC64_TOC16_LO_DS .toc 0x0
# RELOCS-NEXT:   0x8 R_PPC64_TOC16_HA .toc 0x8
# RELOCS-NEXT:   0xC R_PPC64_TOC16_LO_DS .toc 0x8
# RELOCS-NEXT:   0x10 R_PPC64_TOC16_HA .toc 0x10
# RELOCS-NEXT:   0x14 R_PPC64_TOC16_LO_DS .toc 0x10
# RELOCS-NEXT: }

# SECTIONS: .got              PROGBITS        0000000010020308
# SECTIONS: .toc              PROGBITS        0000000010020308

# NM: 0000000010030320 D default

# .LCONST1 is .toc[0].
# .LCONST1 - (.got+0x8000) = 0x10020350 - (0x10020350+0x8000) = -32768
# CHECK: nop
# CHECK: lwa 3, -32768(2)
  addis 3, 2, .LCONST1@toc@ha
  lwa 3, .LCONST1@toc@l(3)

# .LCONST2 is .toc[1]
# .LCONST2 - (.got+0x8000) = 0x10020358 - (0x10020350+0x8000) = -32760
# CHECK: nop
# CHECK: ld 4, -32760(2)
  addis 4, 2, .LCONST2@toc@ha
  ld 4, .LCONST2@toc@l(4)

# .Ldefault is .toc[2]. `default` is not preemptable when producing an executable.
# After toc-indirection to toc-relative relaxation, it is loaded using an
# offset relative to r2.
# CHECK: addis 5, 2, 1
# CHECK: addi 5, 5, -32744
# CHECK: lwa 5, 0(5)
  addis 5, 2, .Ldefault@toc@ha
  ld    5, .Ldefault@toc@l(5)
  lwa   5, 0(5)

.section .toc,"aw",@progbits
.LCONST1:
  .quad 11
.LCONST2:
  .quad 22
.Ldefault:
  .tc default[TC],default