1# REQUIRES: mips
2# Check R_MIPS_HI16 / LO16 relocations calculation.
3
4# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
5# RUN: echo "SECTIONS { . = 0x20000; .text ALIGN(0x1000) : { *(.text) } }" > %t.script
6# RUN: ld.lld %t.o --script %t.script -o %t.exe
7# RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck %s
8
9  .text
10  .globl  __start
11__start:
12  lui    $t0,%hi(__start)
13  lui    $t1,%hi(g1)
14  addi   $t0,$t0,%lo(__start+4)
15  addi   $t0,$t0,%lo(g1+8)
16
17  lui    $t0,%hi(l1+0x10000)
18  lui    $t1,%hi(l1+0x20000)
19  addi   $t0,$t0,%lo(l1+(-4))
20
21  .data
22  .type  l1,@object
23  .size  l1,4
24l1:
25  .word 0
26
27  .globl g1
28  .type  g1,@object
29  .size  g1,4
30g1:
31  .word 0
32
33# CHECK: SYMBOL TABLE:
34# CHECK: 0021020 l     O .data   00000004 l1
35# CHECK: 0021000 g       .text   00000000 __start
36# CHECK: 0021024 g     O .data   00000004 g1
37
38# CHECK:      <__start>:
39# CHECK-NEXT:  21000:   lui    $8, 2
40#                                  ^-- %hi(__start+4)
41# CHECK-NEXT:  21004:   lui    $9, 2
42#                                  ^-- %hi(g1+8)
43# CHECK-NEXT:  21008:   addi   $8, $8, 4100
44#                                      ^-- %lo(__start+4)
45# CHECK-NEXT:  2100c:   addi   $8, $8, 4140
46#                                      ^-- %lo(g1+8)
47# CHECK-NEXT:  21010:   lui    $8, 3
48#                                  ^-- %hi(l1+0x10000-4)
49# CHECK-NEXT:  21014:   lui    $9, 4
50#                                  ^-- %hi(l1+0x20000-4)
51# CHECK-NEXT:  21018:   addi   $8, $8, 4124
52#                                      ^-- %lo(l1-4)
53