2015-12-22 01:36:40 +08:00
|
|
|
# Check R_MIPS_PCxxx relocations calculation.
|
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: -mcpu=mips32r6 %s -o %t1.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: -mcpu=mips32r6 %S/Inputs/mips-dynamic.s -o %t2.o
|
|
|
|
# RUN: ld.lld %t1.o %t2.o -o %t.exe
|
2016-02-04 20:31:39 +08:00
|
|
|
# RUN: llvm-objdump -mcpu=mips32r6 -d -t -s %t.exe | FileCheck %s
|
2015-12-22 01:36:40 +08:00
|
|
|
|
|
|
|
# REQUIRES: mips
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl __start
|
|
|
|
__start:
|
|
|
|
lwpc $6, _foo # R_MIPS_PC19_S2
|
|
|
|
beqc $5, $6, _foo # R_MIPS_PC16
|
|
|
|
beqzc $9, _foo # R_MIPS_PC21_S2
|
|
|
|
bc _foo # R_MIPS_PC26_S2
|
|
|
|
aluipc $2, %pcrel_hi(_foo) # R_MIPS_PCHI16
|
|
|
|
addiu $2, $2, %pcrel_lo(_foo) # R_MIPS_PCLO16
|
|
|
|
|
2016-02-04 20:31:39 +08:00
|
|
|
.data
|
|
|
|
.word _foo+8-. # R_MIPS_PC32
|
|
|
|
|
2015-12-22 01:36:40 +08:00
|
|
|
# CHECK: Disassembly of section .text:
|
|
|
|
# CHECK-NEXT: __start:
|
|
|
|
# CHECK-NEXT: 20000: ec c8 00 08 lwpc $6, 32
|
|
|
|
# ^-- (0x20020-0x20000)>>2
|
2016-05-24 19:16:14 +08:00
|
|
|
# CHECK-NEXT: 20004: 20 a6 00 06 beqc $5, $6, 28
|
2015-12-22 01:36:40 +08:00
|
|
|
# ^-- (0x20020-4-0x20004)>>2
|
2016-05-24 19:16:14 +08:00
|
|
|
# CHECK-NEXT: 20008: d9 20 00 05 beqzc $9, 24
|
2015-12-22 01:36:40 +08:00
|
|
|
# ^-- (0x20020-4-0x20008)>>2
|
2016-05-24 19:16:14 +08:00
|
|
|
# CHECK-NEXT: 2000c: c8 00 00 04 bc 20
|
2015-12-22 01:36:40 +08:00
|
|
|
# ^-- (0x20020-4-0x2000c)>>2
|
|
|
|
# CHECK-NEXT: 20010: ec 5f 00 00 aluipc $2, 0
|
|
|
|
# ^-- %hi(0x20020-0x20010)
|
|
|
|
# CHECK-NEXT: 20014: 24 42 00 0c addiu $2, $2, 12
|
|
|
|
# ^-- %lo(0x20020-0x20014)
|
|
|
|
|
2016-02-04 20:31:39 +08:00
|
|
|
# CHECK: Contents of section .data:
|
2016-04-12 21:21:13 +08:00
|
|
|
# CHECK-NEXT: 40000 fffe0028 00000000 00000000 00000000
|
|
|
|
# ^-- 0x20020 + 8 - 0x40000
|
2016-02-04 20:31:39 +08:00
|
|
|
|
2015-12-22 01:36:40 +08:00
|
|
|
# CHECK: 00020000 .text 00000000 __start
|
|
|
|
# CHECK: 00020020 .text 00000000 _foo
|