1# REQUIRES: mips
2# Check less-significant bit setup for microMIPS PLT.
3
4# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
5# RUN:         -mattr=micromips %S/Inputs/mips-dynamic.s -o %t-dso.o
6# RUN: ld.lld %t-dso.o -shared -soname=t.so -o %t.so
7# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
8# RUN:         -mattr=micromips %s -o %t-exe.o
9# RUN: echo "SECTIONS { \
10# RUN:         . = 0x20000;  .text ALIGN(0x100) : { *(.text) } \
11# RUN:         . = 0x20300;  .plt : { *(.plt) } \
12# RUN:       }" > %t.script
13# RUN: ld.lld %t-exe.o %t.so --script %t.script -o %t.exe
14# RUN: llvm-readelf --symbols --dyn-syms -A %t.exe | FileCheck %s
15# RUN: llvm-objdump -d --mattr=micromips --no-show-raw-insn %t.exe \
16# RUN:   | FileCheck --check-prefix=ASM %s
17
18# CHECK: Symbol table '.dynsym'
19# CHECK:    Num:    Value  Size Type    Bind   Vis                    Ndx Name
20# CHECK:      1: 00020321     0 FUNC    GLOBAL DEFAULT [<other: 0x88>] UND foo0
21
22# CHECK: Symbol table '.symtab'
23# CHECK:    Num:    Value  Size Type    Bind   Vis                    Ndx Name
24# CHECK:      1: 00020210     0 NOTYPE  LOCAL  HIDDEN [<other: 0x82>]   8 foo
25# CHECK:      4: 00020200     0 NOTYPE  GLOBAL DEFAULT [<other: 0x80>]   8 __start
26# CHECK:      5: 00020320     0 FUNC    GLOBAL DEFAULT [<other: 0x88>] UND foo0
27
28# CHECK: Primary GOT:
29# CHECK:  Local entries:
30# CHECK:    Address     Access  Initial
31# CHECK:            -32744(gp) 00020211
32
33# CHECK: PLT GOT:
34# CHECK:  Entries:
35# CHECK:    Address  Initial Sym.Val. Type    Ndx Name
36# CHECK:            00020301 00020321 FUNC    UND foo0
37
38# ASM:      <__start>:
39# ASM-NEXT:    20200:  lw      $8, -32744($gp)
40# ASM-NEXT:            addi    $8, $8, 529
41# ASM-NEXT:            lui     $8, 2
42# ASM-NEXT:            addi    $8, $8, 801
43#
44# ASM:      <foo>:
45# ASM-NEXT:    20210:  jal     131872
46
47  .text
48  .set micromips
49  .global foo
50  .hidden foo
51  .global __start
52__start:
53  lw    $t0,%got(foo)($gp)
54  addi  $t0,$t0,%lo(foo)
55  lui   $t0,%hi(foo0)
56  addi  $t0,$t0,%lo(foo0)
57foo:
58  jal   foo0
59