2018-06-27 00:58:19 +08:00
|
|
|
# REQUIRES: mips
|
2016-02-11 03:57:19 +08:00
|
|
|
# Check R_MIPS_26 relocation handling.
|
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t1.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: %S/Inputs/mips-dynamic.s -o %t2.o
|
|
|
|
# RUN: ld.lld %t2.o -shared -o %t.so
|
|
|
|
# RUN: ld.lld %t1.o %t.so -o %t.exe
|
2019-09-05 21:37:16 +08:00
|
|
|
# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.exe | FileCheck %s
|
2020-03-04 11:49:14 +08:00
|
|
|
# RUN: llvm-readobj -S --dynamic-table -r -A %t.exe \
|
2016-02-11 03:57:19 +08:00
|
|
|
# RUN: | FileCheck -check-prefix=REL %s
|
|
|
|
|
|
|
|
# CHECK: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
# CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
# CHECK-NEXT: <bar>:
|
2019-09-05 21:37:16 +08:00
|
|
|
# CHECK-NEXT: [[BAR:[0-9a-f]+]]: jal 0x[[LOC:[0-9a-f]+]] <loc>
|
|
|
|
# CHECK-NEXT: {{.*}}: nop
|
2016-02-11 03:57:19 +08:00
|
|
|
#
|
2020-03-06 06:18:38 +08:00
|
|
|
# CHECK: <__start>:
|
2019-09-05 21:37:16 +08:00
|
|
|
# CHECK-NEXT: {{.*}}: jal 0x[[BAR]] <bar>
|
|
|
|
# CHECK-NEXT: {{.*}}: nop
|
|
|
|
# CHECK-NEXT: {{.*}}: jal 0x[[FOO0:[0-9a-f]+]]
|
|
|
|
# ^-- gotplt[foo0]
|
|
|
|
# CHECK-NEXT: {{.*}}: nop
|
2016-02-11 03:57:19 +08:00
|
|
|
#
|
2020-03-06 06:18:38 +08:00
|
|
|
# CHECK: <loc>:
|
2019-09-05 21:37:16 +08:00
|
|
|
# CHECK-NEXT: [[LOC]]: nop
|
2019-05-01 18:40:48 +08:00
|
|
|
# CHECK-EMPTY:
|
2016-02-11 03:57:19 +08:00
|
|
|
# CHECK-NEXT: Disassembly of section .plt:
|
2019-05-01 18:40:48 +08:00
|
|
|
# CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
# CHECK-NEXT: <.plt>:
|
2019-09-05 21:37:16 +08:00
|
|
|
# CHECK-NEXT: {{.*}}: lui $gp, 0x3
|
|
|
|
# CHECK-NEXT: {{.*}}: lw $25, {{.*}}($gp)
|
|
|
|
# CHECK-NEXT: {{.*}}: addiu $gp, $gp, {{.*}}
|
|
|
|
# CHECK-NEXT: {{.*}}: subu $24, $24, $gp
|
|
|
|
# CHECK-NEXT: {{.*}}: move $15, $ra
|
|
|
|
# CHECK-NEXT: {{.*}}: srl $24, $24, 0x2
|
|
|
|
# CHECK-NEXT: {{.*}}: jalr $25
|
|
|
|
# CHECK-NEXT: {{.*}}: addiu $24, $24, -0x2
|
|
|
|
# CHECK-NEXT: [[FOO0]]: lui $15, 0x3
|
|
|
|
# CHECK-NEXT: {{.*}}: lw $25, {{.*}}($15)
|
|
|
|
# CHECK-NEXT: {{.*}}: jr $25
|
|
|
|
# CHECK-NEXT: {{.*}}: addiu $24, $15, {{.*}}
|
2016-02-11 03:57:19 +08:00
|
|
|
|
|
|
|
# REL: Name: .plt
|
|
|
|
# REL-NEXT: Type: SHT_PROGBITS
|
|
|
|
# REL-NEXT: Flags [ (0x6)
|
|
|
|
# REL-NEXT: SHF_ALLOC
|
|
|
|
# REL-NEXT: SHF_EXECINSTR
|
|
|
|
# REL-NEXT: ]
|
|
|
|
# REL-NEXT: Address: 0x[[PLTADDR:[0-9A-F]+]]
|
|
|
|
|
|
|
|
# REL: Name: .got.plt
|
|
|
|
# REL-NEXT: Type: SHT_PROGBITS
|
|
|
|
# REL-NEXT: Flags [ (0x3)
|
|
|
|
# REL-NEXT: SHF_ALLOC
|
|
|
|
# REL-NEXT: SHF_WRITE
|
|
|
|
# REL-NEXT: ]
|
|
|
|
# REL-NEXT: Address: 0x[[GOTPLTADDR:[0-9A-F]+]]
|
|
|
|
|
2020-03-04 11:49:14 +08:00
|
|
|
# REL: 0x70000032 MIPS_PLTGOT 0x[[GOTPLTADDR]]
|
|
|
|
|
2016-02-11 03:57:19 +08:00
|
|
|
# REL: Relocations [
|
|
|
|
# REL-NEXT: Section (7) .rel.plt {
|
2020-12-10 21:12:26 +08:00
|
|
|
# REL-NEXT: 0x[[PLTSLOT:[0-9A-F]+]] R_MIPS_JUMP_SLOT foo0
|
2016-02-11 03:57:19 +08:00
|
|
|
# REL-NEXT: }
|
|
|
|
# REL-NEXT: ]
|
|
|
|
|
|
|
|
# REL: Primary GOT {
|
|
|
|
# REL: Local entries [
|
|
|
|
# REL-NEXT: ]
|
|
|
|
# REL-NEXT: Global entries [
|
|
|
|
# REL-NEXT: ]
|
|
|
|
# REL: PLT GOT {
|
|
|
|
# REL: Entries [
|
|
|
|
# REL-NEXT: Entry {
|
|
|
|
# REL-NEXT: Address: 0x[[PLTSLOT]]
|
|
|
|
# REL-NEXT: Initial: 0x[[PLTADDR]]
|
|
|
|
# REL-NEXT: Value: 0x0
|
|
|
|
# REL-NEXT: Type: Function
|
|
|
|
# REL-NEXT: Section: Undefined
|
|
|
|
# REL-NEXT: Name: foo0
|
|
|
|
# REL-NEXT: }
|
|
|
|
# REL-NEXT: ]
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl bar
|
|
|
|
bar:
|
|
|
|
jal loc # R_MIPS_26 against .text + offset
|
|
|
|
|
|
|
|
.globl __start
|
|
|
|
__start:
|
|
|
|
jal bar # R_MIPS_26 against global 'bar' from object file
|
|
|
|
jal foo0 # R_MIPS_26 against 'foo0' from DSO
|
|
|
|
|
|
|
|
loc:
|
|
|
|
nop
|