]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/mips-got16.s
Vendor import of lld trunk r290819:
[FreeBSD/FreeBSD.git] / test / ELF / mips-got16.s
1 # Check R_MIPS_GOT16 relocation calculation.
2
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
7
8 # REQUIRES: mips
9
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)
23 #
24 # CHECK: SYMBOL TABLE:
25 # CHECK: 00051008         .data           00000000 .hidden bar
26 # CHECK: 00000000         *UND*           00000000 foo
27
28 # GOT:      Relocations [
29 # GOT-NEXT: ]
30
31 # GOT:      Primary GOT {
32 # GOT-NEXT:   Canonical gp value: 0x27FF0
33 # GOT-NEXT:   Reserved entries [
34 # GOT-NEXT:     Entry {
35 # GOT-NEXT:       Address: 0x20000
36 # GOT-NEXT:       Access: -32752
37 # GOT-NEXT:       Initial: 0x0
38 # GOT-NEXT:       Purpose: Lazy resolver
39 # GOT-NEXT:     }
40 # GOT-NEXT:     Entry {
41 # GOT-NEXT:       Address: 0x20004
42 # GOT-NEXT:       Access: -32748
43 # GOT-NEXT:       Initial: 0x80000000
44 # GOT-NEXT:       Purpose: Module pointer (GNU extension)
45 # GOT-NEXT:     }
46 # GOT-NEXT:   ]
47 # GOT-NEXT:   Local entries [
48 # GOT-NEXT:     Entry {
49 # GOT-NEXT:       Address: 0x20008
50 # GOT-NEXT:       Access: -32744
51 # GOT-NEXT:       Initial: 0x10000
52 #                          ^-- (0x1002c + 0x8000) & ~0xffff
53 # GOT-NEXT:     }
54 # GOT-NEXT:     Entry {
55 # GOT-NEXT:       Address: 0x2000C
56 # GOT-NEXT:       Access: -32740
57 # GOT-NEXT:       Initial: 0x20000
58 #                          ^-- redundant unused entry
59 # GOT-NEXT:     }
60 # GOT-NEXT:     Entry {
61 # GOT-NEXT:       Address: 0x20010
62 # GOT-NEXT:       Access: -32736
63 # GOT-NEXT:       Initial: 0x30000
64 #                          ^-- redundant unused entry
65 # GOT-NEXT:     }
66 # GOT-NEXT:     Entry {
67 # GOT-NEXT:       Address: 0x20014
68 # GOT-NEXT:       Access: -32732
69 # GOT-NEXT:       Initial: 0x40000
70 #                          ^-- (0x39000 + 0x8000) & ~0xffff
71 # GOT-NEXT:     }
72 # GOT-NEXT:     Entry {
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
78 # GOT-NEXT:     }
79 # GOT-NEXT:     Entry {
80 # GOT-NEXT:       Address: 0x2001C
81 # GOT-NEXT:       Access: -32724
82 # GOT-NEXT:       Initial: 0x60000
83 #                          ^-- redundant unused entry
84 # GOT-NEXT:     }
85 # GOT-NEXT:     Entry {
86 # GOT-NEXT:       Address: 0x20020
87 # GOT-NEXT:       Access: -32720
88 # GOT-NEXT:       Initial: 0x51008
89 #                          ^-- 'bar' address
90 # GOT-NEXT:     }
91 # GOT-NEXT:   ]
92 # GOT-NEXT:   Global entries [
93 # GOT-NEXT:     Entry {
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@
101 # GOT-NEXT:     }
102 # GOT-NEXT:   ]
103 # GOT-NEXT:   Number of TLS and multi-GOT entries: 0
104 # GOT-NEXT: }
105
106   .text
107   .globl  __start
108 __start:
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)
120 $LC0:
121   nop
122
123   .data
124   .space 0x9000
125 $LC1:
126   .word 0
127   .space 0x18000
128   .word 0
129 .global bar
130 .hidden bar
131 bar:
132   .word 0