1# REQUIRES: mips
2# Check that GOT entries accessed via 16-bit indexing are allocated
3# in the beginning of the GOT.
4
5# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
6# RUN: ld.lld %t.o -o %t.exe
7# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s
8# RUN: llvm-readelf -s -A %t.exe | FileCheck -check-prefix=GOT %s
9
10# CHECK:      Disassembly of section .text:
11# CHECK-EMPTY:
12# CHECK-NEXT: <__start>:
13# CHECK-NEXT:    lui     $2, 0
14# CHECK-NEXT:    lw      $2, -32732($2)
15# CHECK-NEXT:    lui     $2, 0
16# CHECK-NEXT:    lw      $2, -32728($2)
17#
18# CHECK:      <bar>:
19# CHECK-NEXT:    lw      $2, -32736($2)
20# CHECK-NEXT:    lw      $2, -32744($2)
21# CHECK-NEXT:    addi    $2, $2, {{.*}}
22
23# GOT: Symbol table '.symtab'
24# GOT:    Num:               Value  Size Type    Bind   Vis       Ndx Name
25# GOT:           [[LOC:[0-9a-f]+]]     0 NOTYPE  LOCAL  DEFAULT     4 loc
26# GOT:         [[START:[0-9a-f]+]]     0 NOTYPE  GLOBAL DEFAULT     3 __start
27# GOT:           [[BAR:[0-9a-f]+]]     0 NOTYPE  GLOBAL DEFAULT     3 bar
28
29# GOT:      Static GOT:
30# GOT:       Local entries:
31# GOT:         Address     Access  Initial
32# GOT-NEXT:            -32744(gp) 00030000
33# GOT-NEXT:            -32740(gp) 00040000
34# GOT-NEXT:            -32736(gp) [[BAR]]
35# GOT-NEXT:            -32732(gp) [[START]]
36# GOT-NEXT:            -32728(gp) [[LOC]]
37
38  .text
39  .global __start, bar
40__start:
41  lui   $2, %got_hi(__start)
42  lw    $2, %got_lo(__start)($2)
43  lui   $2, %got_hi(loc)
44  lw    $2, %got_lo(loc)($2)
45bar:
46  lw    $2, %got(bar)($2)
47  lw    $2, %got(loc)($2)
48  addi  $2, $2, %lo(loc)
49
50  .data
51loc:
52  .word 0
53