1# REQUIRES: mips
2
3# Check PLT entries generation in case of using N32 ABI.
4
5# RUN: echo "SECTIONS { \
6# RUN:         . = 0x10000; .text ALIGN(0x10000) : { *(.text) } \
7# RUN:         . = 0x30000; .data                : { *(.data) } \
8# RUN:       }" > %t.script
9
10# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
11# RUN:         -target-abi n32 %s -o %t1.o
12# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
13# RUN:         -target-abi n32 %S/Inputs/mips-dynamic.s -o %t2.o
14# RUN: ld.lld %t2.o -shared -soname=t.so -o %t.so
15# RUN: ld.lld %t1.o %t.so -script %t.script -o %t.exe
16# RUN: llvm-objdump -d --no-show-raw-insn %t.exe \
17# RUN:   | FileCheck %s --check-prefixes=DEFAULT,CHECK
18# RUN: ld.lld %t2.o -shared -soname=t.so -o %t.so -z hazardplt
19# RUN: ld.lld %t1.o %t.so -script %t.script -o %t.exe -z hazardplt
20# RUN: llvm-objdump -d --no-show-raw-insn %t.exe \
21# RUN:   | FileCheck %s --check-prefixes=HAZARDPLT,CHECK
22
23# CHECK:      Disassembly of section .text:
24# CHECK-EMPTY:
25# CHECK-NEXT: <__start>:
26# CHECK-NEXT:   20000:       jal     131120
27#                                    ^-- 0x20030 gotplt[foo0]
28# CHECK-NEXT:   20004:       nop
29#
30# CHECK-EMPTY:
31# CHECK-NEXT: Disassembly of section .plt:
32# CHECK-EMPTY:
33# CHECK-NEXT: <.plt>:
34# CHECK-NEXT:   20010:       lui     $14, 3
35# CHECK-NEXT:   20014:       lw      $25, 4($14)
36# CHECK-NEXT:   20018:       addiu   $14, $14, 4
37# CHECK-NEXT:   2001c:       subu    $24, $24, $14
38# CHECK-NEXT:   20020:       move    $15, $ra
39# CHECK-NEXT:   20024:       srl     $24, $24, 2
40# DEFAULT:      20028:       jalr    $25
41# HAZARDPLT:    20028:       jalr.hb $25
42# CHECK-NEXT:   2002c:       addiu   $24, $24, -2
43
44# CHECK-NEXT:   20030:       lui     $15, 3
45# CHECK-NEXT:   20034:       lw      $25, 12($15)
46# DEFAULT:      20038:       jr      $25
47# HAZARDPLT:    20038:       jr.hb   $25
48# CHECK-NEXT:   2003c:       addiu   $24, $15, 12
49
50  .text
51  .global __start
52__start:
53  jal foo0        # R_MIPS_26 against 'foo0' from DSO
54