78 lines · plain
1# REQUIRES: mips2# Check that the linker use a value of _gp symbol defined3# in a linker script to calculate GOT relocations.4 5# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o6 7# RUN: echo "SECTIONS { \8# RUN: .text : { *(.text) } \9# RUN: _gp = ABSOLUTE(.) + 0x100; \10# RUN: .got : { *(.got) } }" > %t.rel.script11# RUN: ld.lld -shared -o %t.rel.so --script %t.rel.script %t.o12# RUN: llvm-objdump -s -t %t.rel.so | FileCheck --check-prefix=REL %s13 14# RUN: echo "SECTIONS { \15# RUN: .text : { *(.text) } \16# RUN: _gp = 0x100 + ABSOLUTE(.); \17# RUN: .got : { *(.got) } }" > %t.rel.script18# RUN: ld.lld -shared -o %t.rel.so --script %t.rel.script %t.o19# RUN: llvm-objdump -s -t %t.rel.so | FileCheck --check-prefix=REL %s20 21# RUN: echo "SECTIONS { \22# RUN: .text : { *(.text) } \23# RUN: _gp = 0x200; \24# RUN: .got : { *(.got) } }" > %t.abs.script25# RUN: ld.lld -shared -o %t.abs.so --script %t.abs.script %t.o26# RUN: llvm-objdump -s -t %t.abs.so | FileCheck --check-prefix=ABS %s27 28# REL: 000000e0 l .text 00000000 foo29# REL: 00000000 l *ABS* 00000000 .hidden _gp_disp30# REL: 000001ec l *ABS* 00000000 .hidden _gp31 32# REL: Contents of section .reginfo:33# REL-NEXT: 0018 10000104 00000000 00000000 0000000034# REL-NEXT: 0028 00000000 000001ec35# ^-- _gp36 37# REL: Contents of section .text:38# REL-NEXT: 00e0 3c080000 2108010c 8f82ff1c39# ^-- %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 fffffef446# ^-- 0x30-0x1ec47# foo - GP48 49# ABS: 000000e0 l .text 00000000 foo50# ABS: 00000000 l *ABS* 00000000 .hidden _gp_disp51# ABS: 00000200 l *ABS* 00000000 .hidden _gp52 53# ABS: Contents of section .reginfo:54# ABS-NEXT: 0018 10000104 00000000 00000000 0000000055# ABS-NEXT: 0028 00000000 0000020056# ^-- _gp57 58# ABS: Contents of section .text:59# ABS-NEXT: 00e0 3c080000 21080120 8f82ff0860# ^-- %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 fffffee067# ^-- 0xe0-0x20068# foo - GP69 70 .text71foo:72 lui $t0, %hi(_gp_disp)73 addi $t0, $t0, %lo(_gp_disp)74 lw $v0, %call16(bar)($gp)75 76 .data77 .gpword foo78