llvm.org GIT mirror llvm / a3f5d86
[llvm-readobj]Add additional testing for various ELF features This patch adds testing of areas of the code that are not fully tested, in particular dynamic table printing, ELF type printing, handling of edge cases where things are missing/empty (relocations/program header tables/section header table), and the --string-dump switch. Reviewed by: grimar, higuoxing, rupprecht Differential Revision: https://reviews.llvm.org/D58677 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355003 91177308-0d34-0410-b5e6-96231b3b80d8 James Henderson 1 year, 8 months ago
11 changed file(s) with 1152 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 # Show that llvm-readobj can handle an empty .dynamic section.
1
2 # RUN: yaml2obj %s -o %t.o
3 # RUN: llvm-readobj --dynamic-table %t.o | FileCheck %s --check-prefix LLVM
4 # RUN: llvm-readelf --dynamic-table %t.o | FileCheck %s --check-prefix GNU --allow-empty
5
6 # LLVM: File: {{.*}}.o
7 # LLVM-NOT: DynamicSection
8 # GNU-NOT: {{.}}
9
10 !ELF
11 FileHeader:
12 Class: ELFCLASS64
13 Data: ELFDATA2LSB
14 Type: ET_EXEC
15 Machine: EM_X86_64
16 Sections:
17 - Name: .dynamic
18 Type: SHT_DYNAMIC
19 Address: 0x1000
20 ProgramHeaders:
21 - Type: PT_LOAD
22 VAddr: 0x1000
23 Sections:
24 - Section: .dynamic
25 - Type: PT_DYNAMIC
26 VAddr: 0x1000
27 Sections:
28 - Section: .dynamic
0 # Test handling of a dynamic section size which is not a multiple of its entry size.
1 # RUN: yaml2obj %s --docnum=1 -o %t.bad-size
2 # RUN: not llvm-readobj --dynamic-table %t.bad-size 2>&1 | FileCheck %s --check-prefix ERR-SIZE
3 # RUN: not llvm-readelf --dynamic-table %t.bad-size 2>&1 | FileCheck %s --check-prefix ERR-SIZE
4
5 # ERR-SIZE: Error reading file: Invalid entity size.
6
7 --- !ELF
8 FileHeader:
9 Class: ELFCLASS64
10 Data: ELFDATA2LSB
11 Type: ET_EXEC
12 Machine: EM_X86_64
13 Sections:
14 - Name: .dynamic
15 Type: SHT_DYNAMIC
16 Address: 0x1000
17 Content: "01234567"
18 ProgramHeaders:
19 - Type: PT_LOAD
20 VAddr: 0x1000
21 Sections:
22 - Section: .dynamic
23 - Type: PT_DYNAMIC
24 VAddr: 0x1000
25 Sections:
26 - Section: .dynamic
27
28 # Test handling of a .dynamic section with an invalid entsize (i.e. not 2 * sizeof(Elf_Dyn)).
29 # RUN: yaml2obj %s --docnum=2 -o %t.bad-entsize
30 # RUN: llvm-readobj --dynamic-table %t.bad-entsize | FileCheck %s --check-prefix BAD-ENTSIZE
31 # RUN: llvm-readelf --dynamic-table %t.bad-entsize | FileCheck %s --check-prefix BAD-ENTSIZE
32
33 # BAD-ENTSIZE: DynamicSection [ (2 entries)
34 # BAD-ENTSIZE-NEXT: Tag Type Name/Value
35 # BAD-ENTSIZE-NEXT: 0x0000000000000015 DEBUG 0x0
36 # BAD-ENTSIZE-NEXT: 0x0000000000000000 NULL 0x0
37 # BAD-ENTSIZE-NEXT: ]
38
39 --- !ELF
40 FileHeader:
41 Class: ELFCLASS64
42 Data: ELFDATA2LSB
43 Type: ET_EXEC
44 Machine: EM_X86_64
45 Sections:
46 - Name: .dynamic
47 Type: SHT_DYNAMIC
48 Address: 0x1000
49 EntSize: 0x2
50 Entries:
51 - Tag: DT_DEBUG
52 Value: 0
53 - Tag: DT_NULL
54 Value: 0
55 ProgramHeaders:
56 - Type: PT_LOAD
57 VAddr: 0x1000
58 Sections:
59 - Section: .dynamic
60 - Type: PT_DYNAMIC
61 VAddr: 0x1000
62 Sections:
63 - Section: .dynamic
64
65 # Test handling of string references pointing past the end of the dynamic string table. In this case,
66 # we have a DT_NEEDED tag pointing at offset 1 in a 1-byte string table.
67 # RUN: yaml2obj %s --docnum=3 -o %t.bad-string
68 # RUN: not llvm-readobj --dynamic-table %t.bad-string 2>&1 | FileCheck %s --check-prefix BAD-STRING
69 # RUN: not llvm-readelf --dynamic-table %t.bad-string 2>&1 | FileCheck %s --check-prefix BAD-STRING
70
71 # BAD-STRING: Error reading file: Invalid dynamic string table reference.
72
73 --- !ELF
74 FileHeader:
75 Class: ELFCLASS64
76 Data: ELFDATA2LSB
77 Type: ET_EXEC
78 Machine: EM_X86_64
79 Sections:
80 - Name: .dynstr
81 Type: SHT_STRTAB
82 Address: 0x1000
83 - Name: .dynamic
84 Type: SHT_DYNAMIC
85 Address: 0x1010
86 Entries:
87 - Tag: DT_STRTAB
88 Value: 0x1000
89 - Tag: DT_STRSZ
90 Value: 1
91 - Tag: DT_NEEDED
92 Value: 1
93 - Tag: DT_NULL
94 Value: 0
95 ProgramHeaders:
96 - Type: PT_LOAD
97 VAddr: 0x1000
98 Sections:
99 - Section: .dynstr
100 - Section: .dynamic
101 - Type: PT_DYNAMIC
102 VAddr: 0x1010
103 Sections:
104 - Section: .dynamic
105
106 # Test handling of DT_STRTAB pointing outside the file's address space.
107 # RUN: yaml2obj %s --docnum=4 -o %t.bad-strtab
108 # RUN: not llvm-readobj --dynamic-table %t.bad-strtab 2>&1 | FileCheck %s --check-prefix BAD-STRTAB
109 # RUN: not llvm-readelf --dynamic-table %t.bad-strtab 2>&1 | FileCheck %s --check-prefix BAD-STRTAB
110
111 # BAD-STRTAB: LLVM ERROR: Virtual address is not in any segment
112
113 --- !ELF
114 FileHeader:
115 Class: ELFCLASS64
116 Data: ELFDATA2LSB
117 Type: ET_EXEC
118 Machine: EM_X86_64
119 Sections:
120 - Name: .dynamic
121 Type: SHT_DYNAMIC
122 Address: 0x1000
123 Entries:
124 - Tag: DT_STRTAB
125 Value: 0x2000000
126 - Tag: DT_STRSZ
127 Value: 10
128 - Tag: DT_NEEDED
129 Value: 1
130 - Tag: DT_NULL
131 Value: 0x0
132 ProgramHeaders:
133 - Type: PT_LOAD
134 VAddr: 0x1000
135 Sections:
136 - Section: .dynamic
137 - Type: PT_DYNAMIC
138 VAddr: 0x1000
139 Sections:
140 - Section: .dynamic
141
142 # Test handling of other d_ptr tags pointing outside the file's address space.
143 # RUN: yaml2obj %s --docnum=5 -o %t.bad-rela
144 # RUN: not llvm-readobj --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefix BAD-RELA
145 # RUN: not llvm-readelf --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefix BAD-RELA
146
147 # BAD-RELA: LLVM ERROR: Virtual address is not in any segment
148
149 --- !ELF
150 FileHeader:
151 Class: ELFCLASS64
152 Data: ELFDATA2LSB
153 Type: ET_EXEC
154 Machine: EM_X86_64
155 Sections:
156 - Name: .dynamic
157 Type: SHT_DYNAMIC
158 Address: 0x1000
159 Entries:
160 - Tag: DT_RELA
161 Value: 0x1000000
162 - Tag: DT_NULL
163 Value: 0x0
164 ProgramHeaders:
165 - Type: PT_LOAD
166 VAddr: 0x1000
167 Sections:
168 - Section: .dynamic
169 - Type: PT_DYNAMIC
170 VAddr: 0x1000
171 Sections:
172 - Section: .dynamic
0 # Show that no dumping occurs if there is no PT_DYNAMIC header.
1 # RUN: yaml2obj %s -o %t.no-phdr
2 # RUN: llvm-readobj --dynamic-table %t.no-phdr | FileCheck %s --check-prefix=LLVM
3 # RUN: llvm-readelf --dynamic-table %t.no-phdr | FileCheck %s --check-prefix=GNU --allow-empty
4
5 # LLVM: File: {{.*}}.no-phdr
6 # LLVM-NEXT: Format: ELF64-x86-64
7 # LLVM-NEXT: Arch: x86_64
8 # LLVM-NEXT: AddressSize: 64bit
9 # LLVM-NEXT: LoadName:{{ *}}
10 # LLVM-NOT: {{.}}
11
12 # GNU-NOT: {{.}}
13
14 --- !ELF
15 FileHeader:
16 Class: ELFCLASS64
17 Data: ELFDATA2LSB
18 Type: ET_EXEC
19 Machine: EM_X86_64
20 Sections:
21 - Name: .dynamic
22 Type: SHT_DYNAMIC
23 Address: 0x1000
24 Entries:
25 - Tag: DT_NULL
26 Value: 0
27 ProgramHeaders:
28 - Type: PT_LOAD
29 VAddr: 0x1000
30 Sections:
31 - Section: .dynamic
0 # Test that hexagon machine-specific tags can be dumped.
1 # RUN: yaml2obj --docnum=1 %s -o %t.hex
2 # RUN: llvm-readobj --dynamic-table %t.hex | FileCheck %s --check-prefix=LLVM-HEXAGON
3 # RUN: llvm-readelf --dynamic-table %t.hex | FileCheck %s --check-prefix=GNU-HEXAGON
4
5 --- !ELF
6 FileHeader:
7 Class: ELFCLASS64
8 Data: ELFDATA2LSB
9 Type: ET_EXEC
10 Machine: EM_HEXAGON
11 Sections:
12 - Name: .dynstr
13 Type: SHT_STRTAB
14 Address: 0x1000
15 Size: 0x10
16 Content: "004400550066007700"
17 - Name: .dynamic
18 Type: SHT_DYNAMIC
19 Address: 0x1010
20 Entries:
21 - Tag: DT_HEXAGON_SYMSZ
22 Value: 0x10
23 - Tag: DT_HEXAGON_VER
24 Value: 0x1000
25 - Tag: DT_HEXAGON_PLT
26 Value: 0x1000
27 - Tag: DT_NULL
28 Value: 0
29 ProgramHeaders:
30 - Type: PT_LOAD
31 VAddr: 0x1000
32 Sections:
33 - Section: .dynstr
34 - Section: .dynamic
35 - Type: PT_DYNAMIC
36 VAddr: 0x1010
37 Sections:
38 - Section: .dynamic
39
40 # LLVM-HEXAGON: DynamicSection [ (4 entries)
41 # LLVM-HEXAGON-NEXT: Tag Type Name/Value
42 # LLVM-HEXAGON-NEXT: 0x0000000070000000 HEXAGON_SYMSZ 0x10
43 # LLVM-HEXAGON-NEXT: 0x0000000070000001 HEXAGON_VER 4096
44 # LLVM-HEXAGON-NEXT: 0x0000000070000002 HEXAGON_PLT 0x1000
45 # LLVM-HEXAGON-NEXT: 0x0000000000000000 NULL 0x0
46 # LLVM-HEXAGON-NEXT: ]
47
48 # GNU-HEXAGON: DynamicSection [ (4 entries)
49 # GNU-HEXAGON-NEXT: Tag Type Name/Value
50 # GNU-HEXAGON-NEXT: 0x0000000070000000 HEXAGON_SYMSZ 0x10
51 # GNU-HEXAGON-NEXT: 0x0000000070000001 HEXAGON_VER 4096
52 # GNU-HEXAGON-NEXT: 0x0000000070000002 HEXAGON_PLT 0x1000
53 # GNU-HEXAGON-NEXT: 0x0000000000000000 NULL 0x0
54 # GNU-HEXAGON-NEXT: ]
55
56 # Test that MIPS machine-specific tags can be dumped.
57 # RUN: yaml2obj --docnum=2 %s -o %t.mips
58 # RUN: llvm-readobj --dynamic-table %t.mips | FileCheck %s --check-prefix=LLVM-MIPS
59 # RUN: llvm-readelf --dynamic-table %t.mips | FileCheck %s --check-prefix=GNU-MIPS
60
61 # LLVM-MIPS: DynamicSection [ (46 entries)
62 # LLVM-MIPS-NEXT: Tag Type Name/Value
63 # LLVM-MIPS-NEXT: 0x0000000070000001 MIPS_RLD_VERSION 305419896
64 # LLVM-MIPS-NEXT: 0x0000000070000002 MIPS_TIME_STAMP 0x11223344
65 # LLVM-MIPS-NEXT: 0x0000000070000003 MIPS_ICHECKSUM 0x11112222
66 # LLVM-MIPS-NEXT: 0x0000000070000004 MIPS_IVERSION 0x1
67 # LLVM-MIPS-NEXT: 0x0000000070000005 MIPS_FLAGS QUICKSTART SGI_ONLY PIXIE CORD
68 # LLVM-MIPS-NEXT: 0x0000000070000006 MIPS_BASE_ADDRESS 0x87654321
69 # LLVM-MIPS-NEXT: 0x0000000070000007 MIPS_MSYM 0x1000
70 # LLVM-MIPS-NEXT: 0x0000000070000008 MIPS_CONFLICT 0x1000
71 # LLVM-MIPS-NEXT: 0x0000000070000009 MIPS_LIBLIST 0x1000
72 # LLVM-MIPS-NEXT: 0x000000007000000A MIPS_LOCAL_GOTNO 1
73 # LLVM-MIPS-NEXT: 0x000000007000000B MIPS_CONFLICTNO 0x1
74 # LLVM-MIPS-NEXT: 0x0000000070000010 MIPS_LIBLISTNO 0x1
75 # LLVM-MIPS-NEXT: 0x0000000070000011 MIPS_SYMTABNO 1
76 # LLVM-MIPS-NEXT: 0x0000000070000012 MIPS_UNREFEXTNO 0
77 # LLVM-MIPS-NEXT: 0x0000000070000013 MIPS_GOTSYM 0x0
78 # LLVM-MIPS-NEXT: 0x0000000070000014 MIPS_HIPAGENO 0x88776655
79 # LLVM-MIPS-NEXT: 0x0000000070000016 MIPS_RLD_MAP 0x1000
80 # LLVM-MIPS-NEXT: 0x0000000070000017 MIPS_DELTA_CLASS 0x1000
81 # LLVM-MIPS-NEXT: 0x0000000070000018 MIPS_DELTA_CLASS_NO 0x1
82 # LLVM-MIPS-NEXT: 0x0000000070000019 MIPS_DELTA_INSTANCE 0x1000
83 # LLVM-MIPS-NEXT: 0x000000007000001A MIPS_DELTA_INSTANCE_NO0x1
84 # LLVM-MIPS-NEXT: 0x000000007000001B MIPS_DELTA_RELOC 0x1000
85 # LLVM-MIPS-NEXT: 0x000000007000001C MIPS_DELTA_RELOC_NO 0x1
86 # LLVM-MIPS-NEXT: 0x000000007000001D MIPS_DELTA_SYM 0x1000
87 # LLVM-MIPS-NEXT: 0x000000007000001E MIPS_DELTA_SYM_NO 0x1
88 # LLVM-MIPS-NEXT: 0x0000000070000020 MIPS_DELTA_CLASSSYM 0x1000
89 # LLVM-MIPS-NEXT: 0x0000000070000021 MIPS_DELTA_CLASSSYM_NO0x1
90 # LLVM-MIPS-NEXT: 0x0000000070000022 MIPS_CXX_FLAGS 0x88887777
91 # LLVM-MIPS-NEXT: 0x0000000070000023 MIPS_PIXIE_INIT 0x1000
92 # LLVM-MIPS-NEXT: 0x0000000070000025 MIPS_LOCALPAGE_GOTIDX0x1
93 # LLVM-MIPS-NEXT: 0x0000000070000026 MIPS_LOCAL_GOTIDX 0x1
94 # LLVM-MIPS-NEXT: 0x0000000070000027 MIPS_HIDDEN_GOTIDX 0x1
95 # LLVM-MIPS-NEXT: 0x0000000070000028 MIPS_PROTECTED_GOTIDX0x1
96 # LLVM-MIPS-NEXT: 0x0000000070000029 MIPS_OPTIONS 0x1000
97 # LLVM-MIPS-NEXT: 0x000000007000002A MIPS_INTERFACE 0x1000
98 # LLVM-MIPS-NEXT: 0x000000007000002B MIPS_DYNSTR_ALIGN 0x88888888
99 # LLVM-MIPS-NEXT: 0x000000007000002C MIPS_INTERFACE_SIZE 0x10
100 # LLVM-MIPS-NEXT: 0x000000007000002D MIPS_RLD_TEXT_RESOLVE_ADDR0x8
101 # LLVM-MIPS-NEXT: 0x000000007000002E MIPS_PERF_SUFFIX 0x0
102 # LLVM-MIPS-NEXT: 0x000000007000002F MIPS_COMPACT_SIZE 0x10
103 # LLVM-MIPS-NEXT: 0x0000000070000030 MIPS_GP_VALUE 0x1
104 # LLVM-MIPS-NEXT: 0x0000000070000031 MIPS_AUX_DYNAMIC 0x1000
105 # LLVM-MIPS-NEXT: 0x0000000070000032 MIPS_PLTGOT 0x1000
106 # LLVM-MIPS-NEXT: 0x0000000070000034 MIPS_RWPLT 0x1000
107 # LLVM-MIPS-NEXT: 0x0000000070000035 MIPS_RLD_MAP_REL 0x1000
108 # LLVM-MIPS-NEXT: 0x0000000000000000 NULL 0x0
109 # LLVM-MIPS-NEXT: ]
110
111 # GNU-MIPS: DynamicSection [ (46 entries)
112 # GNU-MIPS-NEXT: Tag Type Name/Value
113 # GNU-MIPS-NEXT: 0x0000000070000001 MIPS_RLD_VERSION 305419896
114 # GNU-MIPS-NEXT: 0x0000000070000002 MIPS_TIME_STAMP 0x11223344
115 # GNU-MIPS-NEXT: 0x0000000070000003 MIPS_ICHECKSUM 0x11112222
116 # GNU-MIPS-NEXT: 0x0000000070000004 MIPS_IVERSION 0x1
117 # GNU-MIPS-NEXT: 0x0000000070000005 MIPS_FLAGS QUICKSTART SGI_ONLY PIXIE CORD
118 # GNU-MIPS-NEXT: 0x0000000070000006 MIPS_BASE_ADDRESS 0x87654321
119 # GNU-MIPS-NEXT: 0x0000000070000007 MIPS_MSYM 0x1000
120 # GNU-MIPS-NEXT: 0x0000000070000008 MIPS_CONFLICT 0x1000
121 # GNU-MIPS-NEXT: 0x0000000070000009 MIPS_LIBLIST 0x1000
122 # GNU-MIPS-NEXT: 0x000000007000000a MIPS_LOCAL_GOTNO 1
123 # GNU-MIPS-NEXT: 0x000000007000000b MIPS_CONFLICTNO 0x1
124 # GNU-MIPS-NEXT: 0x0000000070000010 MIPS_LIBLISTNO 0x1
125 # GNU-MIPS-NEXT: 0x0000000070000011 MIPS_SYMTABNO 1
126 # GNU-MIPS-NEXT: 0x0000000070000012 MIPS_UNREFEXTNO 0
127 # GNU-MIPS-NEXT: 0x0000000070000013 MIPS_GOTSYM 0x0
128 # GNU-MIPS-NEXT: 0x0000000070000014 MIPS_HIPAGENO 0x88776655
129 # GNU-MIPS-NEXT: 0x0000000070000016 MIPS_RLD_MAP 0x1000
130 # GNU-MIPS-NEXT: 0x0000000070000017 MIPS_DELTA_CLASS 0x1000
131 # GNU-MIPS-NEXT: 0x0000000070000018 MIPS_DELTA_CLASS_NO 0x1
132 # GNU-MIPS-NEXT: 0x0000000070000019 MIPS_DELTA_INSTANCE 0x1000
133 # GNU-MIPS-NEXT: 0x000000007000001a MIPS_DELTA_INSTANCE_NO0x1
134 # GNU-MIPS-NEXT: 0x000000007000001b MIPS_DELTA_RELOC 0x1000
135 # GNU-MIPS-NEXT: 0x000000007000001c MIPS_DELTA_RELOC_NO 0x1
136 # GNU-MIPS-NEXT: 0x000000007000001d MIPS_DELTA_SYM 0x1000
137 # GNU-MIPS-NEXT: 0x000000007000001e MIPS_DELTA_SYM_NO 0x1
138 # GNU-MIPS-NEXT: 0x0000000070000020 MIPS_DELTA_CLASSSYM 0x1000
139 # GNU-MIPS-NEXT: 0x0000000070000021 MIPS_DELTA_CLASSSYM_NO0x1
140 # GNU-MIPS-NEXT: 0x0000000070000022 MIPS_CXX_FLAGS 0x88887777
141 # GNU-MIPS-NEXT: 0x0000000070000023 MIPS_PIXIE_INIT 0x1000
142 # GNU-MIPS-NEXT: 0x0000000070000025 MIPS_LOCALPAGE_GOTIDX0x1
143 # GNU-MIPS-NEXT: 0x0000000070000026 MIPS_LOCAL_GOTIDX 0x1
144 # GNU-MIPS-NEXT: 0x0000000070000027 MIPS_HIDDEN_GOTIDX 0x1
145 # GNU-MIPS-NEXT: 0x0000000070000028 MIPS_PROTECTED_GOTIDX0x1
146 # GNU-MIPS-NEXT: 0x0000000070000029 MIPS_OPTIONS 0x1000
147 # GNU-MIPS-NEXT: 0x000000007000002a MIPS_INTERFACE 0x1000
148 # GNU-MIPS-NEXT: 0x000000007000002b MIPS_DYNSTR_ALIGN 0x88888888
149 # GNU-MIPS-NEXT: 0x000000007000002c MIPS_INTERFACE_SIZE 0x10
150 # GNU-MIPS-NEXT: 0x000000007000002d MIPS_RLD_TEXT_RESOLVE_ADDR0x8
151 # GNU-MIPS-NEXT: 0x000000007000002e MIPS_PERF_SUFFIX 0x0
152 # GNU-MIPS-NEXT: 0x000000007000002f MIPS_COMPACT_SIZE 0x10
153 # GNU-MIPS-NEXT: 0x0000000070000030 MIPS_GP_VALUE 0x1
154 # GNU-MIPS-NEXT: 0x0000000070000031 MIPS_AUX_DYNAMIC 0x1000
155 # GNU-MIPS-NEXT: 0x0000000070000032 MIPS_PLTGOT 0x1000
156 # GNU-MIPS-NEXT: 0x0000000070000034 MIPS_RWPLT 0x1000
157 # GNU-MIPS-NEXT: 0x0000000070000035 MIPS_RLD_MAP_REL 0x1000
158 # GNU-MIPS-NEXT: 0x0000000000000000 NULL 0x0
159 # GNU-MIPS-NEXT: ]
160
161 --- !ELF
162 FileHeader:
163 Class: ELFCLASS64
164 Data: ELFDATA2LSB
165 Type: ET_EXEC
166 Machine: EM_MIPS
167 Sections:
168 - Name: .dynstr
169 Type: SHT_STRTAB
170 Address: 0x1000
171 Size: 0x10
172 Content: "004400550066007700"
173 - Name: .dynamic
174 Type: SHT_DYNAMIC
175 Address: 0x1010
176 Entries:
177 - Tag: DT_MIPS_RLD_VERSION
178 Value: 0x12345678
179 - Tag: DT_MIPS_TIME_STAMP
180 Value: 0x11223344
181 - Tag: DT_MIPS_ICHECKSUM
182 Value: 0x11112222
183 - Tag: DT_MIPS_IVERSION
184 Value: 0x1
185 - Tag: DT_MIPS_FLAGS
186 Value: 0x11111111
187 - Tag: DT_MIPS_BASE_ADDRESS
188 Value: 0x87654321
189 - Tag: DT_MIPS_MSYM
190 Value: 0x1000
191 - Tag: DT_MIPS_CONFLICT
192 Value: 0x1000
193 - Tag: DT_MIPS_LIBLIST
194 Value: 0x1000
195 - Tag: DT_MIPS_LOCAL_GOTNO
196 Value: 0x1
197 - Tag: DT_MIPS_CONFLICTNO
198 Value: 0x1
199 - Tag: DT_MIPS_LIBLISTNO
200 Value: 0x1
201 - Tag: DT_MIPS_SYMTABNO
202 Value: 0x1
203 - Tag: DT_MIPS_UNREFEXTNO
204 Value: 0x0
205 - Tag: DT_MIPS_GOTSYM
206 Value: 0x0
207 - Tag: DT_MIPS_HIPAGENO
208 Value: 0x88776655
209 - Tag: DT_MIPS_RLD_MAP
210 Value: 0x1000
211 - Tag: DT_MIPS_DELTA_CLASS
212 Value: 0x1000
213 - Tag: DT_MIPS_DELTA_CLASS_NO
214 Value: 0x1
215 - Tag: DT_MIPS_DELTA_INSTANCE
216 Value: 0x1000
217 - Tag: DT_MIPS_DELTA_INSTANCE_NO
218 Value: 0x1
219 - Tag: DT_MIPS_DELTA_RELOC
220 Value: 0x1000
221 - Tag: DT_MIPS_DELTA_RELOC_NO
222 Value: 0x1
223 - Tag: DT_MIPS_DELTA_SYM
224 Value: 0x1000
225 - Tag: DT_MIPS_DELTA_SYM_NO
226 Value: 0x1
227 - Tag: DT_MIPS_DELTA_CLASSSYM
228 Value: 0x1000
229 - Tag: DT_MIPS_DELTA_CLASSSYM_NO
230 Value: 0x1
231 - Tag: DT_MIPS_CXX_FLAGS
232 Value: 0x88887777
233 - Tag: DT_MIPS_PIXIE_INIT
234 Value: 0x1000
235 - Tag: DT_MIPS_LOCALPAGE_GOTIDX
236 Value: 0x1
237 - Tag: DT_MIPS_LOCAL_GOTIDX
238 Value: 0x1
239 - Tag: DT_MIPS_HIDDEN_GOTIDX
240 Value: 0x1
241 - Tag: DT_MIPS_PROTECTED_GOTIDX
242 Value: 0x1
243 - Tag: DT_MIPS_OPTIONS
244 Value: 0x1000
245 - Tag: DT_MIPS_INTERFACE
246 Value: 0x1000
247 - Tag: DT_MIPS_DYNSTR_ALIGN
248 Value: 0x88888888
249 - Tag: DT_MIPS_INTERFACE_SIZE
250 Value: 0x10
251 - Tag: DT_MIPS_RLD_TEXT_RESOLVE_ADDR
252 Value: 0x8
253 - Tag: DT_MIPS_PERF_SUFFIX
254 Value: 0x0
255 - Tag: DT_MIPS_COMPACT_SIZE
256 Value: 0x10
257 - Tag: DT_MIPS_GP_VALUE
258 Value: 0x1
259 - Tag: DT_MIPS_AUX_DYNAMIC
260 Value: 0x1000
261 - Tag: DT_MIPS_PLTGOT
262 Value: 0x1000
263 - Tag: DT_MIPS_RWPLT
264 Value: 0x1000
265 - Tag: DT_MIPS_RLD_MAP_REL
266 Value: 0x1000
267 - Tag: DT_NULL
268 Value: 0
269 ProgramHeaders:
270 - Type: PT_LOAD
271 VAddr: 0x1000
272 Sections:
273 - Section: .dynstr
274 - Section: .dynamic
275 - Type: PT_DYNAMIC
276 VAddr: 0x1010
277 Sections:
278 - Section: .dynamic
279
280 # Test that PPC64 machine-specific tags can be dumped.
281 # RUN: yaml2obj --docnum=3 %s -o %t.ppc
282 # RUN: llvm-readobj --dynamic-table %t.ppc | FileCheck %s --check-prefix=LLVM-PPC
283 # RUN: llvm-readelf --dynamic-table %t.ppc | FileCheck %s --check-prefix=GNU-PPC
284
285 # LLVM-PPC: DynamicSection [ (2 entries)
286 # LLVM-PPC-NEXT: Tag Type Name/Value
287 # LLVM-PPC-NEXT: 0x0000000070000000 PPC64_GLINK 0x1000
288 # LLVM-PPC-NEXT: 0x0000000000000000 NULL 0x0
289 # LLVM-PPC-NEXT: ]
290
291 # GNU-PPC: DynamicSection [ (2 entries)
292 # GNU-PPC-NEXT: Tag Type Name/Value
293 # GNU-PPC-NEXT: 0x0000000070000000 PPC64_GLINK 0x1000
294 # GNU-PPC-NEXT: 0x0000000000000000 NULL 0x0
295 # GNU-PPC-NEXT: ]
296
297 --- !ELF
298 FileHeader:
299 Class: ELFCLASS64
300 Data: ELFDATA2LSB
301 Type: ET_EXEC
302 Machine: EM_PPC64
303 Sections:
304 - Name: .dynstr
305 Type: SHT_STRTAB
306 Address: 0x1000
307 Size: 0x10
308 Content: "004400550066007700"
309 - Name: .dynamic
310 Type: SHT_DYNAMIC
311 Address: 0x1010
312 Entries:
313 - Tag: DT_PPC64_GLINK
314 Value: 0x1000
315 - Tag: DT_NULL
316 Value: 0
317 ProgramHeaders:
318 - Type: PT_LOAD
319 VAddr: 0x1000
320 Sections:
321 - Section: .dynstr
322 - Section: .dynamic
323 - Type: PT_DYNAMIC
324 VAddr: 0x1010
325 Sections:
326 - Section: .dynamic
0 # Show that all non-machine specific tags can be read and printed correctly.
1 # RUN: yaml2obj %s > %t
2 # RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=LLVM
3 # RUN: llvm-readelf --dynamic-table %t | FileCheck %s --check-prefix=GNU
4
5 # LLVM: DynamicSection [ (60 entries)
6 # LLVM-NEXT: Tag Type Name/Value
7 # LLVM-NEXT: 0x0000000000000001 NEEDED Shared library: [D]
8 # LLVM-NEXT: 0x0000000000000002 PLTRELSZ 16 (bytes)
9 # LLVM-NEXT: 0x0000000000000003 PLTGOT 0x1000
10 # LLVM-NEXT: 0x0000000000000004 HASH 0x1000
11 # LLVM-NEXT: 0x0000000000000005 STRTAB 0x1000
12 # LLVM-NEXT: 0x0000000000000006 SYMTAB 0x1000
13 # LLVM-NEXT: 0x0000000000000007 RELA 0x1000
14 # LLVM-NEXT: 0x0000000000000008 RELASZ 16 (bytes)
15 # LLVM-NEXT: 0x0000000000000009 RELAENT 1929 (bytes)
16 # LLVM-NEXT: 0x000000000000000A STRSZ 16 (bytes)
17 # LLVM-NEXT: 0x000000000000000B SYMENT 2439 (bytes)
18 # LLVM-NEXT: 0x000000000000000C INIT 0x1000
19 # LLVM-NEXT: 0x000000000000000D FINI 0x1000
20 # LLVM-NEXT: 0x000000000000000E SONAME Library soname: [U]
21 # LLVM-NEXT: 0x000000000000000F RPATH f
22 # LLVM-NEXT: 0x0000000000000010 SYMBOLIC 0x1234567890ABCDEF
23 # LLVM-NEXT: 0x0000000000000011 REL 0x1000
24 # LLVM-NEXT: 0x0000000000000012 RELSZ 16 (bytes)
25 # LLVM-NEXT: 0x0000000000000013 RELENT 291 (bytes)
26 # LLVM-NEXT: 0x0000000000000014 PLTREL RELA
27 # LLVM-NEXT: 0x0000000000000015 DEBUG 0xFEDCBA0987654321
28 # LLVM-NEXT: 0x0000000000000016 TEXTREL 0x1122334455667788
29 # LLVM-NEXT: 0x0000000000000017 JMPREL 0x1000
30 # LLVM-NEXT: 0x0000000000000018 BIND_NOW 0x8877665544332211
31 # LLVM-NEXT: 0x0000000000000019 INIT_ARRAY 0x1000
32 # LLVM-NEXT: 0x000000000000001A FINI_ARRAY 0x1000
33 # LLVM-NEXT: 0x000000000000001B INIT_ARRAYSZ 16 (bytes)
34 # LLVM-NEXT: 0x000000000000001C FINI_ARRAYSZ 16 (bytes)
35 # LLVM-NEXT: 0x000000000000001D RUNPATH w
36 # LLVM-NEXT: 0x000000000000001E FLAGS ORIGIN SYMBOLIC TEXTREL BIND_NOW STATIC_TLS {{$}}
37 # LLVM-NEXT: 0x0000000000000020 PREINIT_ARRAY 0x1000
38 # LLVM-NEXT: 0x0000000000000021 PREINIT_ARRAYSZ 16 (bytes)
39 # LLVM-NEXT: 0x0000000000000022 SYMTAB_SHNDX 0x1000
40 # LLVM-NEXT: 0x0000000000000023 RELRSZ 0x10
41 # LLVM-NEXT: 0x0000000000000024 RELR 0x1000
42 # LLVM-NEXT: 0x0000000000000025 RELRENT 0x4321
43 # LLVM-NEXT: 0x000000006000000F ANDROID_REL 0x1000
44 # LLVM-NEXT: 0x0000000060000010 ANDROID_RELSZ 16 (bytes)
45 # LLVM-NEXT: 0x0000000060000011 ANDROID_RELA 0x1000
46 # LLVM-NEXT: 0x0000000060000012 ANDROID_RELASZ 16 (bytes)
47 # LLVM-NEXT: 0x000000006FFFE000 ANDROID_RELR 0x1000
48 # LLVM-NEXT: 0x000000006FFFE001 ANDROID_RELRSZ 0x10
49 # LLVM-NEXT: 0x000000006FFFE003 ANDROID_RELRENT 0x1234
50 # LLVM-NEXT: 0x000000006FFFFEF5 GNU_HASH 0x1000
51 # LLVM-NEXT: 0x000000006FFFFEF6 TLSDESC_PLT 0x1000
52 # LLVM-NEXT: 0x000000006FFFFEF7 TLSDESC_GOT 0x1000
53 # LLVM-NEXT: 0x000000006FFFFFF9 RELACOUNT 0
54 # LLVM-NEXT: 0x000000006FFFFFFA RELCOUNT 0
55 # LLVM-NEXT: 0x000000006FFFFFFB FLAGS_1 NOW GLOBAL GROUP NODELETE LOADFLTR INITFIRST NOOPEN ORIGIN DIRECT TRANS INTERPOSE NODEFLIB NODUMP CONFALT ENDFILTEE DISPRELDNE DISPRELPND NODIRECT IGNMULDEF NOKSYMS NOHDR EDITED NORELOC SYMINTPOSE GLOBAUDIT SINGLETON {{$}}
56 # LLVM-NEXT: 0x000000006FFFFFF0 VERSYM 0x1000
57 # LLVM-NEXT: 0x000000006FFFFFFC VERDEF 0x1000
58 # LLVM-NEXT: 0x000000006FFFFFFD VERDEFNUM 0
59 # LLVM-NEXT: 0x000000006FFFFFFE VERNEED 0x1000
60 # LLVM-NEXT: 0x000000006FFFFFFF VERNEEDNUM 0
61 # LLVM-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: [D]
62 # LLVM-NEXT: 0x000000007FFFFFFF FILTER Filter library: [U]
63 # LLVM-NEXT: 0x0000000012345678 unknown 0x8765432187654321
64 # LLVM-NEXT: 0x000000006ABCDEF0 unknown 0x9988776655443322
65 # LLVM-NEXT: 0x0000000076543210 unknown 0x5555666677778888
66 # LLVM-NEXT: 0x0000000000000000 NULL 0x0
67 # LLVM-NEXT: ]
68
69 # GNU: DynamicSection [ (60 entries)
70 # GNU-NEXT: Tag Type Name/Value
71 # GNU-NEXT: 0x0000000000000001 NEEDED Shared library: [D]
72 # GNU-NEXT: 0x0000000000000002 PLTRELSZ 16 (bytes)
73 # GNU-NEXT: 0x0000000000000003 PLTGOT 0x1000
74 # GNU-NEXT: 0x0000000000000004 HASH 0x1000
75 # GNU-NEXT: 0x0000000000000005 STRTAB 0x1000
76 # GNU-NEXT: 0x0000000000000006 SYMTAB 0x1000
77 # GNU-NEXT: 0x0000000000000007 RELA 0x1000
78 # GNU-NEXT: 0x0000000000000008 RELASZ 16 (bytes)
79 # GNU-NEXT: 0x0000000000000009 RELAENT 1929 (bytes)
80 # GNU-NEXT: 0x000000000000000a STRSZ 16 (bytes)
81 # GNU-NEXT: 0x000000000000000b SYMENT 2439 (bytes)
82 # GNU-NEXT: 0x000000000000000c INIT 0x1000
83 # GNU-NEXT: 0x000000000000000d FINI 0x1000
84 # GNU-NEXT: 0x000000000000000e SONAME Library soname: [U]
85 # GNU-NEXT: 0x000000000000000f RPATH f
86 # GNU-NEXT: 0x0000000000000010 SYMBOLIC 0x1234567890abcdef
87 # GNU-NEXT: 0x0000000000000011 REL 0x1000
88 # GNU-NEXT: 0x0000000000000012 RELSZ 16 (bytes)
89 # GNU-NEXT: 0x0000000000000013 RELENT 291 (bytes)
90 # GNU-NEXT: 0x0000000000000014 PLTREL RELA
91 # GNU-NEXT: 0x0000000000000015 DEBUG 0xfedcba0987654321
92 # GNU-NEXT: 0x0000000000000016 TEXTREL 0x1122334455667788
93 # GNU-NEXT: 0x0000000000000017 JMPREL 0x1000
94 # GNU-NEXT: 0x0000000000000018 BIND_NOW 0x8877665544332211
95 # GNU-NEXT: 0x0000000000000019 INIT_ARRAY 0x1000
96 # GNU-NEXT: 0x000000000000001a FINI_ARRAY 0x1000
97 # GNU-NEXT: 0x000000000000001b INIT_ARRAYSZ 16 (bytes)
98 # GNU-NEXT: 0x000000000000001c FINI_ARRAYSZ 16 (bytes)
99 # GNU-NEXT: 0x000000000000001d RUNPATH w
100 # GNU-NEXT: 0x000000000000001e FLAGS ORIGIN SYMBOLIC TEXTREL BIND_NOW STATIC_TLS {{$}}
101 # GNU-NEXT: 0x0000000000000020 PREINIT_ARRAY 0x1000
102 # GNU-NEXT: 0x0000000000000021 PREINIT_ARRAYSZ 16 (bytes)
103 # GNU-NEXT: 0x0000000000000022 SYMTAB_SHNDX 0x1000
104 # GNU-NEXT: 0x0000000000000023 RELRSZ 0x10
105 # GNU-NEXT: 0x0000000000000024 RELR 0x1000
106 # GNU-NEXT: 0x0000000000000025 RELRENT 0x4321
107 # GNU-NEXT: 0x000000006000000f ANDROID_REL 0x1000
108 # GNU-NEXT: 0x0000000060000010 ANDROID_RELSZ 16 (bytes)
109 # GNU-NEXT: 0x0000000060000011 ANDROID_RELA 0x1000
110 # GNU-NEXT: 0x0000000060000012 ANDROID_RELASZ 16 (bytes)
111 # GNU-NEXT: 0x000000006fffe000 ANDROID_RELR 0x1000
112 # GNU-NEXT: 0x000000006fffe001 ANDROID_RELRSZ 0x10
113 # GNU-NEXT: 0x000000006fffe003 ANDROID_RELRENT 0x1234
114 # GNU-NEXT: 0x000000006ffffef5 GNU_HASH 0x1000
115 # GNU-NEXT: 0x000000006ffffef6 TLSDESC_PLT 0x1000
116 # GNU-NEXT: 0x000000006ffffef7 TLSDESC_GOT 0x1000
117 # GNU-NEXT: 0x000000006ffffff9 RELACOUNT 0
118 # GNU-NEXT: 0x000000006ffffffa RELCOUNT 0
119 # GNU-NEXT: 0x000000006ffffffb FLAGS_1 NOW GLOBAL GROUP NODELETE LOADFLTR INITFIRST NOOPEN ORIGIN DIRECT TRANS INTERPOSE NODEFLIB NODUMP CONFALT ENDFILTEE DISPRELDNE DISPRELPND NODIRECT IGNMULDEF NOKSYMS NOHDR EDITED NORELOC SYMINTPOSE GLOBAUDIT SINGLETON {{$}}
120 # GNU-NEXT: 0x000000006ffffff0 VERSYM 0x1000
121 # GNU-NEXT: 0x000000006ffffffc VERDEF 0x1000
122 # GNU-NEXT: 0x000000006ffffffd VERDEFNUM 0
123 # GNU-NEXT: 0x000000006ffffffe VERNEED 0x1000
124 # GNU-NEXT: 0x000000006fffffff VERNEEDNUM 0
125 # GNU-NEXT: 0x000000007ffffffd AUXILIARY Auxiliary library: [D]
126 # GNU-NEXT: 0x000000007fffffff FILTER Filter library: [U]
127 # GNU-NEXT: 0x0000000012345678 unknown 0x8765432187654321
128 # GNU-NEXT: 0x000000006abcdef0 unknown 0x9988776655443322
129 # GNU-NEXT: 0x0000000076543210 unknown 0x5555666677778888
130 # GNU-NEXT: 0x0000000000000000 NULL 0x0
131 # GNU-NEXT: ]
132
133 --- !ELF
134 FileHeader:
135 Class: ELFCLASS64
136 Data: ELFDATA2LSB
137 Type: ET_EXEC
138 Machine: EM_X86_64
139 Sections:
140 - Name: .dynstr
141 Type: SHT_STRTAB
142 Address: 0x1000
143 Size: 0x10
144 Content: "004400550066007700"
145 - Name: .dynamic
146 Type: SHT_DYNAMIC
147 Address: 0x1010
148 Entries:
149 - Tag: DT_NEEDED
150 Value: 0x1
151 - Tag: DT_PLTRELSZ
152 Value: 0x10
153 - Tag: DT_PLTGOT
154 Value: 0x1000
155 - Tag: DT_HASH
156 Value: 0x1000
157 - Tag: DT_STRTAB
158 Value: 0x1000
159 - Tag: DT_SYMTAB
160 Value: 0x1000
161 - Tag: DT_RELA
162 Value: 0x1000
163 - Tag: DT_RELASZ
164 Value: 0x10
165 - Tag: DT_RELAENT
166 Value: 0x789
167 - Tag: DT_STRSZ
168 Value: 0x10
169 - Tag: DT_SYMENT
170 Value: 0x987
171 - Tag: DT_INIT
172 Value: 0x1000
173 - Tag: DT_FINI
174 Value: 0x1000
175 - Tag: DT_SONAME
176 Value: 0x3
177 - Tag: DT_RPATH
178 Value: 0x5
179 - Tag: DT_SYMBOLIC
180 Value: 0x1234567890abcdef
181 - Tag: DT_REL
182 Value: 0x1000
183 - Tag: DT_RELSZ
184 Value: 0x10
185 - Tag: DT_RELENT
186 Value: 0x123
187 - Tag: DT_PLTREL
188 Value: 0x7
189 - Tag: DT_DEBUG
190 Value: 0xfedcba0987654321
191 - Tag: DT_TEXTREL
192 Value: 0x1122334455667788
193 - Tag: DT_JMPREL
194 Value: 0x1000
195 - Tag: DT_BIND_NOW
196 Value: 0x8877665544332211
197 - Tag: DT_INIT_ARRAY
198 Value: 0x1000
199 - Tag: DT_FINI_ARRAY
200 Value: 0x1000
201 - Tag: DT_INIT_ARRAYSZ
202 Value: 0x10
203 - Tag: DT_FINI_ARRAYSZ
204 Value: 0x10
205 - Tag: DT_RUNPATH
206 Value: 0x7
207 - Tag: DT_FLAGS
208 Value: 0xffffffffffffffff
209 - Tag: DT_PREINIT_ARRAY
210 Value: 0x1000
211 - Tag: DT_PREINIT_ARRAYSZ
212 Value: 0x10
213 - Tag: DT_SYMTAB_SHNDX
214 Value: 0x1000
215 - Tag: DT_RELRSZ
216 Value: 0x10
217 - Tag: DT_RELR
218 Value: 0x1000
219 - Tag: DT_RELRENT
220 Value: 0x4321
221 - Tag: DT_ANDROID_REL
222 Value: 0x1000
223 - Tag: DT_ANDROID_RELSZ
224 Value: 0x10
225 - Tag: DT_ANDROID_RELA
226 Value: 0x1000
227 - Tag: DT_ANDROID_RELASZ
228 Value: 0x10
229 - Tag: DT_ANDROID_RELR
230 Value: 0x1000
231 - Tag: DT_ANDROID_RELRSZ
232 Value: 0x10
233 - Tag: DT_ANDROID_RELRENT
234 Value: 0x1234
235 - Tag: DT_GNU_HASH
236 Value: 0x1000
237 - Tag: DT_TLSDESC_PLT
238 Value: 0x1000
239 - Tag: DT_TLSDESC_GOT
240 Value: 0x1000
241 - Tag: DT_RELACOUNT
242 Value: 0x0
243 - Tag: DT_RELCOUNT
244 Value: 0x0
245 - Tag: DT_FLAGS_1
246 Value: 0xffffffffffffffff
247 - Tag: DT_VERSYM
248 Value: 0x1000
249 - Tag: DT_VERDEF
250 Value: 0x1000
251 - Tag: DT_VERDEFNUM
252 Value: 0x0
253 - Tag: DT_VERNEED
254 Value: 0x1000
255 - Tag: DT_VERNEEDNUM
256 Value: 0x0
257 - Tag: DT_AUXILIARY
258 Value: 0x1
259 - Tag: DT_FILTER
260 Value: 0x3
261 # Show behaviour for unknown values in special and un-marked ranges.
262 - Tag: 0x12345678
263 Value: 0x8765432187654321
264 - Tag: 0x6abcdef0
265 Value: 0x9988776655443322
266 - Tag: 0x76543210
267 Value: 0x5555666677778888
268 - Tag: DT_NULL
269 Value: 0x0
270 ProgramHeaders:
271 - Type: PT_LOAD
272 VAddr: 0x1000
273 Sections:
274 - Section: .dynstr
275 - Section: .dynamic
276 - Type: PT_DYNAMIC
277 VAddr: 0x1010
278 Sections:
279 - Section: .dynamic
0 # If the offset and/or size fields of the PT_DYNAMIC field become corrupted,
1 # it will be impossible to read the dynamic segment validly. This test shows
2 # that a sensible error message is given in this situation.
3
4 # Creating such a malformed file is hard. The easiest way to simulate it is to
5 # truncate the file. Note that the section headers must first be stripped or
6 # llvm-readobj will fail to parse the file due to the section header table
7 # offset pointing outside the file.
8
9 # RUN: yaml2obj %s -o %t.base
10 # RUN: llvm-objcopy --strip-sections %t.base %t.stripped
11
12 # Test case where the size is too large to fit in the file, but the start is
13 # within the file.
14 # RUN: cp %t.stripped %t.truncated1
15 # RUN: %python -c "with open(r'%t.truncated1', 'r+') as f: f.truncate(0x1001)"
16 # RUN: not llvm-readobj %t.truncated1 --dynamic-table 2>&1 | FileCheck %s
17
18 # Test case where the offset is too large to be in the file.
19 # RUN: cp %t.stripped %t.truncated2
20 # RUN: %python -c "with open(r'%t.truncated2', 'r+') as f: f.truncate(0xFFF)"
21 # RUN: not llvm-readobj %t.truncated2 --dynamic-table 2>&1 | FileCheck %s
22
23 # CHECK: Error reading file: Invalid data was encountered while parsing the file.
24
25 --- !ELF
26 FileHeader:
27 Class: ELFCLASS64
28 Data: ELFDATA2LSB
29 Type: ET_EXEC
30 Machine: EM_X86_64
31 Sections:
32 - Name: .dynamic
33 Type: SHT_DYNAMIC
34 Address: 0x1000
35 AddressAlign: 0x1000
36 Entries:
37 - Tag: DT_NULL
38 Value: 0
39 ProgramHeaders:
40 - Type: PT_LOAD
41 VAddr: 0x1000
42 Sections:
43 - Section: .dynamic
44 - Type: PT_DYNAMIC
45 VAddr: 0x1000
46 Sections:
47 - Section: .dynamic
0 # Show that llvm-readobj can handle no program headers when --program-headers
1 # is requested, both for LLVM and GNU output.
2
3 # RUN: yaml2obj %s -o %t
4 # RUN: llvm-readobj %t --program-headers | FileCheck %s --check-prefix=LLVM
5 # RUN: llvm-readelf %t --program-headers | FileCheck %s --check-prefix=GNU
6
7 # LLVM: ProgramHeaders [
8 # LLVM-NEXT: ]
9
10 # GNU: There are 0 program headers
11 # GNU: Program Headers:
12 # GNU-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
13 # GNU-EMPTY:
14 # GNU-NEXT: Section to Segment mapping:
15 # GNU-NEXT: Segment Sections...
16 # GNU-NEXT: None .symtab .strtab .shstrtab
17
18 --- !ELF
19 FileHeader:
20 Class: ELFCLASS64
21 Data: ELFDATA2LSB
22 Type: ET_REL
23 Machine: EM_X86_64
0 # Show that llvm-readobj can handle no relocations when --relocations is
1 # requested, both for LLVM and GNU output, both for no relocation sections and
2 # for empty relocation sections.
3
4 # RUN: yaml2obj %s -o %t.no_relocs
5 # RUN: llvm-readobj %t.no_relocs --relocations | FileCheck %s --check-prefix NO-RELOCS-LLVM
6 # RUN: llvm-readelf %t.no_relocs --relocations | FileCheck %s --check-prefix NO-RELOCS-GNU
7
8 # RUN: llvm-objcopy -R .rela.text -R .rel.text %t.no_relocs %t.no_sec
9 # RUN: llvm-readobj %t.no_sec --relocations | FileCheck %s --check-prefix NO-SEC-LLVM
10 # RUN: llvm-readelf %t.no_sec --relocations | FileCheck %s --check-prefix NO-SEC-GNU
11
12 # NO-RELOCS-LLVM: Relocations [
13 # NO-RELOCS-LLVM-NEXT: Section (2) .rela.text {
14 # NO-RELOCS-LLVM-NEXT: }
15 # NO-RELOCS-LLVM-NEXT: Section (3) .rel.text {
16 # NO-RELOCS-LLVM-NEXT: }
17 # NO-RELOCS-LLVM-NEXT: ]
18
19 # NO-RELOCS-GNU: Relocation section '.rela.text' at offset {{.*}} contains 0 entries:
20 # NO-RELOCS-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
21 # NO-RELOCS-GNU-EMPTY:
22 # NO-RELOCS-GNU-NEXT: Relocation section '.rel.text' at offset {{.*}} contains 0 entries:
23 # NO-RELOCS-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
24 # NO-RELOCS-GNU-EMPTY:
25
26 # NO-SEC-LLVM: Relocations [
27 # NO-SEC-LLVM-NEXT: ]
28
29 # NO-SEC-GNU: There are no relocations in this file.
30
31 --- !ELF
32 FileHeader:
33 Class: ELFCLASS64
34 Data: ELFDATA2LSB
35 Type: ET_REL
36 Machine: EM_X86_64
37 Sections:
38 - Name: .text
39 Type: SHT_PROGBITS
40 - Name: .rela.text
41 Type: SHT_RELA
42 Info: .text
43 Link: .symtab
44 - Name: .rel.text
45 Type: SHT_REL
46 Info: .text
47 Link: .symtab
0 # Show that llvm-readobj can handle ELF files where the section header table has
1 # been stripped, both for GNU and LLVM style output.
2
3 # RUN: yaml2obj %s -o %t.raw
4 # RUN: llvm-objcopy --strip-sections %t.raw %t.o
5 # RUN: llvm-readobj --file-headers --section-headers --symbols %t.o | FileCheck %s --check-prefix=LLVM
6 # RUN: llvm-readelf --file-headers --section-headers --symbols %t.o | FileCheck %s --check-prefix=GNU --allow-empty
7
8 # LLVM: SectionHeaderCount: 0
9 # LLVM: StringTableSectionIndex: 0
10 # LLVM: Sections [
11 # LLVM-NEXT: ]
12 # LLVM-NEXT: Symbols [
13 # LLVM-NEXT: ]
14
15 # GNU: Number of section headers: 0
16 # GNU: Section header string table index: 0
17 # GNU: There are 0 section headers
18 # GNU-NOT: Symbol table '{{.*}}' contains {{.*}} entries
19
20 --- !ELF
21 FileHeader:
22 Class: ELFCLASS64
23 Data: ELFDATA2LSB
24 Type: ET_REL
25 Machine: EM_X86_64
26 Sections:
27 - Name: .text
28 Type: SHT_PROGBITS
29 Symbols:
30 Global:
31 - Name: foobar
32 Section: .text
0 # Show that llvm-readobj can handle all standard ELF types.
1 # RUN: yaml2obj %s --docnum=1 -o %t.none
2 # RUN: llvm-readobj --file-headers %t.none | FileCheck %s --check-prefix=LLVM-NONE
3 # RUN: llvm-readelf --file-headers %t.none | FileCheck %s --check-prefix=GNU-NONE
4
5 # LLVM-NONE: Type: None (0x0)
6 # GNU-NONE: Type: NONE (none)
7
8 --- !ELF
9 FileHeader:
10 Class: ELFCLASS64
11 Data: ELFDATA2LSB
12 Type: ET_NONE
13 Machine: EM_X86_64
14
15 # RUN: yaml2obj %s --docnum=2 -o %t.rel
16 # RUN: llvm-readobj --file-headers %t.rel | FileCheck %s --check-prefix=LLVM-REL
17 # RUN: llvm-readelf --file-headers %t.rel | FileCheck %s --check-prefix=GNU-REL
18
19 # LLVM-REL: Type: Relocatable (0x1)
20 # GNU-REL: Type: REL (Relocatable file)
21
22 --- !ELF
23 FileHeader:
24 Class: ELFCLASS64
25 Data: ELFDATA2LSB
26 Type: ET_REL
27 Machine: EM_X86_64
28
29
30 # RUN: yaml2obj %s --docnum=3 -o %t.exec
31 # RUN: llvm-readobj --file-headers %t.exec | FileCheck %s --check-prefix=LLVM-EXEC
32 # RUN: llvm-readelf --file-headers %t.exec | FileCheck %s --check-prefix=GNU-EXEC
33
34 # LLVM-EXEC: Type: Executable (0x2)
35 # GNU-EXEC: Type: EXEC (Executable file)
36
37 --- !ELF
38 FileHeader:
39 Class: ELFCLASS64
40 Data: ELFDATA2LSB
41 Type: ET_EXEC
42 Machine: EM_X86_64
43
44 # RUN: yaml2obj %s --docnum=4 -o %t.so
45 # RUN: llvm-readobj --file-headers %t.so | FileCheck %s --check-prefix=LLVM-SO
46 # RUN: llvm-readelf --file-headers %t.so | FileCheck %s --check-prefix=GNU-SO
47
48 # LLVM-SO: Type: SharedObject (0x3)
49 # GNU-SO: Type: DYN (Shared object file)
50
51 --- !ELF
52 FileHeader:
53 Class: ELFCLASS64
54 Data: ELFDATA2LSB
55 Type: ET_DYN
56 Machine: EM_X86_64
57
58 # RUN: yaml2obj %s --docnum=5 -o %t.core
59 # RUN: llvm-readobj --file-headers %t.core | FileCheck %s --check-prefix=LLVM-CORE
60 # RUN: llvm-readelf --file-headers %t.core | FileCheck %s --check-prefix=GNU-CORE
61
62 # LLVM-CORE: Type: Core (0x4)
63 # GNU-CORE: Type: CORE (Core file)
64
65 --- !ELF
66 FileHeader:
67 Class: ELFCLASS64
68 Data: ELFDATA2LSB
69 Type: ET_CORE
70 Machine: EM_X86_64
71
72 # Show that llvm-readobj can handle an unknown ELF type.
73 # RUN: yaml2obj %s --docnum=6 -o %t.unknown
74 # RUN: llvm-readobj --file-headers %t.unknown | FileCheck %s --check-prefix=LLVM-UNKNOWN
75 # RUN: llvm-readelf --file-headers %t.unknown | FileCheck %s --check-prefix=GNU-UNKNOWN
76
77 # LLVM-UNKNOWN: Type: 0x42
78 # GNU-UNKNOWN: Type: 42
79
80 --- !ELF
81 FileHeader:
82 Class: ELFCLASS64
83 Data: ELFDATA2LSB
84 Type: 0x42
85 Machine: EM_X86_64
86
87 # Show that llvm-readobj can handle an unknown OS-specific ELF type.
88 # RUN: yaml2obj %s --docnum=7 -o %t.os
89 # RUN: llvm-readobj --file-headers %t.os | FileCheck %s --check-prefix=LLVM-OS
90 # RUN: llvm-readelf --file-headers %t.os | FileCheck %s --check-prefix=GNU-OS
91
92 # LLVM-OS: Type: 0xFE00
93 # GNU-OS: Type: fe00
94
95 --- !ELF
96 FileHeader:
97 Class: ELFCLASS64
98 Data: ELFDATA2LSB
99 Type: 0xfe00
100 Machine: EM_X86_64
101
102 # Show that llvm-readobj can handle an unknown machine-specific ELF type.
103 # RUN: yaml2obj %s --docnum=8 -o %t.proc
104 # RUN: llvm-readobj --file-headers %t.proc | FileCheck %s --check-prefix=LLVM-PROC
105 # RUN: llvm-readelf --file-headers %t.proc | FileCheck %s --check-prefix=GNU-PROC
106
107 # LLVM-PROC: Type: 0xFF00
108 # GNU-PROC: Type: ff00
109
110 --- !ELF
111 FileHeader:
112 Class: ELFCLASS64
113 Data: ELFDATA2LSB
114 Type: 0xff00
115 Machine: EM_X86_64
0 # Check the dumping of a section as strings.
1 # RUN: yaml2obj %s > %t
2
3 # RUN: llvm-readobj --string-dump=.strings --string-dump=.not_null_terminated %t | FileCheck %s
4 # RUN: llvm-readobj -p=.strings -p=.not_null_terminated %t | FileCheck %s
5 # RUN: llvm-readobj --string-dump=1 --string-dump=2 %t | FileCheck %s
6
7 # RUN: llvm-readelf --string-dump=.strings --string-dump=.not_null_terminated %t | FileCheck %s
8 # RUN: llvm-readelf -p=.strings -p=.not_null_terminated %t | FileCheck %s
9 # RUN: llvm-readelf --string-dump=1 --string-dump=2 %t | FileCheck %s
10
11 # CHECK: String dump of section '.strings':
12 # CHECK-NEXT: [ 0] here
13 # CHECK-NEXT: [ 5] are
14 # CHECK-NEXT: [ 9] some
15 # CHECK-NEXT: [ e] strings
16 # CHECK-NEXT: String dump of section '.not_null_terminated':
17 # CHECK-NEXT: [ 0] no
18 # CHECK-NEXT: [ 3] null{{$}}
19 # CHECK-NOT: {{.}}
20
21 # RUN: not llvm-readobj --string-dump=does_not_exist %t 2>&1 | FileCheck %s --check-prefix=ERR
22 # RUN: not llvm-readobj --string-dump=42 %t 2>&1 | FileCheck %s --check-prefix=ERR
23
24 # RUN: not llvm-readelf --string-dump=does_not_exist %t 2>&1 | FileCheck %s --check-prefix=ERR
25 # RUN: not llvm-readelf --string-dump=42 %t 2>&1 | FileCheck %s --check-prefix=ERR
26
27 # ERR: Error reading file: invalid section reference.
28
29 --- !ELF
30 FileHeader:
31 Class: ELFCLASS64
32 Data: ELFDATA2LSB
33 Type: ET_REL
34 Machine: EM_X86_64
35 Sections:
36 - Name: .strings
37 Type: SHT_PROGBITS
38 Content: 686572650061726500736f6d6500737472696e677300
39 - Name: .not_null_terminated
40 Type: SHT_PROGBITS
41 Content: 6e6f006e756c6c