1# REQUIRES: mips 2# Check that the linker use a value of _gp symbol defined 3# in a linker script to calculate GOT relocations. 4 5# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o 6 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 13 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 20 21# RUN: echo "SECTIONS { \ 22# RUN: .text : { *(.text) } \ 23# RUN: _gp = 0x200; \ 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 27 28# REL: 000000e0 l .text 00000000 foo 29# REL: 00000000 l *ABS* 00000000 .hidden _gp_disp 30# REL: 000001ec l *ABS* 00000000 .hidden _gp 31 32# REL: Contents of section .reginfo: 33# REL-NEXT: 0018 10000104 00000000 00000000 00000000 34# REL-NEXT: 0028 00000000 000001ec 35# ^-- _gp 36 37# REL: Contents of section .text: 38# REL-NEXT: 00e0 3c080000 2108010c 8f82ff1c 39# ^-- %hi(_gp_disp) 40# ^-- %lo(_gp_disp) 41# ^-- 8 - (0x1ec - 0x100) 42# G - (GP - .got) 43 44# REL: Contents of section .data: 45# REL-NEXT: 00f0 fffffef4 46# ^-- 0x30-0x1ec 47# foo - GP 48 49# ABS: 000000e0 l .text 00000000 foo 50# ABS: 00000000 l *ABS* 00000000 .hidden _gp_disp 51# ABS: 00000200 l *ABS* 00000000 .hidden _gp 52 53# ABS: Contents of section .reginfo: 54# ABS-NEXT: 0018 10000104 00000000 00000000 00000000 55# ABS-NEXT: 0028 00000000 00000200 56# ^-- _gp 57 58# ABS: Contents of section .text: 59# ABS-NEXT: 00e0 3c080000 21080120 8f82ff08 60# ^-- %hi(_gp_disp) 61# ^-- %lo(_gp_disp) 62# ^-- 8 - (0x200 - 0x100) 63# G - (GP - .got) 64 65# ABS: Contents of section .data: 66# ABS-NEXT: 00f0 fffffee0 67# ^-- 0xe0-0x200 68# foo - GP 69 70 .text 71foo: 72 lui $t0, %hi(_gp_disp) 73 addi $t0, $t0, %lo(_gp_disp) 74 lw $v0, %call16(bar)($gp) 75 76 .data 77 .gpword foo 78