2 # Check that the linker use a value of _gp symbol defined
3 # in a linker script to calculate GOT relocations.
5 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
7 # RUN: echo "SECTIONS { \
8 # RUN: .text : { *(.text) } \
9 # RUN: _gp = ABSOLUTE(.) + 0x100; \
10 # RUN: .got : { *(.got) } }" > %t.rel.script
11 # RUN: ld.lld -shared -o %t.rel.so --script %t.rel.script %t.o
12 # RUN: llvm-objdump -s -t %t.rel.so | FileCheck --check-prefix=REL %s
14 # RUN: echo "SECTIONS { \
15 # RUN: .text : { *(.text) } \
16 # RUN: _gp = 0x100 + ABSOLUTE(.); \
17 # RUN: .got : { *(.got) } }" > %t.rel.script
18 # RUN: ld.lld -shared -o %t.rel.so --script %t.rel.script %t.o
19 # RUN: llvm-objdump -s -t %t.rel.so | FileCheck --check-prefix=REL %s
21 # RUN: echo "SECTIONS { \
22 # RUN: .text : { *(.text) } \
24 # RUN: .got : { *(.got) } }" > %t.abs.script
25 # RUN: ld.lld -shared -o %t.abs.so --script %t.abs.script %t.o
26 # RUN: llvm-objdump -s -t %t.abs.so | FileCheck --check-prefix=ABS %s
28 # REL: 000000e0 l .text 00000000 foo
29 # REL: 00000000 l *ABS* 00000000 .hidden _gp_disp
30 # REL: 000001ec l *ABS* 00000000 .hidden _gp
32 # REL: Contents of section .reginfo:
33 # REL-NEXT: 0018 10000104 00000000 00000000 00000000
34 # REL-NEXT: 0028 00000000 000001ec
37 # REL: Contents of section .text:
38 # REL-NEXT: 00e0 3c080000 2108010c 8f82ff1c
41 # ^-- 8 - (0x1ec - 0x100)
44 # REL: Contents of section .data:
45 # REL-NEXT: 00f0 fffffef4
49 # ABS: 000000e0 l .text 00000000 foo
50 # ABS: 00000000 l *ABS* 00000000 .hidden _gp_disp
51 # ABS: 00000200 l *ABS* 00000000 .hidden _gp
53 # ABS: Contents of section .reginfo:
54 # ABS-NEXT: 0018 10000104 00000000 00000000 00000000
55 # ABS-NEXT: 0028 00000000 00000200
58 # ABS: Contents of section .text:
59 # ABS-NEXT: 00e0 3c080000 21080120 8f82ff08
62 # ^-- 8 - (0x200 - 0x100)
65 # ABS: Contents of section .data:
66 # ABS-NEXT: 00f0 fffffee0
72 lui $t0
, %hi
(_gp_disp
)
73 addi $t0
, $t0
, %lo
(_gp_disp
)
74 lw $v0
, %call16
(bar
)($gp
)