1 # Check R_MIPS_GOT16 relocation calculation.
3 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
4 # RUN: ld.lld %t.o -shared -o %t.so
5 # RUN: llvm-objdump -d -t %t.so | FileCheck %s
6 # RUN: llvm-readobj -r -mips-plt-got %t.so | FileCheck -check-prefix=GOT %s
10 # CHECK: Disassembly of section .text:
11 # CHECK-NEXT: __start:
12 # CHECK-NEXT: 10000: 8f 88 80 18 lw $8, -32744($gp)
13 # CHECK-NEXT: 10004: 21 08 00 2c addi $8, $8, 44
14 # CHECK-NEXT: 10008: 8f 88 80 24 lw $8, -32732($gp)
15 # CHECK-NEXT: 1000c: 21 08 90 00 addi $8, $8, -28672
16 # CHECK-NEXT: 10010: 8f 88 80 28 lw $8, -32728($gp)
17 # CHECK-NEXT: 10014: 21 08 90 04 addi $8, $8, -28668
18 # CHECK-NEXT: 10018: 8f 88 80 28 lw $8, -32728($gp)
19 # CHECK-NEXT: 1001c: 21 08 10 04 addi $8, $8, 4100
20 # CHECK-NEXT: 10020: 8f 88 80 30 lw $8, -32720($gp)
21 # CHECK-NEXT: 10024: 21 08 10 08 addi $8, $8, 4104
22 # CHECK-NEXT: 10028: 8f 88 80 34 lw $8, -32716($gp)
24 # CHECK: SYMBOL TABLE:
25 # CHECK: 00051008 .data 00000000 .hidden bar
26 # CHECK: 00000000 *UND* 00000000 foo
32 # GOT-NEXT: Canonical gp value: 0x27FF0
33 # GOT-NEXT: Reserved entries [
35 # GOT-NEXT: Address: 0x20000
36 # GOT-NEXT: Access: -32752
37 # GOT-NEXT: Initial: 0x0
38 # GOT-NEXT: Purpose: Lazy resolver
41 # GOT-NEXT: Address: 0x20004
42 # GOT-NEXT: Access: -32748
43 # GOT-NEXT: Initial: 0x80000000
44 # GOT-NEXT: Purpose: Module pointer (GNU extension)
47 # GOT-NEXT: Local entries [
49 # GOT-NEXT: Address: 0x20008
50 # GOT-NEXT: Access: -32744
51 # GOT-NEXT: Initial: 0x10000
52 # ^-- (0x1002c + 0x8000) & ~0xffff
55 # GOT-NEXT: Address: 0x2000C
56 # GOT-NEXT: Access: -32740
57 # GOT-NEXT: Initial: 0x20000
58 # ^-- redundant unused entry
61 # GOT-NEXT: Address: 0x20010
62 # GOT-NEXT: Access: -32736
63 # GOT-NEXT: Initial: 0x30000
64 # ^-- redundant unused entry
67 # GOT-NEXT: Address: 0x20014
68 # GOT-NEXT: Access: -32732
69 # GOT-NEXT: Initial: 0x40000
70 # ^-- (0x39000 + 0x8000) & ~0xffff
73 # GOT-NEXT: Address: 0x20018
74 # GOT-NEXT: Access: -32728
75 # GOT-NEXT: Initial: 0x50000
76 # ^-- (0x39000 + 0x10004 + 0x8000) & ~0xffff
77 # ^-- (0x39000 + 0x18004 + 0x8000) & ~0xffff
80 # GOT-NEXT: Address: 0x2001C
81 # GOT-NEXT: Access: -32724
82 # GOT-NEXT: Initial: 0x60000
83 # ^-- redundant unused entry
86 # GOT-NEXT: Address: 0x20020
87 # GOT-NEXT: Access: -32720
88 # GOT-NEXT: Initial: 0x51008
92 # GOT-NEXT: Global entries [
94 # GOT-NEXT: Address: 0x20024
95 # GOT-NEXT: Access: -32716
96 # GOT-NEXT: Initial: 0x0
97 # GOT-NEXT: Value: 0x0
98 # GOT-NEXT: Type: None
99 # GOT-NEXT: Section: Undefined
100 # GOT-NEXT: Name: foo@
103 # GOT-NEXT: Number of TLS and multi-GOT entries: 0
109 lw $t0,%got($LC0)($gp)
110 addi $t0,$t0,%lo($LC0)
111 lw $t0,%got($LC1)($gp)
112 addi $t0,$t0,%lo($LC1)
113 lw $t0,%got($LC1+0x10004)($gp)
114 addi $t0,$t0,%lo($LC1+0x10004)
115 lw $t0,%got($LC1+0x18004)($gp)
116 addi $t0,$t0,%lo($LC1+0x18004)
117 lw $t0,%got(bar)($gp)
118 addi $t0,$t0,%lo(bar)
119 lw $t0,%got(foo)($gp)