File: ppc32-got2.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (59 lines) | stat: -rw-r--r-- 1,505 bytes parent folder | download | duplicates (18)
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
# REQUIRES: ppc
## Test .got2 placed in a different output section.

# RUN: rm -rf %t && split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=powerpc %t/a.s -o %t/a.o
# RUN: llvm-mc -filetype=obj -triple=powerpc %t/b.s -o %t/b.o
# RUN: ld.lld -shared -T %t/t %t/a.o %t/b.o -o %t/a.so
# RUN: llvm-readobj -r %t/a.so | FileCheck --check-prefix=RELOC %s
# RUN: llvm-readelf -S %t/a.so | FileCheck --check-prefix=SEC %s

# RELOC:      .rela.plt {
# RELOC-NEXT:   0x1A4 R_PPC_JMP_SLOT f 0x0
# RELOC-NEXT: }

# SEC:      .got    PROGBITS 0000018c
# SEC-NEXT: .rodata PROGBITS 00000198

## .got2+0x8000-0xb0 = .rodata+4+0x8000-0xb0 = 0x198+4+0x8000-0xb0 = 65536*1-32532
# CHECK:      <_start>:
# CHECK-NEXT:          bcl 20, 31, 0x
# CHECK-NEXT:      b0: mflr 30
# CHECK-NEXT:          addis 30, 30, 1
# CHECK-NEXT:          addi 30, 30, -32532
# CHECK-NEXT:          bl {{.*}} <00008000.got2.plt_pic32.f>

## &.got[2] - (.got2+0x8000) = &.got[2] - (.rodata+4+0x8000) = 0x1A4 - (0x198+4+0x8000) = -32760
# CHECK:      <00008000.got2.plt_pic32.f>:
# CHECK-NEXT:   lwz 11, -32760(30)
# CHECK-NEXT:   mtctr 11
# CHECK-NEXT:   bctr
# CHECK-NEXT:   nop

#--- a.s
.section .rodata.cst4,"aM",@progbits,4
.long 1

.section .got2,"aw"
.long f

.text
.globl _start, f, g
_start:
  bcl 20,31,.L
.L:
  mflr 30
  addis 30, 30, .got2+0x8000-.L@ha
  addi 30, 30, .got2+0x8000-.L@l
  bl f+0x8000@plt

#--- b.s
.section .got2,"aw"
.globl f
f:
  bl f+0x8000@plt

#--- t
SECTIONS {
  .rodata : { *(.rodata .rodata.*) *(.got2) }
}