xref: /llvm-project/llvm/test/tools/llvm-readobj/ELF/mips-got.test (revision 141906fa149ffaa37bb5b65e9890ab1f0f3effd5)
1## Check that we are able to dump MIPS GOT entries using -A properly.
2
3## Check how we dump 64-bit inputs.
4
5# RUN: yaml2obj --docnum=1 -DTYPE=ET_REL %s -o %t.got.o
6# RUN: yaml2obj --docnum=1 -DTYPE=ET_DYN %s -o %t.got.so
7# RUN: yaml2obj --docnum=1 -DTYPE=ET_EXEC %s -o %t.got.exe
8
9# RUN: llvm-readobj -A %t.got.o 2>&1 | FileCheck %s -DOTHERNUM=0 -check-prefix=BASIC-LLVM
10# RUN: llvm-readobj -A %t.got.so 2>&1 | FileCheck %s -DOTHERNUM=0 -check-prefix=BASIC-LLVM
11# RUN: llvm-readobj -A %t.got.exe 2>&1 | FileCheck %s -DOTHERNUM=0 -check-prefix=BASIC-LLVM
12# RUN: llvm-readelf -A %t.got.o 2>&1 | FileCheck %s -check-prefix=BASIC-GNU \
13# RUN:   --implicit-check-not="Number of" --strict-whitespace --match-full-lines
14# RUN: llvm-readelf -A %t.got.so 2>&1 | FileCheck %s -check-prefix=BASIC-GNU \
15# RUN:   --implicit-check-not="Number of" --strict-whitespace --match-full-lines
16# RUN: llvm-readelf -A %t.got.exe 2>&1 | FileCheck %s -check-prefix=BASIC-GNU \
17# RUN:   --implicit-check-not="Number of" --strict-whitespace --match-full-lines
18
19--- !ELF
20FileHeader:
21  Class:   ELFCLASS64
22  Data:    ELFDATA2LSB
23  Type:    [[TYPE=ET_EXEC]]
24  Machine: EM_MIPS
25Sections:
26  - Name:    .got
27    Type:    SHT_PROGBITS
28    Address: 0x1122
29    ContentArray: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  ## Lazy resolver.
30                    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,  ## Module pointer (GNU extension)
31                    0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,  ## Local entry 1
32                    0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  ## Local entry 2
33                    0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,  ## Global entry 1
34                    0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB ] ## Global entry 2
35    Size: [[SIZE=<none>]]
36  - Name:   .dynamic
37    Type:   SHT_DYNAMIC
38    ShType: [[DYNAMICTYPE=<none>]]
39    Entries:
40      - Tag:   DT_MIPS_LOCAL_GOTNO
41        Value: 4
42      - Tag:   DT_MIPS_GOTSYM
43        Value: 1
44      - Tag:   DT_PLTGOT
45        Value: 0x1122
46DynamicSymbols:
47  - Name: foo
48  - Name: bar
49    Type: STT_FUNC
50
51# BASIC-LLVM:      Primary GOT {
52# BASIC-LLVM-NEXT:   Canonical gp value: 0x9112
53# BASIC-LLVM-NEXT:   Reserved entries [
54# BASIC-LLVM-NEXT:     Entry {
55# BASIC-LLVM-NEXT:       Address: 0x1122
56# BASIC-LLVM-NEXT:       Access: -32752
57# BASIC-LLVM-NEXT:       Initial: 0x0
58# BASIC-LLVM-NEXT:       Purpose: Lazy resolver
59# BASIC-LLVM-NEXT:     }
60# BASIC-LLVM-NEXT:     Entry {
61# BASIC-LLVM-NEXT:       Address: 0x112A
62# BASIC-LLVM-NEXT:       Access: -32744
63# BASIC-LLVM-NEXT:       Initial: 0xFFFFFFFFFFFFFFFF
64# BASIC-LLVM-NEXT:       Purpose: Module pointer (GNU extension)
65# BASIC-LLVM-NEXT:     }
66# BASIC-LLVM-NEXT:   ]
67# BASIC-LLVM-NEXT:   Local entries [
68# BASIC-LLVM-NEXT:     Entry {
69# BASIC-LLVM-NEXT:       Address: 0x1132
70# BASIC-LLVM-NEXT:       Access: -32736
71# BASIC-LLVM-NEXT:       Initial: 0x1111111111111111
72# BASIC-LLVM-NEXT:     }
73# BASIC-LLVM-NEXT:     Entry {
74# BASIC-LLVM-NEXT:       Address: 0x113A
75# BASIC-LLVM-NEXT:       Access: -32728
76# BASIC-LLVM-NEXT:       Initial: 0x2222222222222222
77# BASIC-LLVM-NEXT:     }
78# BASIC-LLVM-NEXT:   ]
79# BASIC-LLVM-NEXT:   Global entries [
80# BASIC-LLVM-NEXT:     Entry {
81# BASIC-LLVM-NEXT:       Address: 0x1142
82# BASIC-LLVM-NEXT:       Access: -32720
83# BASIC-LLVM-NEXT:       Initial: 0xAAAAAAAAAAAAAAAA
84# BASIC-LLVM-NEXT:       Value: 0x0
85# BASIC-LLVM-NEXT:       Type: None (0x0)
86# BASIC-LLVM-NEXT:       Section: Undefined (0x0)
87# BASIC-LLVM-NEXT:       Name: foo (5)
88# BASIC-LLVM-NEXT:     }
89# BASIC-LLVM-NEXT:     Entry {
90# BASIC-LLVM-NEXT:       Address: 0x114A
91# BASIC-LLVM-NEXT:       Access: -32712
92# BASIC-LLVM-NEXT:       Initial: 0xBBBBBBBBBBBBBBBB
93# BASIC-LLVM-NEXT:       Value: 0x0
94# BASIC-LLVM-NEXT:       Type: Function (0x2)
95# BASIC-LLVM-NEXT:       Section: Undefined (0x0)
96# BASIC-LLVM-NEXT:       Name: bar (1)
97# BASIC-LLVM-NEXT:     }
98# BASIC-LLVM-NEXT:   ]
99# BASIC-LLVM-NEXT:   Number of TLS and multi-GOT entries: [[OTHERNUM]]
100# BASIC-LLVM-NEXT: }
101
102#            BASIC-GNU:Primary GOT:
103#       BASIC-GNU-NEXT: Canonical gp value: 0000000000009112
104#      BASIC-GNU-EMPTY:
105#       BASIC-GNU-NEXT: Reserved entries:
106#       BASIC-GNU-NEXT:           Address     Access          Initial Purpose
107#       BASIC-GNU-NEXT:  0000000000001122 -32752(gp) 0000000000000000 Lazy resolver
108#       BASIC-GNU-NEXT:  000000000000112a -32744(gp) ffffffffffffffff Module pointer (GNU extension)
109#      BASIC-GNU-EMPTY:
110#       BASIC-GNU-NEXT: Local entries:
111#       BASIC-GNU-NEXT:           Address     Access          Initial
112#       BASIC-GNU-NEXT:  0000000000001132 -32736(gp) 1111111111111111 {{$}}
113#       BASIC-GNU-NEXT:  000000000000113a -32728(gp) 2222222222222222 {{$}}
114#      BASIC-GNU-EMPTY:
115#       BASIC-GNU-NEXT: Global entries:
116#       BASIC-GNU-NEXT:           Address     Access          Initial         Sym.Val. Type    Ndx Name
117#       BASIC-GNU-NEXT:  0000000000001142 -32720(gp) aaaaaaaaaaaaaaaa 0000000000000000 NOTYPE  UND foo
118#       BASIC-GNU-NEXT:  000000000000114a -32712(gp) bbbbbbbbbbbbbbbb 0000000000000000 FUNC    UND bar
119#      BASIC-GNU-EMPTY:
120# BASIC-GNU-OTHER-NEXT: Number of TLS and multi-GOT entries [[OTHERNUM]]
121
122## Check we are able to print the number of TLS and multi-GOT entries properly.
123
124# RUN: yaml2obj --docnum=1 %s -DSIZE=56 -o %t.other.entries1.exe
125# RUN: yaml2obj --docnum=1 %s -DSIZE=64 -o %t.other.entries2.exe
126# RUN: llvm-readobj -A %t.other.entries1.exe 2>&1 | FileCheck %s -DOTHERNUM=1 --check-prefix=BASIC-LLVM
127# RUN: llvm-readobj -A %t.other.entries2.exe 2>&1 | FileCheck %s -DOTHERNUM=2 -check-prefix=BASIC-LLVM
128# RUN: llvm-readelf -A %t.other.entries1.exe 2>&1 | FileCheck %s -DOTHERNUM=1 \
129# RUN:   --check-prefixes=BASIC-GNU,BASIC-GNU-OTHER --strict-whitespace --match-full-lines
130# RUN: llvm-readelf -A %t.other.entries2.exe 2>&1 | FileCheck %s -DOTHERNUM=2 \
131# RUN:   --check-prefixes=BASIC-GNU,BASIC-GNU-OTHER --strict-whitespace --match-full-lines
132
133## Check how we print static GOT. Our code assumes that the GOT is static when there
134## is no .dynamic section, so we change its type to hide it.
135
136# RUN: yaml2obj --docnum=1 -DDYNAMICTYPE=SHT_PROGBITS %s -o %t.got-static.exe
137# RUN: llvm-readobj -A %t.got-static.exe | FileCheck %s --check-prefix=STATIC-GOT-LLVM
138# RUN: llvm-readelf -A %t.got-static.exe | FileCheck %s --check-prefix=STATIC-GOT-GNU
139
140# STATIC-GOT-LLVM:      Static GOT {
141# STATIC-GOT-LLVM-NEXT:   Canonical gp value: 0x9112
142# STATIC-GOT-LLVM-NEXT:   Reserved entries [
143# STATIC-GOT-LLVM-NEXT:     Entry {
144# STATIC-GOT-LLVM-NEXT:       Address: 0x1122
145# STATIC-GOT-LLVM-NEXT:       Access: -32752
146# STATIC-GOT-LLVM-NEXT:       Initial: 0x0
147# STATIC-GOT-LLVM-NEXT:       Purpose: Lazy resolver
148# STATIC-GOT-LLVM-NEXT:     }
149# STATIC-GOT-LLVM-NEXT:     Entry {
150# STATIC-GOT-LLVM-NEXT:       Address: 0x112A
151# STATIC-GOT-LLVM-NEXT:       Access: -32744
152# STATIC-GOT-LLVM-NEXT:       Initial: 0xFFFFFFFFFFFFFFFF
153# STATIC-GOT-LLVM-NEXT:       Purpose: Module pointer (GNU extension)
154# STATIC-GOT-LLVM-NEXT:     }
155# STATIC-GOT-LLVM-NEXT:   ]
156# STATIC-GOT-LLVM-NEXT:   Local entries [
157# STATIC-GOT-LLVM-NEXT:     Entry {
158# STATIC-GOT-LLVM-NEXT:       Address: 0x1132
159# STATIC-GOT-LLVM-NEXT:       Access: -32736
160# STATIC-GOT-LLVM-NEXT:       Initial: 0x1111111111111111
161# STATIC-GOT-LLVM-NEXT:     }
162# STATIC-GOT-LLVM-NEXT:     Entry {
163# STATIC-GOT-LLVM-NEXT:       Address: 0x113A
164# STATIC-GOT-LLVM-NEXT:       Access: -32728
165# STATIC-GOT-LLVM-NEXT:       Initial: 0x2222222222222222
166# STATIC-GOT-LLVM-NEXT:     }
167# STATIC-GOT-LLVM-NEXT:     Entry {
168# STATIC-GOT-LLVM-NEXT:       Address: 0x1142
169# STATIC-GOT-LLVM-NEXT:       Access: -32720
170# STATIC-GOT-LLVM-NEXT:       Initial: 0xAAAAAAAAAAAAAAAA
171# STATIC-GOT-LLVM-NEXT:     }
172# STATIC-GOT-LLVM-NEXT:     Entry {
173# STATIC-GOT-LLVM-NEXT:       Address: 0x114A
174# STATIC-GOT-LLVM-NEXT:       Access: -32712
175# STATIC-GOT-LLVM-NEXT:       Initial: 0xBBBBBBBBBBBBBBBB
176# STATIC-GOT-LLVM-NEXT:     }
177# STATIC-GOT-LLVM-NEXT:   ]
178# STATIC-GOT-LLVM-NEXT: }
179
180# STATIC-GOT-GNU:       Static GOT:
181# STATIC-GOT-GNU-NEXT:   Canonical gp value: 0000000000009112
182# STATIC-GOT-GNU-EMPTY:
183# STATIC-GOT-GNU-NEXT:   Reserved entries:
184# STATIC-GOT-GNU-NEXT:             Address     Access          Initial Purpose
185# STATIC-GOT-GNU-NEXT:    0000000000001122 -32752(gp) 0000000000000000 Lazy resolver
186# STATIC-GOT-GNU-NEXT:    000000000000112a -32744(gp) ffffffffffffffff Module pointer (GNU extension)
187# STATIC-GOT-GNU-EMPTY:
188# STATIC-GOT-GNU-NEXT:   Local entries:
189# STATIC-GOT-GNU-NEXT:             Address     Access          Initial
190# STATIC-GOT-GNU-NEXT:    0000000000001132 -32736(gp) 1111111111111111
191# STATIC-GOT-GNU-NEXT:    000000000000113a -32728(gp) 2222222222222222
192# STATIC-GOT-GNU-NEXT:    0000000000001142 -32720(gp) aaaaaaaaaaaaaaaa
193# STATIC-GOT-GNU-NEXT:    000000000000114a -32712(gp) bbbbbbbbbbbbbbbb
194# STATIC-GOT-GNU-EMPTY:
195# STATIC-GOT-GNU-NOT:   {{.}}
196
197## Check how we dump 32-bit inputs.
198
199# RUN: yaml2obj --docnum=2 %s -o %t.got32.exe
200# RUN: llvm-readobj -A %t.got32.exe 2>&1 | FileCheck %s -check-prefix=BASIC32-LLVM
201# RUN: llvm-readelf -A %t.got32.exe 2>&1 | FileCheck %s -check-prefix=BASIC32-GNU \
202# RUN:   --strict-whitespace --match-full-lines
203
204# BASIC32-LLVM:      Primary GOT {
205# BASIC32-LLVM-NEXT:   Canonical gp value: 0x9112
206# BASIC32-LLVM-NEXT:   Reserved entries [
207# BASIC32-LLVM-NEXT:     Entry {
208# BASIC32-LLVM-NEXT:       Address: 0x1122
209# BASIC32-LLVM-NEXT:       Access: -32752
210# BASIC32-LLVM-NEXT:       Initial: 0x0
211# BASIC32-LLVM-NEXT:       Purpose: Lazy resolver
212# BASIC32-LLVM-NEXT:     }
213# BASIC32-LLVM-NEXT:     Entry {
214# BASIC32-LLVM-NEXT:       Address: 0x1126
215# BASIC32-LLVM-NEXT:       Access: -32748
216# BASIC32-LLVM-NEXT:       Initial: 0xFFFFFFFF
217# BASIC32-LLVM-NEXT:       Purpose: Module pointer (GNU extension)
218# BASIC32-LLVM-NEXT:     }
219# BASIC32-LLVM-NEXT:   ]
220# BASIC32-LLVM-NEXT:   Local entries [
221# BASIC32-LLVM-NEXT:     Entry {
222# BASIC32-LLVM-NEXT:       Address: 0x112A
223# BASIC32-LLVM-NEXT:       Access: -32744
224# BASIC32-LLVM-NEXT:       Initial: 0x11111111
225# BASIC32-LLVM-NEXT:     }
226# BASIC32-LLVM-NEXT:     Entry {
227# BASIC32-LLVM-NEXT:       Address: 0x112E
228# BASIC32-LLVM-NEXT:       Access: -32740
229# BASIC32-LLVM-NEXT:       Initial: 0x22222222
230# BASIC32-LLVM-NEXT:     }
231# BASIC32-LLVM-NEXT:   ]
232# BASIC32-LLVM-NEXT:   Global entries [
233# BASIC32-LLVM-NEXT:     Entry {
234# BASIC32-LLVM-NEXT:       Address: 0x1132
235# BASIC32-LLVM-NEXT:       Access: -32736
236# BASIC32-LLVM-NEXT:       Initial: 0xAAAAAAAA
237# BASIC32-LLVM-NEXT:       Value: 0x0
238# BASIC32-LLVM-NEXT:       Type: None (0x0)
239# BASIC32-LLVM-NEXT:       Section: Undefined (0x0)
240# BASIC32-LLVM-NEXT:       Name: foo (5)
241# BASIC32-LLVM-NEXT:     }
242# BASIC32-LLVM-NEXT:     Entry {
243# BASIC32-LLVM-NEXT:       Address: 0x1136
244# BASIC32-LLVM-NEXT:       Access: -32732
245# BASIC32-LLVM-NEXT:       Initial: 0xBBBBBBBB
246# BASIC32-LLVM-NEXT:       Value: 0x0
247# BASIC32-LLVM-NEXT:       Type: Function (0x2)
248# BASIC32-LLVM-NEXT:       Section: Undefined (0x0)
249# BASIC32-LLVM-NEXT:       Name: bar (1)
250# BASIC32-LLVM-NEXT:     }
251# BASIC32-LLVM-NEXT:   ]
252# BASIC32-LLVM-NEXT:   Number of TLS and multi-GOT entries: 1
253# BASIC32-LLVM-NEXT: }
254
255#       BASIC32-GNU:Primary GOT:
256#  BASIC32-GNU-NEXT: Canonical gp value: 00009112
257# BASIC32-GNU-EMPTY:
258#  BASIC32-GNU-NEXT: Reserved entries:
259#  BASIC32-GNU-NEXT:   Address     Access  Initial Purpose
260#  BASIC32-GNU-NEXT:  00001122 -32752(gp) 00000000 Lazy resolver
261#  BASIC32-GNU-NEXT:  00001126 -32748(gp) ffffffff Module pointer (GNU extension)
262# BASIC32-GNU-EMPTY:
263#  BASIC32-GNU-NEXT: Local entries:
264#  BASIC32-GNU-NEXT:   Address     Access  Initial
265#  BASIC32-GNU-NEXT:  0000112a -32744(gp) 11111111 {{$}}
266#  BASIC32-GNU-NEXT:  0000112e -32740(gp) 22222222 {{$}}
267# BASIC32-GNU-EMPTY:
268#  BASIC32-GNU-NEXT: Global entries:
269#  BASIC32-GNU-NEXT:   Address     Access  Initial Sym.Val. Type    Ndx Name
270#  BASIC32-GNU-NEXT:  00001132 -32736(gp) aaaaaaaa 00000000 NOTYPE  UND foo
271#  BASIC32-GNU-NEXT:  00001136 -32732(gp) bbbbbbbb 00000000 FUNC    UND bar
272# BASIC32-GNU-EMPTY:
273#  BASIC32-GNU-NEXT: Number of TLS and multi-GOT entries 1
274
275--- !ELF
276FileHeader:
277  Class:   ELFCLASS32
278  Data:    ELFDATA2LSB
279  Type:    ET_EXEC
280  Machine: EM_MIPS
281Sections:
282  - Name:    .got
283    Type:    SHT_PROGBITS
284    Address: 0x1122
285    ContentArray: [ 0x00, 0x00, 0x00, 0x00,  ## Lazy resolver.
286                    0xFF, 0xFF, 0xFF, 0xFF,  ## Module pointer (GNU extension).
287                    0x11, 0x11, 0x11, 0x11,  ## Local entry 1.
288                    0x22, 0x22, 0x22, 0x22,  ## Local entry 2.
289                    0xAA, 0xAA, 0xAA, 0xAA,  ## Global entry 1.
290                    0xBB, 0xBB, 0xBB, 0xBB,  ## Global entry 2.
291                    0x00, 0x00, 0x00, 0x00 ] ## Other entry.
292  - Name: .dynamic
293    Type: SHT_DYNAMIC
294    Entries:
295      - Tag:   DT_MIPS_LOCAL_GOTNO
296        Value: 4
297      - Tag:   DT_MIPS_GOTSYM
298        Value: 1
299      - Tag:   DT_PLTGOT
300        Value: 0x1122
301DynamicSymbols:
302  - Name: foo
303  - Name: bar
304    Type: STT_FUNC
305
306## Check what we print when there are no local nor global GOT entries.
307
308# RUN: yaml2obj --docnum=3 %s -o %t.got-noentries.exe
309# RUN: llvm-readobj -A %t.got-noentries.exe | FileCheck %s --check-prefix=GOT-EMPTY-LLVM
310# RUN: llvm-readelf -A %t.got-noentries.exe | FileCheck %s --check-prefix=GOT-EMPTY-GNU
311
312# GOT-EMPTY-LLVM:      Primary GOT {
313# GOT-EMPTY-LLVM-NEXT:   Canonical gp value: 0x9112
314# GOT-EMPTY-LLVM-NEXT:   Reserved entries [
315# GOT-EMPTY-LLVM-NEXT:     Entry {
316# GOT-EMPTY-LLVM-NEXT:       Address: 0x1122
317# GOT-EMPTY-LLVM-NEXT:       Access: -32752
318# GOT-EMPTY-LLVM-NEXT:       Initial: 0x0
319# GOT-EMPTY-LLVM-NEXT:       Purpose: Lazy resolver
320# GOT-EMPTY-LLVM-NEXT:     }
321# GOT-EMPTY-LLVM-NEXT:     Entry {
322# GOT-EMPTY-LLVM-NEXT:       Address: 0x112A
323# GOT-EMPTY-LLVM-NEXT:       Access: -32744
324# GOT-EMPTY-LLVM-NEXT:       Initial: 0xFFFFFFFFFFFFFFFF
325# GOT-EMPTY-LLVM-NEXT:       Purpose: Module pointer (GNU extension)
326# GOT-EMPTY-LLVM-NEXT:     }
327# GOT-EMPTY-LLVM-NEXT:   ]
328# GOT-EMPTY-LLVM-NEXT:   Local entries [
329# GOT-EMPTY-LLVM-NEXT:   ]
330# GOT-EMPTY-LLVM-NEXT:   Global entries [
331# GOT-EMPTY-LLVM-NEXT:   ]
332# GOT-EMPTY-LLVM-NEXT:   Number of TLS and multi-GOT entries: 0
333# GOT-EMPTY-LLVM-NEXT: }
334
335# GOT-EMPTY-GNU:      Primary GOT:
336# GOT-EMPTY-GNU-NEXT:  Canonical gp value: 0000000000009112
337# GOT-EMPTY-GNU-EMPTY:
338# GOT-EMPTY-GNU-NEXT:  Reserved entries:
339# GOT-EMPTY-GNU-NEXT:            Address     Access          Initial Purpose
340# GOT-EMPTY-GNU-NEXT:   0000000000001122 -32752(gp) 0000000000000000 Lazy resolver
341# GOT-EMPTY-GNU-NEXT:   000000000000112a -32744(gp) ffffffffffffffff Module pointer (GNU extension)
342# GOT-EMPTY-GNU-NOT:  {{.}}
343
344--- !ELF
345FileHeader:
346  Class:   ELFCLASS64
347  Data:    ELFDATA2LSB
348  Type:    ET_EXEC
349  Machine: EM_MIPS
350Sections:
351  - Name:    .got
352    Type:    SHT_PROGBITS
353    Address: 0x1122
354    ContentArray: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  ## Lazy resolver.
355                    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ] ## Module pointer (GNU extension)
356    Size: [[SIZE=<none>]]
357  - Name: .dynamic
358    Type: SHT_DYNAMIC
359    Entries:
360      - Tag:   DT_MIPS_LOCAL_GOTNO
361        Value: 2
362      - Tag:   DT_MIPS_GOTSYM
363        Value: 1
364      - Tag:   DT_PLTGOT
365        Value: 0x1122
366DynamicSymbols: []
367
368## Check we report errors when dynamic tags, needed for dumping GOT, are missing.
369
370# RUN: yaml2obj --docnum=4 -DTAG1=DT_MIPS_LOCAL_GOTNO -DTAG2=DT_MIPS_GOTSYM %s -o %t.err1.o
371# RUN: llvm-readobj -A %t.err1.o 2>&1 | FileCheck %s -DFILE=%t.err1.o -check-prefixes=NO-OUTPUT,ERR1
372
373# RUN: yaml2obj --docnum=4 -DTAG1=DT_PLTGOT -DTAG2=DT_MIPS_GOTSYM %s -o %t.err2.o
374# RUN: llvm-readobj -A %t.err2.o 2>&1 | FileCheck %s -DFILE=%t.err2.o -check-prefixes=NO-OUTPUT,ERR2
375
376# RUN: yaml2obj --docnum=4 -DTAG1=DT_PLTGOT -DTAG2=DT_MIPS_LOCAL_GOTNO %s -o %t.err3.o
377# RUN: llvm-readobj -A %t.err3.o 2>&1 | FileCheck %s -DFILE=%t.err3.o -check-prefixes=NO-OUTPUT,ERR3
378
379--- !ELF
380FileHeader:
381  Class:   ELFCLASS64
382  Data:    ELFDATA2LSB
383  Type:    ET_EXEC
384  Machine: EM_MIPS
385Sections:
386  - Name: .dynamic
387    Type: SHT_DYNAMIC
388    Entries:
389      - Tag:   [[TAG1]]
390        Value: 0
391      - Tag:   [[TAG2]]
392        Value: 0
393      - Tag:   DT_NULL
394        Value: 0
395DynamicSymbols: []
396
397# RUN: yaml2obj --docnum=5 -DVAL1=0xffff %s -o %t.err4.o
398# RUN: llvm-readobj -A %t.err4.o 2>&1 | FileCheck %s -DFILE=%t.err4.o -check-prefixes=NO-OUTPUT,ERR4
399
400# RUN: yaml2obj --docnum=5 -DVAL2=0xffff %s -o %t.err5.o
401# RUN: llvm-readobj -A %t.err5.o 2>&1 | FileCheck %s -DFILE=%t.err5.o -check-prefixes=NO-OUTPUT,ERR5
402
403--- !ELF
404FileHeader:
405  Class:   ELFCLASS64
406  Data:    ELFDATA2LSB
407  Type:    ET_EXEC
408  Machine: EM_MIPS
409Sections:
410  - Name: .dynamic
411    Type: SHT_DYNAMIC
412    Entries:
413      - Tag:   DT_MIPS_LOCAL_GOTNO
414        Value: 0
415      - Tag:   DT_MIPS_GOTSYM
416        Value: [[VAL1=0]]
417      - Tag:   DT_PLTGOT
418        Value: [[VAL2=0]]
419DynamicSymbols: []
420
421# NO-OUTPUT:      LoadName: <Not found>
422# NO-OUTPUT-NEXT: There is no .MIPS.abiflags section in the file.
423# NO-OUTPUT-NEXT: There is no .MIPS.options section in the file.
424# NO-OUTPUT-NEXT: There is no .reginfo section in the file.
425
426# ERR1-NEXT: warning: '[[FILE]]': cannot find PLTGOT dynamic tag
427# ERR2-NEXT: warning: '[[FILE]]': cannot find MIPS_LOCAL_GOTNO dynamic tag
428# ERR3-NEXT: warning: '[[FILE]]': cannot find MIPS_GOTSYM dynamic tag
429# ERR4-NEXT: warning: '[[FILE]]': DT_MIPS_GOTSYM value (65535) exceeds the number of dynamic symbols (1)
430# ERR5-NEXT: warning: '[[FILE]]': there is no non-empty GOT section at 0xffff
431
432# NO-OUTPUT-EMPTY:
433# NO-OUTPUT-NOT: {{.}}
434
435## Check that we do not report a warning about the .got section when we are able to locate it by name.
436# RUN: yaml2obj --docnum=6 -DNAME=0xffff %s -o %t.err6.o
437# RUN: llvm-readobj -A %t.err6.o 2>&1 | \
438# RUN:   FileCheck %s -DFILE=%t.err6.o -check-prefix=NAME-ERR-FOUND --implicit-check-not=warning:
439# RUN: llvm-readelf -A %t.err6.o 2>&1 | \
440# RUN:   FileCheck %s -DFILE=%t.err6.o -check-prefix=NAME-ERR-FOUND --implicit-check-not=warning:
441
442# NAME-ERR-FOUND:      warning: '[[FILE]]': unable to read the name of SHT_PROGBITS section with index 1: a section [index 1] has an invalid sh_name (0xffff) offset which goes past the end of the section name string table
443# NAME-ERR-FOUND-NEXT: warning: '[[FILE]]': unable to read the name of SHT_PROGBITS section with index 3: a section [index 3] has an invalid sh_name (0xffff) offset which goes past the end of the section name string table
444
445--- !ELF
446FileHeader:
447  Class:   ELFCLASS64
448  Data:    ELFDATA2LSB
449  Type:    ET_REL
450  Machine: EM_MIPS
451Sections:
452  - Type:   SHT_PROGBITS
453    ShName: [[NAME=<none>]]
454  - Name:   .got
455    Type:   SHT_PROGBITS
456    ShName: [[GOTNAME=<none>]]
457  - Type:   SHT_PROGBITS
458    ShName: [[NAME=<none>]]
459
460## Check we report a warning when we are unable to find the .got section due to an error.
461# RUN: yaml2obj --docnum=6 -DGOTNAME=0xffff %s -o %t.err7.o
462# RUN: llvm-readelf -A %t.err7.o 2>&1 | FileCheck %s -DFILE=%t.err7.o --check-prefix=NAME-ERR-NOTFOUND --implicit-check-not=warning:
463# RUN: llvm-readobj -A %t.err7.o 2>&1 | FileCheck %s -DFILE=%t.err7.o --check-prefix=NAME-ERR-NOTFOUND --implicit-check-not=warning:
464
465# NAME-ERR-NOTFOUND:      warning: '[[FILE]]': unable to read the name of SHT_PROGBITS section with index 2: a section [index 2] has an invalid sh_name (0xffff) offset which goes past the end of the section name string table
466
467## Check that we correctly show .got section content when there are some other zero-sized
468## sections with the same address as the .got section.
469## In this test the empty .data section has the same address as the .got section.
470
471# RUN: yaml2obj --docnum=7 %s -o %t.err7.o
472# RUN: llvm-readobj -A %t.err7.o 2>&1 | FileCheck %s -DFILE=%t.err7.o --check-prefix=SAME-ADDR-LLVM
473# RUN: llvm-readelf -A %t.err7.o 2>&1 | FileCheck %s -DFILE=%t.err7.o --check-prefix=SAME-ADDR-GNU
474
475# SAME-ADDR-LLVM:      Primary GOT {
476# SAME-ADDR-LLVM-NEXT:   Canonical gp value: 0x9112
477# SAME-ADDR-LLVM-NEXT:   Reserved entries [
478# SAME-ADDR-LLVM-NEXT:     Entry {
479# SAME-ADDR-LLVM-NEXT:       Address: 0x1122
480# SAME-ADDR-LLVM-NEXT:       Access: -32752
481# SAME-ADDR-LLVM-NEXT:       Initial: 0x0
482# SAME-ADDR-LLVM-NEXT:       Purpose: Lazy resolver
483# SAME-ADDR-LLVM-NEXT:     }
484# SAME-ADDR-LLVM-NEXT:   ]
485# SAME-ADDR-LLVM-NEXT:   Local entries [
486# SAME-ADDR-LLVM-NEXT:   ]
487# SAME-ADDR-LLVM-NEXT:   Global entries [
488# SAME-ADDR-LLVM-NEXT:     Entry {
489# SAME-ADDR-LLVM-NEXT:       Address: 0x112A
490# SAME-ADDR-LLVM-NEXT:       Access: -32744
491# SAME-ADDR-LLVM-NEXT:       Initial: 0x0
492# SAME-ADDR-LLVM-NEXT:       Value: 0x0
493# SAME-ADDR-LLVM-NEXT:       Type: None (0x0)
494# SAME-ADDR-LLVM-NEXT:       Section: Undefined (0x0)
495# SAME-ADDR-LLVM-NEXT:       Name: foo (1)
496# SAME-ADDR-LLVM-NEXT:     }
497# SAME-ADDR-LLVM-NEXT:   ]
498# SAME-ADDR-LLVM-NEXT:   Number of TLS and multi-GOT entries: 0
499# SAME-ADDR-LLVM-NEXT: }
500
501# SAME-ADDR-GNU:      Primary GOT:
502# SAME-ADDR-GNU-NEXT:  Canonical gp value: 0000000000009112
503# SAME-ADDR-GNU-EMPTY:
504# SAME-ADDR-GNU-NEXT:  Reserved entries:
505# SAME-ADDR-GNU-NEXT:            Address     Access          Initial Purpose
506# SAME-ADDR-GNU-NEXT:   0000000000001122 -32752(gp) 0000000000000000 Lazy resolver
507# SAME-ADDR-GNU-EMPTY:
508# SAME-ADDR-GNU-NEXT:  Global entries:
509# SAME-ADDR-GNU-NEXT:            Address     Access          Initial         Sym.Val. Type    Ndx Name
510# SAME-ADDR-GNU-NEXT:   000000000000112a -32744(gp) 0000000000000000 0000000000000000 NOTYPE  UND foo
511
512--- !ELF
513FileHeader:
514  Class:   ELFCLASS64
515  Data:    ELFDATA2LSB
516  Type:    ET_REL
517  Machine: EM_MIPS
518Sections:
519  - Name:    .data
520    Type:    SHT_PROGBITS
521    Address: 0x1122
522    Size:    0
523  - Name:    .got
524    Type:    SHT_PROGBITS
525    Address: 0x1122
526    Size:    16
527  - Name: .dynamic
528    Type: SHT_DYNAMIC
529    Entries:
530      - Tag:   DT_MIPS_LOCAL_GOTNO
531        Value: 1
532      - Tag:   DT_MIPS_GOTSYM
533        Value: 1
534      - Tag:   DT_PLTGOT
535        Value: 0x1122
536DynamicSymbols:
537  - Name: foo
538
539## Check how we print global GOT entries when they are unnamed section symbols.
540# RUN: yaml2obj --docnum=8 %s -o %t.err8.o
541# RUN: llvm-readobj -A %t.err8.o 2>&1 | FileCheck %s -DFILE=%t.err8.o --check-prefix=SEC-SYMS-LLVM
542# RUN: llvm-readelf -A %t.err8.o 2>&1 | FileCheck %s -DFILE=%t.err8.o --check-prefix=SEC-SYMS-GNU
543
544# SEC-SYMS-LLVM:      Global entries [
545# SEC-SYMS-LLVM-NEXT:   Entry {
546# SEC-SYMS-LLVM:          Section: Absolute (0xFFF1)
547# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
548# SEC-SYMS-LLVM-NEXT:     Name: <?> (0)
549# SEC-SYMS-LLVM-NEXT:   }
550# SEC-SYMS-LLVM-NEXT:   Entry {
551# SEC-SYMS-LLVM:          Section: .got (0x1)
552# SEC-SYMS-LLVM-NEXT:     Name: .got (0)
553# SEC-SYMS-LLVM-NEXT:   }
554# SEC-SYMS-LLVM-NEXT:   Entry {
555# SEC-SYMS-LLVM:          Section: Common (0xFFF2)
556# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)
557# SEC-SYMS-LLVM-NEXT:     Name: <?> (0)
558# SEC-SYMS-LLVM-NEXT:   }
559# SEC-SYMS-LLVM-NEXT: Entry {
560# SEC-SYMS-LLVM:          Type: Section (0x3)
561# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': found an extended symbol index (4), but unable to locate the extended symbol index table
562# SEC-SYMS-LLVM-NEXT:     Section: Reserved (0xFFFF)
563# SEC-SYMS-LLVM-NEXT:     Name: <?> (0)
564# SEC-SYMS-LLVM-NEXT:   }
565# SEC-SYMS-LLVM-NEXT: ]
566
567# SEC-SYMS-GNU:      Global entries:
568# SEC-SYMS-GNU-NEXT:  {{.*}} Ndx Name
569# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)
570# SEC-SYMS-GNU-NEXT:  {{.*}} ABS <?>
571# SEC-SYMS-GNU-NEXT:  {{.*}}   1 .got
572# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)
573# SEC-SYMS-GNU-NEXT:  {{.*}} COM <?>
574# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': found an extended symbol index (4), but unable to locate the extended symbol index table
575# SEC-SYMS-GNU-NEXT:  {{.*}} RSV[0xffff] <?>
576
577--- !ELF
578FileHeader:
579  Class:   ELFCLASS64
580  Data:    ELFDATA2LSB
581  Type:    ET_REL
582  Machine: EM_MIPS
583Sections:
584  - Name:    .got
585    Type:    SHT_PROGBITS
586    Address: 0x1122
587    Size:    48
588  - Name: .dynamic
589    Type: SHT_DYNAMIC
590    Entries:
591      - Tag:   DT_MIPS_LOCAL_GOTNO
592        Value: 1
593      - Tag:   DT_MIPS_GOTSYM
594        Value: 1
595      - Tag:   DT_PLTGOT
596        Value: 0x1122
597DynamicSymbols:
598  - Type:    STT_SECTION
599    Index:   SHN_ABS
600  - Type:    STT_SECTION
601    Section: .got
602  - Type:    STT_SECTION
603    Index:   SHN_COMMON
604  - Type:    STT_SECTION
605    Index:   SHN_XINDEX
606