1# REQUIRES: mips 2# Check R_MIPS_26 relocation handling. 3 4# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t1.o 5# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ 6# RUN: %S/Inputs/mips-dynamic.s -o %t2.o 7# RUN: ld.lld %t2.o -shared -o %t.so 8# RUN: ld.lld %t1.o %t.so -o %t.exe 9# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.exe | FileCheck %s 10# RUN: llvm-readobj -S --dynamic-table -r -A %t.exe \ 11# RUN: | FileCheck -check-prefix=REL %s 12 13# CHECK: Disassembly of section .text: 14# CHECK-EMPTY: 15# CHECK-NEXT: <bar>: 16# CHECK-NEXT: [[BAR:[0-9a-f]+]]: jal 0x[[LOC:[0-9a-f]+]] <loc> 17# CHECK-NEXT: {{.*}}: nop 18# 19# CHECK: <__start>: 20# CHECK-NEXT: {{.*}}: jal 0x[[BAR]] <bar> 21# CHECK-NEXT: {{.*}}: nop 22# CHECK-NEXT: {{.*}}: jal 0x[[FOO0:[0-9a-f]+]] 23# ^-- gotplt[foo0] 24# CHECK-NEXT: {{.*}}: nop 25# 26# CHECK: <loc>: 27# CHECK-NEXT: [[LOC]]: nop 28# CHECK-EMPTY: 29# CHECK-NEXT: Disassembly of section .plt: 30# CHECK-EMPTY: 31# CHECK-NEXT: <.plt>: 32# CHECK-NEXT: {{.*}}: lui $gp, 0x3 33# CHECK-NEXT: {{.*}}: lw $25, {{.*}}($gp) 34# CHECK-NEXT: {{.*}}: addiu $gp, $gp, {{.*}} 35# CHECK-NEXT: {{.*}}: subu $24, $24, $gp 36# CHECK-NEXT: {{.*}}: move $15, $ra 37# CHECK-NEXT: {{.*}}: srl $24, $24, 0x2 38# CHECK-NEXT: {{.*}}: jalr $25 39# CHECK-NEXT: {{.*}}: addiu $24, $24, -0x2 40# CHECK-NEXT: [[FOO0]]: lui $15, 0x3 41# CHECK-NEXT: {{.*}}: lw $25, {{.*}}($15) 42# CHECK-NEXT: {{.*}}: jr $25 43# CHECK-NEXT: {{.*}}: addiu $24, $15, {{.*}} 44 45# REL: Name: .plt 46# REL-NEXT: Type: SHT_PROGBITS 47# REL-NEXT: Flags [ (0x6) 48# REL-NEXT: SHF_ALLOC 49# REL-NEXT: SHF_EXECINSTR 50# REL-NEXT: ] 51# REL-NEXT: Address: 0x[[PLTADDR:[0-9A-F]+]] 52 53# REL: Name: .got.plt 54# REL-NEXT: Type: SHT_PROGBITS 55# REL-NEXT: Flags [ (0x3) 56# REL-NEXT: SHF_ALLOC 57# REL-NEXT: SHF_WRITE 58# REL-NEXT: ] 59# REL-NEXT: Address: 0x[[GOTPLTADDR:[0-9A-F]+]] 60 61# REL: 0x70000032 MIPS_PLTGOT 0x[[GOTPLTADDR]] 62 63# REL: Relocations [ 64# REL-NEXT: Section (7) .rel.plt { 65# REL-NEXT: 0x[[PLTSLOT:[0-9A-F]+]] R_MIPS_JUMP_SLOT foo0 66# REL-NEXT: } 67# REL-NEXT: ] 68 69# REL: Primary GOT { 70# REL: Local entries [ 71# REL-NEXT: ] 72# REL-NEXT: Global entries [ 73# REL-NEXT: ] 74# REL: PLT GOT { 75# REL: Entries [ 76# REL-NEXT: Entry { 77# REL-NEXT: Address: 0x[[PLTSLOT]] 78# REL-NEXT: Initial: 0x[[PLTADDR]] 79# REL-NEXT: Value: 0x0 80# REL-NEXT: Type: Function 81# REL-NEXT: Section: Undefined 82# REL-NEXT: Name: foo0 83# REL-NEXT: } 84# REL-NEXT: ] 85 86 .text 87 .globl bar 88bar: 89 jal loc # R_MIPS_26 against .text + offset 90 91 .globl __start 92__start: 93 jal bar # R_MIPS_26 against global 'bar' from object file 94 jal foo0 # R_MIPS_26 against 'foo0' from DSO 95 96loc: 97 nop 98