1// RUN: llvm-mc -triple mips-unknown-linux < %s -show-encoding \
2// RUN:     | FileCheck -check-prefixes=ENCBE,FIXUP %s
3// RUN: llvm-mc -triple mipsel-unknown-linux < %s -show-encoding \
4// RUN:     | FileCheck -check-prefixes=ENCLE,FIXUP %s
5// RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux < %s \
6// RUN:     | llvm-readobj -r | FileCheck -check-prefix=RELOC %s
7// RUN: llvm-mc -filetype=obj -triple mips-unknown-linux < %s \
8// RUN:     | llvm-readobj --sections --section-data \
9// RUN:     | FileCheck -check-prefix=DATA %s
10
11// Test that we produce the correct relocation.
12// FIXME: move more relocation only tests here.
13
14// Check prefixes:
15// RELOC - Check the relocation in the object.
16// FIXUP - Check the fixup on the instruction.
17// ENCBE - Check the big-endian encoding on the instruction.
18// ENCLE - Check the little-endian encoding on the instruction.
19// ????? - Placeholder. Relocation is defined but the way of generating it is
20//         unknown.
21// FIXME - Placeholder. Generation method is known but doesn't work.
22
23// RELOC-LABEL: .rel.text {
24// DATA-LABEL: Name: .text
25// DATA:       SectionData (
26
27// DATA-NEXT:  0000: 00000004 00000000 00000004 0C000000
28        .short foo                         // RELOC: R_MIPS_16 foo
29
30        .short bar                         // RELOC: R_MIPS_16 .data
31
32baz:    .long foo                          // RELOC: R_MIPS_32 foo
33
34        .long bar                          // RELOC: R_MIPS_32 .data
35
36                                           // ?????: R_MIPS_REL32 foo
37
38        jal foo                            // RELOC: R_MIPS_26 foo
39                                           // ENCBE: jal foo # encoding: [0b000011AA,A,A,A]
40                                           // ENCLE: jal foo # encoding: [A,A,A,0b000011AA]
41                                           // FIXUP: # fixup A - offset: 0, value: foo, kind: fixup_Mips_26
42
43// The nop from the jal is at 0x0010
44// DATA-NEXT:  0010: 00000000 0C000001 00000000 24620000
45        jal baz                            // RELOC: R_MIPS_26 .text
46                                           // ENCBE: jal baz # encoding: [0b000011AA,A,A,A]
47                                           // ENCLE: jal baz # encoding: [A,A,A,0b000011AA]
48                                           // FIXUP: # fixup A - offset: 0, value: baz, kind: fixup_Mips_26
49
50        addiu $2, $3, %hi(foo)             // RELOC: R_MIPS_HI16 foo
51                                           // ENCBE: addiu $2, $3, %hi(foo) # encoding: [0x24,0x62,A,A]
52                                           // ENCLE: addiu $2, $3, %hi(foo) # encoding: [A,A,0x62,0x24]
53                                           // FIXUP: # fixup A - offset: 0, value: %hi(foo), kind: fixup_Mips_HI16
54
55// DATA-NEXT:  0020: 24620000 24620000 24620004 24620000
56        addiu $2, $3, %lo(foo)             // RELOC: R_MIPS_LO16 foo
57                                           // ENCBE: addiu $2, $3, %lo(foo) # encoding: [0x24,0x62,A,A]
58                                           // ENCLE: addiu $2, $3, %lo(foo) # encoding: [A,A,0x62,0x24]
59                                           // FIXUP: # fixup A - offset: 0, value: %lo(foo), kind: fixup_Mips_LO16
60
61        addiu $2, $3, %hi(bar)             // RELOC: R_MIPS_HI16 .data
62                                           // ENCBE: addiu $2, $3, %hi(bar) # encoding: [0x24,0x62,A,A]
63                                           // ENCLE: addiu $2, $3, %hi(bar) # encoding: [A,A,0x62,0x24]
64                                           // FIXUP: # fixup A - offset: 0, value: %hi(bar), kind: fixup_Mips_HI16
65
66        addiu $2, $3, %lo(bar)             // RELOC: R_MIPS_LO16 .data
67                                           // ENCBE: addiu $2, $3, %lo(bar) # encoding: [0x24,0x62,A,A]
68                                           // ENCLE: addiu $2, $3, %lo(bar) # encoding: [A,A,0x62,0x24]
69                                           // FIXUP: # fixup A - offset: 0, value: %lo(bar), kind: fixup_Mips_LO16
70
71        addiu $2, $3, %gp_rel(foo)         // RELOC: R_MIPS_GPREL16 foo
72                                           // ENCBE: addiu $2, $3, %gp_rel(foo) # encoding: [0x24,0x62,A,A]
73                                           // ENCLE: addiu $2, $3, %gp_rel(foo) # encoding: [A,A,0x62,0x24]
74                                           // FIXUP: # fixup A - offset: 0, value: %gp_rel(foo), kind: fixup_Mips_GPREL
75
76// DATA-NEXT:  0030: 24620004 24620000 24420000 24620000
77        addiu $2, $3, %gp_rel(bar)         // RELOC: R_MIPS_GPREL16 .data
78                                           // ENCBE: addiu $2, $3, %gp_rel(bar) # encoding: [0x24,0x62,A,A]
79                                           // ENCLE: addiu $2, $3, %gp_rel(bar) # encoding: [A,A,0x62,0x24]
80                                           // FIXUP: # fixup A - offset: 0, value: %gp_rel(bar), kind: fixup_Mips_GPREL
81
82                                           // ?????: R_MIPS_LITERAL foo
83
84        addiu $2, $3, %got(foo)            // RELOC: R_MIPS_GOT16 foo
85                                           // ENCBE: addiu $2, $3, %got(foo) # encoding: [0x24,0x62,A,A]
86                                           // ENCLE: addiu $2, $3, %got(foo) # encoding: [A,A,0x62,0x24]
87                                           // FIXUP: # fixup A - offset: 0, value: %got(foo), kind: fixup_Mips_GOT
88        // %got requires a %lo pair
89        addiu $2, $2, %lo(foo)
90
91        addiu $2, $3, %got(bar)            // RELOC: R_MIPS_GOT16 .data
92                                           // ENCBE: addiu $2, $3, %got(bar) # encoding: [0x24,0x62,A,A]
93                                           // ENCLE: addiu $2, $3, %got(bar) # encoding: [A,A,0x62,0x24]
94                                           // FIXUP: # fixup A - offset: 0, value: %got(bar), kind: fixup_Mips_GOT
95// DATA-NEXT:  0040: 24420004 0000FFBE 24620000
96        // %got requires a %lo pair
97        addiu $2, $2, %lo(bar)
98
99        .short foo-.                       // RELOC: R_MIPS_PC16 foo
100        .short baz-.                       // RELOC-NOT: R_MIPS_PC16
101
102        addiu $2, $3, %call16(foo)         // RELOC: R_MIPS_CALL16 foo
103                                           // ENCBE: addiu $2, $3, %call16(foo) # encoding: [0x24,0x62,A,A]
104                                           // ENCLE: addiu $2, $3, %call16(foo) # encoding: [A,A,0x62,0x24]
105                                           // FIXUP: # fixup A - offset: 0, value: %call16(foo), kind: fixup_Mips_CALL16
106
107	.p2align 4
108// DATA-NEXT:  0050: 00000000 00000000 00000000 00000004
109        .quad foo                          // RELOC: R_MIPS_64 foo
110        .quad bar                          // RELOC: R_MIPS_64 .data
111
112                                           // ?????: R_MIPS_GPREL32 foo
113                                           // ?????: R_MIPS_UNUSED1 foo
114                                           // ?????: R_MIPS_UNUSED2 foo
115                                           // ?????: R_MIPS_UNUSED3 foo
116                                           // ?????: R_MIPS_SHIFT5 foo
117                                           // ?????: R_MIPS_SHIFT6 foo
118
119// DATA-NEXT:  0060: 24620000 24620000 24620004 24620000
120        addiu $2, $3, %got_disp(foo)       // RELOC: R_MIPS_GOT_DISP foo
121                                           // ENCBE: addiu $2, $3, %got_disp(foo) # encoding: [0x24,0x62,A,A]
122                                           // ENCLE: addiu $2, $3, %got_disp(foo) # encoding: [A,A,0x62,0x24]
123                                           // FIXUP: # fixup A - offset: 0, value: %got_disp(foo), kind: fixup_Mips_GOT_DISP
124
125        addiu $2, $3, %got_page(foo)       // RELOC: R_MIPS_GOT_PAGE foo
126                                           // ENCBE: addiu $2, $3, %got_page(foo) # encoding: [0x24,0x62,A,A]
127                                           // ENCLE: addiu $2, $3, %got_page(foo) # encoding: [A,A,0x62,0x24]
128                                           // FIXUP: # fixup A - offset: 0, value: %got_page(foo), kind: fixup_Mips_GOT_PAGE
129
130        addiu $2, $3, %got_page(bar)       // RELOC: R_MIPS_GOT_PAGE .data
131                                           // ENCBE: addiu $2, $3, %got_page(bar) # encoding: [0x24,0x62,A,A]
132                                           // ENCLE: addiu $2, $3, %got_page(bar) # encoding: [A,A,0x62,0x24]
133                                           // FIXUP: # fixup A - offset: 0, value: %got_page(bar), kind: fixup_Mips_GOT_PAGE
134
135        addiu $2, $3, %got_ofst(foo)       // RELOC: R_MIPS_GOT_OFST foo
136                                           // ENCBE: addiu $2, $3, %got_ofst(foo) # encoding: [0x24,0x62,A,A]
137                                           // ENCLE: addiu $2, $3, %got_ofst(foo) # encoding: [A,A,0x62,0x24]
138                                           // FIXUP: # fixup A - offset: 0, value: %got_ofst(foo), kind: fixup_Mips_GOT_OFST
139
140// DATA-NEXT:  0070: 24620004 24620000 24620000 64620000
141        addiu $2, $3, %got_ofst(bar)       // RELOC: R_MIPS_GOT_OFST .data
142                                           // ENCBE: addiu $2, $3, %got_ofst(bar) # encoding: [0x24,0x62,A,A]
143                                           // ENCLE: addiu $2, $3, %got_ofst(bar) # encoding: [A,A,0x62,0x24]
144                                           // FIXUP: # fixup A - offset: 0, value: %got_ofst(bar), kind: fixup_Mips_GOT_OFST
145
146        addiu $2, $3, %got_hi(foo)         // RELOC: R_MIPS_GOT_HI16 foo
147                                           // ENCBE: addiu $2, $3, %got_hi(foo) # encoding: [0x24,0x62,A,A]
148                                           // ENCLE: addiu $2, $3, %got_hi(foo) # encoding: [A,A,0x62,0x24]
149                                           // FIXUP: # fixup A - offset: 0, value: %got_hi(foo), kind: fixup_Mips_GOT_HI16
150
151        addiu $2, $3, %got_lo(foo)         // RELOC: R_MIPS_GOT_LO16 foo
152                                           // ENCBE: addiu $2, $3, %got_lo(foo) # encoding: [0x24,0x62,A,A]
153                                           // ENCLE: addiu $2, $3, %got_lo(foo) # encoding: [A,A,0x62,0x24]
154                                           // FIXUP: # fixup A - offset: 0, value: %got_lo(foo), kind: fixup_Mips_GOT_LO16
155
156        // It turns out that %neg() isn't actually usable for anything. It's
157        // not supported in .quad and it doesn't make sense to use a 64-bit
158        // reloc on a 32-bit instruction.
159        // .quad %neg(foo)                 // ?????: R_MIPS_SUB foo
160                                           // ?????: R_MIPS_INSERT_A
161                                           // ?????: R_MIPS_INSERT_B
162                                           // ?????: R_MIPS_DELETE
163
164        .set mips64
165        daddiu $2, $3, %higher(foo)        // RELOC: R_MIPS_HIGHER foo
166                                           // ENCBE: daddiu $2, $3, %higher(foo) # encoding: [0x64,0x62,A,A]
167                                           // ENCLE: daddiu $2, $3, %higher(foo) # encoding: [A,A,0x62,0x64]
168                                           // FIXUP: # fixup A - offset: 0, value: %higher(foo), kind: fixup_Mips_HIGHER
169
170// DATA-NEXT:  0080: 64620000 24620000 24620000 00000000
171        daddiu $2, $3, %highest(foo)       // RELOC: R_MIPS_HIGHEST foo
172                                           // ENCBE: daddiu $2, $3, %highest(foo) # encoding: [0x64,0x62,A,A]
173                                           // ENCLE: daddiu $2, $3, %highest(foo) # encoding: [A,A,0x62,0x64]
174                                           // FIXUP: # fixup A - offset: 0, value: %highest(foo), kind: fixup_Mips_HIGHEST
175
176        .set mips0
177        addiu $2, $3, %call_hi(foo)        // RELOC: R_MIPS_CALL_HI16 foo
178                                           // ENCBE: addiu $2, $3, %call_hi(foo) # encoding: [0x24,0x62,A,A]
179                                           // ENCLE: addiu $2, $3, %call_hi(foo) # encoding: [A,A,0x62,0x24]
180                                           // FIXUP: # fixup A - offset: 0, value: %call_hi(foo), kind: fixup_Mips_CALL_HI16
181
182        addiu $2, $3, %call_lo(foo)        // RELOC: R_MIPS_CALL_LO16 foo
183                                           // ENCBE: addiu $2, $3, %call_lo(foo) # encoding: [0x24,0x62,A,A]
184                                           // ENCLE: addiu $2, $3, %call_lo(foo) # encoding: [A,A,0x62,0x24]
185                                           // FIXUP: # fixup A - offset: 0, value: %call_lo(foo), kind: fixup_Mips_CALL_LO16
186
187                                           // ?????: R_MIPS_SCN_DISP foo
188                                           // ?????: R_MIPS_REL16 foo
189                                           // ?????: R_MIPS_ADD_IMMEDIATE foo
190                                           // ?????: R_MIPS_PJUMP foo
191                                           // ?????: R_MIPS_RELGOT foo
192//      jalr $25                           // ?????: R_MIPS_JALR foo
193
194                                           // ?????: R_MIPS_TLS_DTPMOD32 foo
195        .dtprelword foo                    // RELOC: R_MIPS_TLS_DTPREL32 foo
196
197// DATA-NEXT:  0090: 00000000 00000000 24620000 24620000
198                                           // ?????: R_MIPS_TLS_DTPMOD64 foo
199        .dtpreldword foo                   // RELOC: R_MIPS_TLS_DTPREL64 foo
200        addiu $2, $3, %tlsgd(foo)          // RELOC: R_MIPS_TLS_GD foo
201                                           // ENCBE: addiu $2, $3, %tlsgd(foo) # encoding: [0x24,0x62,A,A]
202                                           // ENCLE: addiu $2, $3, %tlsgd(foo) # encoding: [A,A,0x62,0x24]
203                                           // FIXUP: # fixup A - offset: 0, value: %tlsgd(foo), kind: fixup_Mips_TLSGD
204
205        addiu $2, $3, %tlsldm(foo)         // RELOC: R_MIPS_TLS_LDM foo
206                                           // ENCBE: addiu $2, $3, %tlsldm(foo) # encoding: [0x24,0x62,A,A]
207                                           // ENCLE: addiu $2, $3, %tlsldm(foo) # encoding: [A,A,0x62,0x24]
208                                           // FIXUP: # fixup A - offset: 0, value: %tlsldm(foo), kind: fixup_Mips_TLSLDM
209
210// DATA-NEXT:  00A0: 24620000 24620000 24620000 00000000
211        addiu $2, $3, %dtprel_hi(foo)      // RELOC: R_MIPS_TLS_DTPREL_HI16 foo
212                                           // ENCBE: addiu $2, $3, %dtprel_hi(foo) # encoding: [0x24,0x62,A,A]
213                                           // ENCLE: addiu $2, $3, %dtprel_hi(foo) # encoding: [A,A,0x62,0x24]
214                                           // FIXUP: # fixup A - offset: 0, value: %dtprel_hi(foo), kind: fixup_Mips_DTPREL_HI
215
216        addiu $2, $3, %dtprel_lo(foo)      // RELOC: R_MIPS_TLS_DTPREL_LO16 foo
217                                           // ENCBE: addiu $2, $3, %dtprel_lo(foo) # encoding: [0x24,0x62,A,A]
218                                           // ENCLE: addiu $2, $3, %dtprel_lo(foo) # encoding: [A,A,0x62,0x24]
219                                           // FIXUP: # fixup A - offset: 0, value: %dtprel_lo(foo), kind: fixup_Mips_DTPREL_LO
220
221        addiu $2, $3, %gottprel(foo)       // RELOC: R_MIPS_TLS_GOTTPREL foo
222                                           // ENCBE: addiu $2, $3, %gottprel(foo) # encoding: [0x24,0x62,A,A]
223                                           // ENCLE: addiu $2, $3, %gottprel(foo) # encoding: [A,A,0x62,0x24]
224                                           // FIXUP: # fixup A - offset: 0, value: %gottprel(foo), kind: fixup_Mips_GOTTPREL
225
226        .tprelword foo                     // RELOC: R_MIPS_TLS_TPREL32 foo
227
228// DATA-NEXT:  00B0: 00000000 00000000 24620000 24620000
229        .tpreldword foo                    // RELOC: R_MIPS_TLS_TPREL64 foo
230        addiu $2, $3, %tprel_hi(foo)       // RELOC: R_MIPS_TLS_TPREL_HI16 foo
231                                           // ENCBE: addiu $2, $3, %tprel_hi(foo) # encoding: [0x24,0x62,A,A]
232                                           // ENCLE: addiu $2, $3, %tprel_hi(foo) # encoding: [A,A,0x62,0x24]
233                                           // FIXUP: # fixup A - offset: 0, value: %tprel_hi(foo), kind: fixup_Mips_TPREL_HI
234
235        addiu $2, $3, %tprel_lo(foo)       // RELOC: R_MIPS_TLS_TPREL_LO16 foo
236                                           // ENCBE: addiu $2, $3, %tprel_lo(foo) # encoding: [0x24,0x62,A,A]
237                                           // ENCLE: addiu $2, $3, %tprel_lo(foo) # encoding: [A,A,0x62,0x24]
238                                           // FIXUP: # fixup A - offset: 0, value: %tprel_lo(foo), kind: fixup_Mips_TPREL_LO
239
240// DATA-NEXT:  00C0: D85FFFFF CBFFFFFF EC580000 EC480000
241                                           // ?????: R_MIPS_GLOB_DAT foo
242        .set mips32r6
243        beqzc $2, foo                      // RELOC: R_MIPS_PC21_S2 foo
244                                           // ENCBE: beqzc $2, foo # encoding: [0xd8,0b010AAAAA,A,A]
245                                           // ENCLE: beqzc $2, foo # encoding: [A,A,0b010AAAAA,0xd8]
246                                           // FIXUP: # fixup A - offset: 0, value: foo-4, kind: fixup_MIPS_PC21_S2
247
248        bc foo                             // RELOC: R_MIPS_PC26_S2 foo
249                                           // ENCBE: bc foo # encoding: [0b110010AA,A,A,A]
250                                           // ENCLE: bc foo # encoding: [A,A,A,0b110010AA]
251                                           // FIXUP: # fixup A - offset: 0, value: foo-4, kind: fixup_MIPS_PC26_S2
252
253        .set mips64r6
254        ldpc $2, foo                       // RELOC: R_MIPS_PC18_S3 foo
255                                           // ENCBE: ldpc $2, foo # encoding: [0xec,0b010110AA,A,A]
256                                           // ENCLE: ldpc $2, foo # encoding: [A,A,0b010110AA,0xec]
257                                           // FIXUP: # fixup A - offset: 0, value: foo, kind: fixup_Mips_PC18_S3
258
259        .set mips32r6
260        lwpc $2, foo                       // RELOC: R_MIPS_PC19_S2 foo
261                                           // ENCBE: lwpc $2, foo # encoding: [0xec,0b01001AAA,A,A]
262                                           // ENCLE: lwpc $2, foo # encoding: [A,A,0b01001AAA,0xec]
263                                           // FIXUP: # fixup A - offset: 0, value: foo, kind: fixup_MIPS_PC19_S2
264
265// DATA-NEXT:  00D0: 24620000 24620000 00000000
266        addiu $2, $3, %pcrel_hi(foo)       // RELOC: R_MIPS_PCHI16 foo
267                                           // ENCBE: addiu $2, $3, %pcrel_hi(foo) # encoding: [0x24,0x62,A,A]
268                                           // ENCLE: addiu $2, $3, %pcrel_hi(foo) # encoding: [A,A,0x62,0x24]
269                                           // FIXUP: # fixup A - offset: 0, value: %pcrel_hi(foo), kind: fixup_MIPS_PCHI16
270
271        addiu $2, $3, %pcrel_lo(foo)       // RELOC: R_MIPS_PCLO16 foo
272                                           // ENCBE: addiu $2, $3, %pcrel_lo(foo) # encoding: [0x24,0x62,A,A]
273                                           // ENCLE: addiu $2, $3, %pcrel_lo(foo) # encoding: [A,A,0x62,0x24]
274                                           // FIXUP: # fixup A - offset: 0, value: %pcrel_lo(foo), kind: fixup_MIPS_PCLO16
275
276        .set mips0
277                                           // FIXME: R_MIPS16_*
278                                           // ?????: R_MIPS_COPY foo
279                                           // ?????: R_MIPS_JUMP_SLOT foo
280                                           // FIXME: R_MICROMIPS_*
281        .long foo-.                        // RELOC: R_MIPS_PC32 foo
282//      .ehword foo                        // FIXME: R_MIPS_EH foo
283
284	.data
285	.word 0
286bar:
287	.word 1
288
289        .section .text_mm, "ax", @progbits
290        .set micromips
291mm:
292// RELOC-LABEL: .rel.text_mm {
293// ENCBE-LABEL: mm:
294// ENCLE-LABEL: mm:
295// DATA-LABEL: Name: .text_mm
296// DATA:       SectionData (
297
298// DATA-NEXT:  0000: 30430000 30420000 30430000 30420004
299        addiu $2, $3, %got(foo_mm)         // RELOC: R_MICROMIPS_GOT16 foo_mm
300                                           // ENCBE: addiu $2, $3, %got(foo_mm) # encoding: [0x30,0x43,A,A]
301                                           // The placement of the 'A' annotations is incorrect. They use 32-bit little endian instead of 2x 16-bit little endian.
302                                           // ENCLE: addiu $2, $3, %got(foo_mm) # encoding: [0x43'A',0x30'A',0x00,0x00]
303                                           // FIXUP: # fixup A - offset: 0, value: %got(foo_mm), kind: fixup_MICROMIPS_GOT16
304        // %got requires a %lo pair
305        addiu $2, $2, %lo(foo_mm)          // RELOC: R_MICROMIPS_LO16 foo_mm
306                                           // ENCBE: addiu $2, $2, %lo(foo_mm) # encoding: [0x30,0x42,A,A]
307                                           // ENCLE: addiu $2, $2, %lo(foo_mm) # encoding: [0x42'A',0x30'A',0x00,0x00]
308                                           // FIXUP: # fixup A - offset: 0, value: %lo(foo_mm), kind: fixup_MICROMIPS_LO16
309
310foo_mm:
311        addiu $2, $3, %got(bar)            // RELOC: R_MICROMIPS_GOT16 .data
312                                           // ENCBE: addiu $2, $3, %got(bar) # encoding: [0x30,0x43,A,A]
313                                           // ENCLE: addiu $2, $3, %got(bar) # encoding: [0x43'A',0x30'A',0x00,0x00]
314                                           // FIXUP: # fixup A - offset: 0, value: %got(bar), kind: fixup_MICROMIPS_GOT16
315        // %got requires a %lo pair
316        addiu $2, $2, %lo(bar)             // RELOC: R_MICROMIPS_LO16 .data
317                                           // ENCBE: addiu $2, $2, %lo(bar) # encoding: [0x30,0x42,A,A]
318                                           // ENCLE: addiu $2, $2, %lo(bar) # encoding: [0x42'A',0x30'A',0x00,0x00]
319                                           // FIXUP: # fixup A - offset: 0, value: %lo(bar), kind: fixup_MICROMIPS_LO16
320
321// DATA-NEXT:  0010: 30430000 30420004 30430001 3042003C
322        addiu $2, $3, %got(baz)            // RELOC: R_MICROMIPS_GOT16 .text
323                                           // ENCBE: addiu $2, $3, %got(baz) # encoding: [0x30,0x43,A,A]
324                                           // The placement of the 'A' annotations is incorrect. They use 32-bit little endian instead of 2x 16-bit little endian.
325                                           // ENCLE: addiu $2, $3, %got(baz) # encoding: [0x43'A',0x30'A',0x00,0x00]
326                                           // FIXUP: # fixup A - offset: 0, value: %got(baz), kind: fixup_MICROMIPS_GOT16
327        // %got requires a %lo pair
328        addiu $2, $2, %lo(baz)             // RELOC: R_MICROMIPS_LO16 .text
329                                           // ENCBE: addiu $2, $2, %lo(baz) # encoding: [0x30,0x42,A,A]
330                                           // ENCLE: addiu $2, $2, %lo(baz) # encoding: [0x42'A',0x30'A',0x00,0x00]
331                                           // FIXUP: # fixup A - offset: 0, value: %lo(baz), kind: fixup_MICROMIPS_LO16
332
333        addiu $2, $3, %got(long_mm)        // RELOC: R_MICROMIPS_GOT16 .text
334                                           // ENCBE: addiu $2, $3, %got(long_mm) # encoding: [0x30,0x43,A,A]
335                                           // The placement of the 'A' annotations is incorrect. They use 32-bit little endian instead of 2x 16-bit little endian.
336                                           // ENCLE: addiu $2, $3, %got(long_mm) # encoding: [0x43'A',0x30'A',0x00,0x00]
337                                           // FIXUP: # fixup A - offset: 0, value: %got(long_mm), kind: fixup_MICROMIPS_GOT16
338        // %got requires a %lo pair
339        addiu $2, $2, %lo(long_mm)         // RELOC: R_MICROMIPS_LO16 .text
340                                           // ENCBE: addiu $2, $2, %lo(long_mm) # encoding: [0x30,0x42,A,A]
341                                           // ENCLE: addiu $2, $2, %lo(long_mm) # encoding: [0x42'A',0x30'A',0x00,0x00]
342                                           // FIXUP: # fixup A - offset: 0, value: %lo(long_mm), kind: fixup_MICROMIPS_LO16
343
344// DATA-NEXT:  0020: 30430004 00000000 30430004 00000000
345        addiu $2, $3, %got_page(bar)       // RELOC: R_MICROMIPS_GOT_PAGE .data
346                                           // ENCBE: addiu $2, $3, %got_page(bar) # encoding: [0x30,0x43,A,A]
347                                           // The placement of the 'A' annotations is incorrect. They use 32-bit little endian instead of 2x 16-bit little endian.
348                                           // ENCLE: addiu $2, $3, %got_page(bar) # encoding: [0x43'A',0x30'A',0x00,0x00]
349                                           // FIXUP: # fixup A - offset: 0, value: %got_page(bar), kind: fixup_MICROMIPS_GOT_PAGE
350        nop
351
352        addiu $2, $3, %got_ofst(bar)       // RELOC: R_MICROMIPS_GOT_OFST .data
353                                           // ENCBE: addiu $2, $3, %got_ofst(bar) # encoding: [0x30,0x43,A,A]
354                                           // The placement of the 'A' annotations is incorrect. They use 32-bit little endian instead of 2x 16-bit little endian.
355                                           // ENCLE: addiu $2, $3, %got_ofst(bar) # encoding: [0x43'A',0x30'A',0x00,0x00]
356                                           // FIXUP: # fixup A - offset: 0, value: %got_ofst(bar), kind: fixup_MICROMIPS_GOT_OFST
357        nop
358
359// DATA-NEXT:  0030: 30430000 30420000 30430000 30420004
360        addiu $2, $3, %hi(foo_mm)          // RELOC: R_MICROMIPS_HI16 foo_mm
361                                           // ENCBE: addiu $2, $3, %hi(foo_mm) # encoding: [0x30,0x43,A,A]
362                                           // ENCLE: addiu $2, $3, %hi(foo_mm) # encoding: [0x43'A',0x30'A',0x00,0x00]
363                                           // FIXUP: # fixup A - offset: 0, value: %hi(foo_mm), kind: fixup_MICROMIPS_HI16
364
365        addiu $2, $2, %lo(foo_mm)          // RELOC: R_MICROMIPS_LO16 foo_mm
366                                           // ENCBE: addiu $2, $2, %lo(foo_mm) # encoding: [0x30,0x42,A,A]
367                                           // ENCLE: addiu $2, $2, %lo(foo_mm) # encoding: [0x42'A',0x30'A',0x00,0x00]
368                                           // FIXUP: # fixup A - offset: 0, value: %lo(foo_mm), kind: fixup_MICROMIPS_LO16
369
370        addiu $2, $3, %hi(bar)             // RELOC: R_MICROMIPS_HI16 .data
371                                           // ENCBE: addiu $2, $3, %hi(bar) # encoding: [0x30,0x43,A,A]
372                                           // ENCLE: addiu $2, $3, %hi(bar) # encoding: [0x43'A',0x30'A',0x00,0x00]
373                                           // FIXUP: # fixup A - offset: 0, value: %hi(bar), kind: fixup_MICROMIPS_HI16
374
375        addiu $2, $2, %lo(bar)             // RELOC: R_MICROMIPS_LO16 .data
376                                           // ENCBE: addiu $2, $2, %lo(bar) # encoding: [0x30,0x42,A,A]
377                                           // ENCLE: addiu $2, $2, %lo(bar) # encoding: [0x42'A',0x30'A',0x00,0x00]
378                                           // FIXUP: # fixup A - offset: 0, value: %lo(bar), kind: fixup_MICROMIPS_LO16
379
380// DATA-NEXT:  0040: 30430000 41A50000 41A50000 00000000
381        addiu $2, $3, %gottprel(foo)       // RELOC: R_MICROMIPS_TLS_GOTTPREL foo
382                                           // ENCBE: addiu $2, $3, %gottprel(foo) # encoding: [0x30,0x43,A,A]
383                                           // ENCLE: addiu $2, $3, %gottprel(foo) # encoding: [0x43'A',0x30'A',0x00,0x00]
384                                           // FIXUP: # fixup A - offset: 0, value: %gottprel(foo), kind: fixup_MICROMIPS_GOTTPREL
385
386        lui $5, %higher(foo)               // RELOC: R_MICROMIPS_HIGHER foo
387                                           // ENCBE: lui $5, %higher(foo) # encoding: [0x41,0xa5,A,A]
388                                           // ENCLE: lui $5, %higher(foo) # encoding: [0xa5'A',0x41'A',0x00,0x00]
389                                           // FIXUP: # fixup A - offset: 0, value: %higher(foo), kind: fixup_MICROMIPS_HIGHER
390
391        lui $5, %highest(foo)              // RELOC: R_MICROMIPS_HIGHEST foo
392                                           // ENCBE: lui $5, %highest(foo) # encoding: [0x41,0xa5,A,A]
393                                           // ENCLE: lui $5, %highest(foo) # encoding: [0xa5'A',0x41'A',0x00,0x00]
394                                           // FIXUP: # fixup A - offset: 0, value: %highest(foo), kind: fixup_MICROMIPS_HIGHEST
395
396        .space 65520, 0
397long_mm:
398