2 # Check R_MIPS_GOT16 relocation calculation.
4 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
5 # RUN: echo "SECTIONS { \
6 # RUN: . = 0x1000; .text ALIGN(0x1000) : { *(.text) } \
7 # RUN: . = 0x3000; .data : { *(.data) } \
9 # RUN: ld.lld %t.o -shared --script %t.script -o %t.so
10 # RUN: llvm-objdump --no-print-imm-hex -d -t --no-show-raw-insn %t.so | FileCheck %s
11 # RUN: llvm-readelf -r -A %t.so | FileCheck -check-prefix=GOT %s
13 # CHECK: SYMBOL TABLE:
14 # CHECK: 00024008 l .data 00000000 .hidden bar
15 # CHECK: 00000000 *UND* 00000000 foo
18 # CHECK-NEXT: lw $8, -32744($gp)
19 # CHECK-NEXT: addi $8, $8, 8236
20 # CHECK-NEXT: lw $8, -32732($gp)
21 # CHECK-NEXT: addi $8, $8, -16384
22 # CHECK-NEXT: lw $8, -32728($gp)
23 # CHECK-NEXT: addi $8, $8, -16380
24 # CHECK-NEXT: lw $8, -32728($gp)
25 # CHECK-NEXT: addi $8, $8, 16388
26 # CHECK-NEXT: lw $8, -32720($gp)
27 # CHECK-NEXT: addi $8, $8, 16392
28 # CHECK-NEXT: lw $8, -32716($gp)
30 # GOT: There are no relocations in this file.
33 # GOT-NEXT: Access Initial
34 # GOT-NEXT: -32744(gp) 00000000
35 # ^-- (0x2000 + 0x8000) & ~0xffff
36 # GOT-NEXT: -32740(gp) 00010000
37 # ^-- redundant unused entry
38 # GOT-NEXT: -32736(gp) 00000000
39 # ^-- redundant unused entry
40 # GOT-NEXT: -32732(gp) 00010000
41 # ^-- (0x3000 + 0x9000 + 0x8000) & ~0xffff
42 # GOT-NEXT: -32728(gp) 00020000
43 # ^-- (0x3000 + 0x9000 + 0x10004 + 0x8000) & ~0xffff
44 # ^-- (0x3000 + 0x9000 + 0x18004 + 0x8000) & ~0xffff
45 # GOT-NEXT: -32724(gp) 00030000
46 # ^-- redundant unused entry
47 # GOT-NEXT: -32720(gp) 00024008
50 # GOT-NEXT: Global entries:
51 # GOT-NEXT: Access Initial Sym.Val. Type Ndx Name
52 # GOT-NEXT: -32716(gp) 00000000 00000000 NOTYPE UND foo
57 lw $t0
,%got
($LC0
)($gp
)
58 addi $t0
,$t0
,%lo
($LC0
)
59 lw $t0
,%got
($LC1
)($gp
)
60 addi $t0
,$t0
,%lo
($LC1
)
61 lw $t0
,%got
($LC1+
0x10004)($gp
)
62 addi $t0
,$t0
,%lo
($LC1+
0x10004)
63 lw $t0
,%got
($LC1+
0x18004)($gp
)
64 addi $t0
,$t0
,%lo
($LC1+
0x18004)