File: ppc32-relocatable-got2.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 (47 lines) | stat: -rw-r--r-- 1,478 bytes parent folder | download | duplicates (19)
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
# REQUIRES: ppc
## Test addend adjustment of R_PPC_PLTREL24 when copying relocations.
## If r_addend indicates .got2, adjust it by the local .got2's output section offset.

# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
# RUN: echo 'bl f+0x8000@plt' | llvm-mc -filetype=obj -triple=powerpc - -o %t2.o
# RUN: ld.lld -r %t.o %t.o %t2.o -o %t
# RUN: llvm-readobj -r %t | FileCheck %s

# RUN: ld.lld -shared --emit-relocs %t.o %t.o %t2.o -o %t.so
# RUN: llvm-readobj -r %t.so | FileCheck %s

# CHECK:      .rela.adjust {
# CHECK-NEXT:   R_PPC_REL16_HA .got2 0x8002
# CHECK-NEXT:   R_PPC_REL16_LO .got2 0x8006
# CHECK-NEXT:   R_PPC_PLTREL24 foo 0x8000
# CHECK-NEXT:   R_PPC_PLTREL24 bar 0x8000
# CHECK-NEXT:   R_PPC_REL16_HA .got2 0x8006
# CHECK-NEXT:   R_PPC_REL16_LO .got2 0x800A
# CHECK-NEXT:   R_PPC_PLTREL24 foo 0x8004
# CHECK-NEXT:   R_PPC_PLTREL24 bar 0x8004
# CHECK-NEXT: }
# CHECK-NEXT: .rela.no_adjust {
# CHECK-NEXT:   R_PPC_PLTREL24 foo 0x0
# CHECK-NEXT:   R_PPC_PLTREL24 foo 0x0
# CHECK-NEXT: }
## %t2.o has an invalid relocation with r_addend=0x8000. Test we don't crash.
## The addend doesn't matter.
# CHECK-NEXT: .rela.text {
# CHECK-NEXT:   R_PPC_PLTREL24 f 0x8000
# CHECK-NEXT: }
.section .got2,"aw"
.long 0

.section .adjust,"ax"
bcl 20,30,.L0
.L0:
addis 30,30,.got2+0x8000-.L0@ha
addi 30,30,.got2+0x8000-.L0@l

## Refers to .got2+addend, adjust.
bl foo+0x8000@plt
bl bar+0x8000@plt

.section .no_adjust,"ax"
## Refers to .got, no adjustment.
bl foo@plt