Commit | Line | Data |
---|---|---|
5a6f7e2d ILT |
1 | // testfile.cc -- Dummy ELF objects for testing purposes. |
2 | ||
b3ce541e | 3 | // Copyright 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc. |
6cb15b7f ILT |
4 | // Written by Ian Lance Taylor <iant@google.com>. |
5 | ||
6 | // This file is part of gold. | |
7 | ||
8 | // This program is free software; you can redistribute it and/or modify | |
9 | // it under the terms of the GNU General Public License as published by | |
10 | // the Free Software Foundation; either version 3 of the License, or | |
11 | // (at your option) any later version. | |
12 | ||
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | ||
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
21 | // MA 02110-1301, USA. | |
22 | ||
5a6f7e2d ILT |
23 | #include "gold.h" |
24 | ||
25 | #include "target.h" | |
26 | #include "target-select.h" | |
27 | ||
28 | #include "test.h" | |
29 | #include "testfile.h" | |
30 | ||
31 | namespace gold_testsuite | |
32 | { | |
33 | ||
34 | using namespace gold; | |
35 | ||
36 | // A Target used for testing purposes. | |
37 | ||
6340166c ILT |
38 | template<int size, bool big_endian> |
39 | class Target_test : public Sized_target<size, big_endian> | |
5a6f7e2d ILT |
40 | { |
41 | public: | |
42 | Target_test() | |
6340166c | 43 | : Sized_target<size, big_endian>(&test_target_info) |
5a6f7e2d ILT |
44 | { } |
45 | ||
6d03d481 | 46 | void |
6fa2a40b CC |
47 | gc_process_relocs(Symbol_table*, Layout*, |
48 | Sized_relobj_file<size, big_endian>*, | |
ad0f2072 ILT |
49 | unsigned int, unsigned int, const unsigned char*, size_t, |
50 | Output_section*, bool, size_t, const unsigned char*) | |
6d03d481 ST |
51 | { ERROR("call to Target_test::gc_process_relocs"); } |
52 | ||
5a6f7e2d | 53 | void |
6fa2a40b | 54 | scan_relocs(Symbol_table*, Layout*, Sized_relobj_file<size, big_endian>*, |
ad0f2072 ILT |
55 | unsigned int, unsigned int, const unsigned char*, size_t, |
56 | Output_section*, bool, size_t, const unsigned char*) | |
5a6f7e2d ILT |
57 | { ERROR("call to Target_test::scan_relocs"); } |
58 | ||
59 | void | |
6340166c | 60 | relocate_section(const Relocate_info<size, big_endian>*, unsigned int, |
730cdc88 ILT |
61 | const unsigned char*, size_t, Output_section*, bool, |
62 | unsigned char*, typename elfcpp::Elf_types<size>::Elf_Addr, | |
364c7fa5 | 63 | section_size_type, const Reloc_symbol_changes*) |
5a6f7e2d ILT |
64 | { ERROR("call to Target_test::relocate_section"); } |
65 | ||
6a74a719 | 66 | void |
ad0f2072 | 67 | scan_relocatable_relocs(Symbol_table*, Layout*, |
6fa2a40b | 68 | Sized_relobj_file<size, big_endian>*, unsigned int, |
6a74a719 ILT |
69 | unsigned int, const unsigned char*, |
70 | size_t, Output_section*, bool, size_t, | |
71 | const unsigned char*, Relocatable_relocs*) | |
72 | { ERROR("call to Target_test::scan_relocatable_relocs"); } | |
73 | ||
74 | void | |
75 | relocate_for_relocatable(const Relocate_info<size, big_endian>*, | |
76 | unsigned int, const unsigned char*, size_t, | |
77 | Output_section*, off_t, const Relocatable_relocs*, | |
78 | unsigned char*, | |
79 | typename elfcpp::Elf_types<size>::Elf_Addr, | |
80 | section_size_type, unsigned char*, | |
81 | section_size_type) | |
82 | { ERROR("call to Target_test::relocate_for_relocatable"); } | |
83 | ||
5a6f7e2d ILT |
84 | static const Target::Target_info test_target_info; |
85 | }; | |
86 | ||
6340166c ILT |
87 | template<int size, bool big_endian> |
88 | const Target::Target_info Target_test<size, big_endian>::test_target_info = | |
5a6f7e2d | 89 | { |
6340166c ILT |
90 | size, // size |
91 | big_endian, // is_big_endian | |
5a6f7e2d ILT |
92 | static_cast<elfcpp::EM>(0xffff), // machine_code |
93 | false, // has_make_symbol | |
94 | false, // has_resolve | |
be9d5a93 | 95 | false, // has_code_fill |
35cdfc9a | 96 | false, // is_default_stack_executable |
b3ce541e | 97 | false, // can_icf_inline_merge_sections |
0864d551 | 98 | '\0', // wrap_char |
5a6f7e2d | 99 | "/dummy", // dynamic_linker |
0c5e9c22 | 100 | 0x08000000, // default_text_segment_address |
5a6f7e2d | 101 | 0x1000, // abi_pagesize |
8a5e3e08 ILT |
102 | 0x1000, // common_pagesize |
103 | elfcpp::SHN_UNDEF, // small_common_shndx | |
104 | elfcpp::SHN_UNDEF, // large_common_shndx | |
105 | 0, // small_common_section_flags | |
05a352e6 DK |
106 | 0, // large_common_section_flags |
107 | NULL, // attributes_section | |
108 | NULL // attributes_vendor | |
5a6f7e2d ILT |
109 | }; |
110 | ||
6340166c | 111 | // The test targets. |
5a6f7e2d | 112 | |
6340166c ILT |
113 | #ifdef HAVE_TARGET_32_LITTLE |
114 | Target_test<32, false> target_test_32_little; | |
115 | #endif | |
5a6f7e2d | 116 | |
6340166c ILT |
117 | #ifdef HAVE_TARGET_32_BIG |
118 | Target_test<32, true> target_test_32_big; | |
119 | #endif | |
5a6f7e2d | 120 | |
6340166c ILT |
121 | #ifdef HAVE_TARGET_64_LITTLE |
122 | Target_test<64, false> target_test_64_little; | |
123 | #endif | |
5a6f7e2d | 124 | |
6340166c ILT |
125 | #ifdef HAVE_TARGET_64_BIG |
126 | Target_test<64, true> target_test_64_big; | |
127 | #endif | |
5a6f7e2d | 128 | |
6340166c ILT |
129 | // A pointer to the test targets. This is used in CHECKs. |
130 | ||
131 | #ifdef HAVE_TARGET_32_LITTLE | |
132 | Target* target_test_pointer_32_little = &target_test_32_little; | |
133 | #endif | |
134 | ||
135 | #ifdef HAVE_TARGET_32_BIG | |
136 | Target* target_test_pointer_32_big = &target_test_32_big; | |
137 | #endif | |
138 | ||
139 | #ifdef HAVE_TARGET_64_LITTLE | |
140 | Target* target_test_pointer_64_little = &target_test_64_little; | |
141 | #endif | |
142 | ||
143 | #ifdef HAVE_TARGET_64_BIG | |
144 | Target* target_test_pointer_64_big = &target_test_64_big; | |
145 | #endif | |
146 | ||
147 | // Select the test targets. | |
148 | ||
149 | template<int size, bool big_endian> | |
5a6f7e2d ILT |
150 | class Target_selector_test : public Target_selector |
151 | { | |
152 | public: | |
153 | Target_selector_test() | |
03ef7571 | 154 | : Target_selector(0xffff, size, big_endian, NULL, NULL) |
5a6f7e2d ILT |
155 | { } |
156 | ||
157 | Target* | |
e96caa79 ILT |
158 | do_instantiate_target() |
159 | { | |
160 | gold_unreachable(); | |
161 | return NULL; | |
162 | } | |
163 | ||
164 | Target* | |
165 | do_recognize(int, int, int) | |
6340166c ILT |
166 | { |
167 | if (size == 32) | |
168 | { | |
169 | if (!big_endian) | |
170 | { | |
171 | #ifdef HAVE_TARGET_32_LITTLE | |
172 | return &target_test_32_little; | |
173 | #endif | |
174 | } | |
175 | else | |
176 | { | |
177 | #ifdef HAVE_TARGET_32_BIG | |
178 | return &target_test_32_big; | |
179 | #endif | |
180 | } | |
181 | } | |
182 | else | |
183 | { | |
184 | if (!big_endian) | |
185 | { | |
186 | #ifdef HAVE_TARGET_64_LITTLE | |
187 | return &target_test_64_little; | |
188 | #endif | |
189 | } | |
190 | else | |
191 | { | |
192 | #ifdef HAVE_TARGET_64_BIG | |
193 | return &target_test_64_big; | |
194 | #endif | |
195 | } | |
196 | } | |
197 | ||
198 | return NULL; | |
199 | } | |
0daa6f62 ILT |
200 | |
201 | Target* | |
e96caa79 | 202 | do_recognize_by_name(const char*) |
0daa6f62 | 203 | { return NULL; } |
e96caa79 ILT |
204 | |
205 | void | |
206 | do_supported_names(std::vector<const char*>*) | |
207 | { } | |
5a6f7e2d ILT |
208 | }; |
209 | ||
6340166c ILT |
210 | // Register the test target selectors. These don't need to be |
211 | // conditionally compiled, as they will return NULL if there is no | |
212 | // support for them. | |
5a6f7e2d | 213 | |
6340166c ILT |
214 | Target_selector_test<32, false> target_selector_test_32_little; |
215 | Target_selector_test<32, true> target_selector_test_32_big; | |
216 | Target_selector_test<64, false> target_selector_test_64_little; | |
217 | Target_selector_test<64, true> target_selector_test_64_big; | |
5a6f7e2d ILT |
218 | |
219 | // A simple ELF object with one empty section, named ".test" and one | |
220 | // globally visible symbol named "test". | |
221 | ||
6340166c | 222 | const unsigned char test_file_1_32_little[] = |
5a6f7e2d ILT |
223 | { |
224 | // Ehdr | |
225 | // EI_MAG[0-3] | |
226 | 0x7f, 'E', 'L', 'F', | |
227 | // EI_CLASS: 32 bit. | |
228 | 1, | |
229 | // EI_DATA: little endian | |
230 | 1, | |
231 | // EI_VERSION | |
232 | 1, | |
233 | // EI_OSABI | |
234 | 0, | |
235 | // EI_ABIVERSION | |
236 | 0, | |
237 | // EI_PAD | |
238 | 0, 0, 0, 0, 0, 0, 0, | |
239 | // e_type: ET_REL | |
240 | 1, 0, | |
241 | // e_machine: a magic value used for testing. | |
242 | 0xff, 0xff, | |
243 | // e_version | |
244 | 1, 0, 0, 0, | |
245 | // e_entry | |
246 | 0, 0, 0, 0, | |
247 | // e_phoff | |
248 | 0, 0, 0, 0, | |
249 | // e_shoff: starts right after file header | |
250 | 52, 0, 0, 0, | |
251 | // e_flags | |
252 | 0, 0, 0, 0, | |
253 | // e_ehsize | |
254 | 52, 0, | |
255 | // e_phentsize | |
256 | 32, 0, | |
257 | // e_phnum | |
258 | 0, 0, | |
259 | // e_shentsize | |
260 | 40, 0, | |
261 | // e_shnum: dummy, .test, .symtab, .strtab, .shstrtab | |
262 | 5, 0, | |
263 | // e_shstrndx | |
264 | 4, 0, | |
265 | ||
266 | // Offset 52 | |
267 | // Shdr 0: dummy entry | |
268 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
269 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
270 | 0, 0, 0, 0, 0, 0, 0, 0, | |
271 | ||
272 | // Offset 92 | |
273 | // Shdr 1: .test | |
274 | // sh_name: after initial null | |
275 | 1, 0, 0, 0, | |
276 | // sh_type: SHT_PROGBITS | |
277 | 1, 0, 0, 0, | |
278 | // sh_flags: SHF_ALLOC | |
279 | 2, 0, 0, 0, | |
280 | // sh_addr | |
281 | 0, 0, 0, 0, | |
282 | // sh_offset: after file header + 5 section headers | |
283 | 252, 0, 0, 0, | |
284 | // sh_size | |
285 | 0, 0, 0, 0, | |
286 | // sh_link | |
287 | 0, 0, 0, 0, | |
288 | // sh_info | |
289 | 0, 0, 0, 0, | |
290 | // sh_addralign | |
291 | 1, 0, 0, 0, | |
292 | // sh_entsize | |
293 | 0, 0, 0, 0, | |
294 | ||
295 | // Offset 132 | |
296 | // Shdr 2: .symtab | |
297 | // sh_name: 1 null byte + ".test\0" | |
298 | 7, 0, 0, 0, | |
299 | // sh_type: SHT_SYMTAB | |
300 | 2, 0, 0, 0, | |
301 | // sh_flags | |
302 | 0, 0, 0, 0, | |
303 | // sh_addr | |
304 | 0, 0, 0, 0, | |
305 | // sh_offset: after file header + 5 section headers + empty section | |
306 | 252, 0, 0, 0, | |
307 | // sh_size: two symbols: dummy symbol + test symbol | |
308 | 32, 0, 0, 0, | |
309 | // sh_link: to .strtab | |
310 | 3, 0, 0, 0, | |
311 | // sh_info: one local symbol, the dummy symbol | |
312 | 1, 0, 0, 0, | |
313 | // sh_addralign | |
314 | 4, 0, 0, 0, | |
315 | // sh_entsize: size of symbol | |
316 | 16, 0, 0, 0, | |
317 | ||
318 | // Offset 172 | |
319 | // Shdr 3: .strtab | |
320 | // sh_name: 1 null byte + ".test\0" + ".symtab\0" | |
321 | 15, 0, 0, 0, | |
322 | // sh_type: SHT_STRTAB | |
323 | 3, 0, 0, 0, | |
324 | // sh_flags | |
325 | 0, 0, 0, 0, | |
326 | // sh_addr | |
327 | 0, 0, 0, 0, | |
328 | // sh_offset: after .symtab section. 284 == 0x11c | |
329 | 0x1c, 0x1, 0, 0, | |
330 | // sh_size: 1 null byte + "test\0" | |
331 | 6, 0, 0, 0, | |
332 | // sh_link | |
333 | 0, 0, 0, 0, | |
334 | // sh_info | |
335 | 0, 0, 0, 0, | |
336 | // sh_addralign | |
337 | 1, 0, 0, 0, | |
338 | // sh_entsize | |
339 | 0, 0, 0, 0, | |
340 | ||
341 | // Offset 212 | |
342 | // Shdr 4: .shstrtab | |
343 | // sh_name: 1 null byte + ".test\0" + ".symtab\0" + ".strtab\0" | |
344 | 23, 0, 0, 0, | |
345 | // sh_type: SHT_STRTAB | |
346 | 3, 0, 0, 0, | |
347 | // sh_flags | |
348 | 0, 0, 0, 0, | |
349 | // sh_addr | |
350 | 0, 0, 0, 0, | |
351 | // sh_offset: after .strtab section. 290 == 0x122 | |
352 | 0x22, 0x1, 0, 0, | |
353 | // sh_size: all section names | |
354 | 33, 0, 0, 0, | |
355 | // sh_link | |
356 | 0, 0, 0, 0, | |
357 | // sh_info | |
358 | 0, 0, 0, 0, | |
359 | // sh_addralign | |
360 | 1, 0, 0, 0, | |
361 | // sh_entsize | |
362 | 0, 0, 0, 0, | |
363 | ||
364 | // Offset 252 | |
365 | // Contents of .symtab section | |
366 | // Symbol 0 | |
367 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
368 | ||
369 | // Offset 268 | |
370 | // Symbol 1 | |
371 | // st_name | |
372 | 1, 0, 0, 0, | |
373 | // st_value | |
374 | 0, 0, 0, 0, | |
375 | // st_size | |
376 | 0, 0, 0, 0, | |
377 | // st_info: STT_NOTYPE, STB_GLOBAL | |
378 | 0x10, | |
379 | // st_other | |
380 | 0, | |
381 | // st_shndx: In .test | |
382 | 1, 0, | |
383 | ||
384 | // Offset 284 | |
385 | // Contents of .strtab section | |
386 | '\0', | |
387 | 't', 'e', 's', 't', '\0', | |
388 | ||
389 | // Offset 290 | |
390 | // Contents of .shstrtab section | |
391 | '\0', | |
392 | '.', 't', 'e', 's', 't', '\0', | |
393 | '.', 's', 'y', 'm', 't', 'a', 'b', '\0', | |
394 | '.', 's', 't', 'r', 't', 'a', 'b', '\0', | |
395 | '.', 's', 'h', 's', 't', 'r', 't', 'a', 'b', '\0' | |
396 | }; | |
397 | ||
6340166c ILT |
398 | const unsigned int test_file_1_size_32_little = sizeof test_file_1_32_little; |
399 | ||
400 | // 32-bit big-endian version of test_file_1_32_little. | |
401 | ||
402 | const unsigned char test_file_1_32_big[] = | |
403 | { | |
404 | // Ehdr | |
405 | // EI_MAG[0-3] | |
406 | 0x7f, 'E', 'L', 'F', | |
407 | // EI_CLASS: 32 bit. | |
408 | 1, | |
409 | // EI_DATA: big endian | |
410 | 2, | |
411 | // EI_VERSION | |
412 | 1, | |
413 | // EI_OSABI | |
414 | 0, | |
415 | // EI_ABIVERSION | |
416 | 0, | |
417 | // EI_PAD | |
418 | 0, 0, 0, 0, 0, 0, 0, | |
419 | // e_type: ET_REL | |
420 | 0, 1, | |
421 | // e_machine: a magic value used for testing. | |
422 | 0xff, 0xff, | |
423 | // e_version | |
424 | 0, 0, 0, 1, | |
425 | // e_entry | |
426 | 0, 0, 0, 0, | |
427 | // e_phoff | |
428 | 0, 0, 0, 0, | |
429 | // e_shoff: starts right after file header | |
430 | 0, 0, 0, 52, | |
431 | // e_flags | |
432 | 0, 0, 0, 0, | |
433 | // e_ehsize | |
434 | 0, 52, | |
435 | // e_phentsize | |
436 | 0, 32, | |
437 | // e_phnum | |
438 | 0, 0, | |
439 | // e_shentsize | |
440 | 0, 40, | |
441 | // e_shnum: dummy, .test, .symtab, .strtab, .shstrtab | |
442 | 0, 5, | |
443 | // e_shstrndx | |
444 | 0, 4, | |
445 | ||
446 | // Offset 52 | |
447 | // Shdr 0: dummy entry | |
448 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
449 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
450 | 0, 0, 0, 0, 0, 0, 0, 0, | |
451 | ||
452 | // Offset 92 | |
453 | // Shdr 1: .test | |
454 | // sh_name: after initial null | |
455 | 0, 0, 0, 1, | |
456 | // sh_type: SHT_PROGBITS | |
457 | 0, 0, 0, 1, | |
458 | // sh_flags: SHF_ALLOC | |
459 | 0, 0, 0, 2, | |
460 | // sh_addr | |
461 | 0, 0, 0, 0, | |
462 | // sh_offset: after file header + 5 section headers | |
463 | 0, 0, 0, 252, | |
464 | // sh_size | |
465 | 0, 0, 0, 0, | |
466 | // sh_link | |
467 | 0, 0, 0, 0, | |
468 | // sh_info | |
469 | 0, 0, 0, 0, | |
470 | // sh_addralign | |
471 | 0, 0, 0, 1, | |
472 | // sh_entsize | |
473 | 0, 0, 0, 0, | |
474 | ||
475 | // Offset 132 | |
476 | // Shdr 2: .symtab | |
477 | // sh_name: 1 null byte + ".test\0" | |
478 | 0, 0, 0, 7, | |
479 | // sh_type: SHT_SYMTAB | |
480 | 0, 0, 0, 2, | |
481 | // sh_flags | |
482 | 0, 0, 0, 0, | |
483 | // sh_addr | |
484 | 0, 0, 0, 0, | |
485 | // sh_offset: after file header + 5 section headers + empty section | |
486 | 0, 0, 0, 252, | |
487 | // sh_size: two symbols: dummy symbol + test symbol | |
488 | 0, 0, 0, 32, | |
489 | // sh_link: to .strtab | |
490 | 0, 0, 0, 3, | |
491 | // sh_info: one local symbol, the dummy symbol | |
492 | 0, 0, 0, 1, | |
493 | // sh_addralign | |
494 | 0, 0, 0, 4, | |
495 | // sh_entsize: size of symbol | |
496 | 0, 0, 0, 16, | |
497 | ||
498 | // Offset 172 | |
499 | // Shdr 3: .strtab | |
500 | // sh_name: 1 null byte + ".test\0" + ".symtab\0" | |
501 | 0, 0, 0, 15, | |
502 | // sh_type: SHT_STRTAB | |
503 | 0, 0, 0, 3, | |
504 | // sh_flags | |
505 | 0, 0, 0, 0, | |
506 | // sh_addr | |
507 | 0, 0, 0, 0, | |
508 | // sh_offset: after .symtab section. 284 == 0x11c | |
509 | 0, 0, 0x1, 0x1c, | |
510 | // sh_size: 1 null byte + "test\0" | |
511 | 0, 0, 0, 6, | |
512 | // sh_link | |
513 | 0, 0, 0, 0, | |
514 | // sh_info | |
515 | 0, 0, 0, 0, | |
516 | // sh_addralign | |
517 | 0, 0, 0, 1, | |
518 | // sh_entsize | |
519 | 0, 0, 0, 0, | |
520 | ||
521 | // Offset 212 | |
522 | // Shdr 4: .shstrtab | |
523 | // sh_name: 1 null byte + ".test\0" + ".symtab\0" + ".strtab\0" | |
524 | 0, 0, 0, 23, | |
525 | // sh_type: SHT_STRTAB | |
526 | 0, 0, 0, 3, | |
527 | // sh_flags | |
528 | 0, 0, 0, 0, | |
529 | // sh_addr | |
530 | 0, 0, 0, 0, | |
531 | // sh_offset: after .strtab section. 290 == 0x122 | |
532 | 0, 0, 0x1, 0x22, | |
533 | // sh_size: all section names | |
534 | 0, 0, 0, 33, | |
535 | // sh_link | |
536 | 0, 0, 0, 0, | |
537 | // sh_info | |
538 | 0, 0, 0, 0, | |
539 | // sh_addralign | |
540 | 0, 0, 0, 1, | |
541 | // sh_entsize | |
542 | 0, 0, 0, 0, | |
543 | ||
544 | // Offset 252 | |
545 | // Contents of .symtab section | |
546 | // Symbol 0 | |
547 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
548 | ||
549 | // Offset 268 | |
550 | // Symbol 1 | |
551 | // st_name | |
552 | 0, 0, 0, 1, | |
553 | // st_value | |
554 | 0, 0, 0, 0, | |
555 | // st_size | |
556 | 0, 0, 0, 0, | |
557 | // st_info: STT_NOTYPE, STB_GLOBAL | |
558 | 0x10, | |
559 | // st_other | |
560 | 0, | |
561 | // st_shndx: In .test | |
562 | 0, 1, | |
563 | ||
564 | // Offset 284 | |
565 | // Contents of .strtab section | |
566 | '\0', | |
567 | 't', 'e', 's', 't', '\0', | |
568 | ||
569 | // Offset 290 | |
570 | // Contents of .shstrtab section | |
571 | '\0', | |
572 | '.', 't', 'e', 's', 't', '\0', | |
573 | '.', 's', 'y', 'm', 't', 'a', 'b', '\0', | |
574 | '.', 's', 't', 'r', 't', 'a', 'b', '\0', | |
575 | '.', 's', 'h', 's', 't', 'r', 't', 'a', 'b', '\0' | |
576 | }; | |
577 | ||
578 | const unsigned int test_file_1_size_32_big = sizeof test_file_1_32_big; | |
579 | ||
580 | // 64-bit little-endian version of test_file_1_32_little. | |
581 | ||
582 | const unsigned char test_file_1_64_little[] = | |
583 | { | |
584 | // Ehdr | |
585 | // EI_MAG[0-3] | |
586 | 0x7f, 'E', 'L', 'F', | |
587 | // EI_CLASS: 64 bit. | |
588 | 2, | |
589 | // EI_DATA: little endian | |
590 | 1, | |
591 | // EI_VERSION | |
592 | 1, | |
593 | // EI_OSABI | |
594 | 0, | |
595 | // EI_ABIVERSION | |
596 | 0, | |
597 | // EI_PAD | |
598 | 0, 0, 0, 0, 0, 0, 0, | |
599 | // e_type: ET_REL | |
600 | 1, 0, | |
601 | // e_machine: a magic value used for testing. | |
602 | 0xff, 0xff, | |
603 | // e_version | |
604 | 1, 0, 0, 0, | |
605 | // e_entry | |
606 | 0, 0, 0, 0, 0, 0, 0, 0, | |
607 | // e_phoff | |
608 | 0, 0, 0, 0, 0, 0, 0, 0, | |
609 | // e_shoff: starts right after file header | |
610 | 64, 0, 0, 0, 0, 0, 0, 0, | |
611 | // e_flags | |
612 | 0, 0, 0, 0, | |
613 | // e_ehsize | |
614 | 64, 0, | |
615 | // e_phentsize | |
616 | 56, 0, | |
617 | // e_phnum | |
618 | 0, 0, | |
619 | // e_shentsize | |
620 | 64, 0, | |
621 | // e_shnum: dummy, .test, .symtab, .strtab, .shstrtab | |
622 | 5, 0, | |
623 | // e_shstrndx | |
624 | 4, 0, | |
625 | ||
626 | // Offset 64 | |
627 | // Shdr 0: dummy entry | |
628 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
629 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
630 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
631 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
632 | ||
633 | // Offset 128 | |
634 | // Shdr 1: .test | |
635 | // sh_name: after initial null | |
636 | 1, 0, 0, 0, | |
637 | // sh_type: SHT_PROGBITS | |
638 | 1, 0, 0, 0, | |
639 | // sh_flags: SHF_ALLOC | |
640 | 2, 0, 0, 0, 0, 0, 0, 0, | |
641 | // sh_addr | |
642 | 0, 0, 0, 0, 0, 0, 0, 0, | |
643 | // sh_offset: after file header + 5 section headers. 384 == 0x180. | |
644 | 0x80, 0x1, 0, 0, 0, 0, 0, 0, | |
645 | // sh_size | |
646 | 0, 0, 0, 0, 0, 0, 0, 0, | |
647 | // sh_link | |
648 | 0, 0, 0, 0, | |
649 | // sh_info | |
650 | 0, 0, 0, 0, | |
651 | // sh_addralign | |
652 | 1, 0, 0, 0, 0, 0, 0, 0, | |
653 | // sh_entsize | |
654 | 0, 0, 0, 0, 0, 0, 0, 0, | |
655 | ||
656 | // Offset 192 | |
657 | // Shdr 2: .symtab | |
658 | // sh_name: 1 null byte + ".test\0" | |
659 | 7, 0, 0, 0, | |
660 | // sh_type: SHT_SYMTAB | |
661 | 2, 0, 0, 0, | |
662 | // sh_flags | |
663 | 0, 0, 0, 0, 0, 0, 0, 0, | |
664 | // sh_addr | |
665 | 0, 0, 0, 0, 0, 0, 0, 0, | |
666 | // sh_offset: after file header + 5 section headers + empty section | |
667 | // 384 == 0x180. | |
668 | 0x80, 0x1, 0, 0, 0, 0, 0, 0, | |
669 | // sh_size: two symbols: dummy symbol + test symbol | |
670 | 48, 0, 0, 0, 0, 0, 0, 0, | |
671 | // sh_link: to .strtab | |
672 | 3, 0, 0, 0, | |
673 | // sh_info: one local symbol, the dummy symbol | |
674 | 1, 0, 0, 0, | |
675 | // sh_addralign | |
676 | 8, 0, 0, 0, 0, 0, 0, 0, | |
677 | // sh_entsize: size of symbol | |
678 | 24, 0, 0, 0, 0, 0, 0, 0, | |
679 | ||
680 | // Offset 256 | |
681 | // Shdr 3: .strtab | |
682 | // sh_name: 1 null byte + ".test\0" + ".symtab\0" | |
683 | 15, 0, 0, 0, | |
684 | // sh_type: SHT_STRTAB | |
685 | 3, 0, 0, 0, | |
686 | // sh_flags | |
687 | 0, 0, 0, 0, 0, 0, 0, 0, | |
688 | // sh_addr | |
689 | 0, 0, 0, 0, 0, 0, 0, 0, | |
690 | // sh_offset: after .symtab section. 432 == 0x1b0 | |
691 | 0xb0, 0x1, 0, 0, 0, 0, 0, 0, | |
692 | // sh_size: 1 null byte + "test\0" | |
693 | 6, 0, 0, 0, 0, 0, 0, 0, | |
694 | // sh_link | |
695 | 0, 0, 0, 0, | |
696 | // sh_info | |
697 | 0, 0, 0, 0, | |
698 | // sh_addralign | |
699 | 1, 0, 0, 0, 0, 0, 0, 0, | |
700 | // sh_entsize | |
701 | 0, 0, 0, 0, 0, 0, 0, 0, | |
702 | ||
703 | // Offset 320 | |
704 | // Shdr 4: .shstrtab | |
705 | // sh_name: 1 null byte + ".test\0" + ".symtab\0" + ".strtab\0" | |
706 | 23, 0, 0, 0, | |
707 | // sh_type: SHT_STRTAB | |
708 | 3, 0, 0, 0, | |
709 | // sh_flags | |
710 | 0, 0, 0, 0, 0, 0, 0, 0, | |
711 | // sh_addr | |
712 | 0, 0, 0, 0, 0, 0, 0, 0, | |
713 | // sh_offset: after .strtab section. 438 == 0x1b6 | |
714 | 0xb6, 0x1, 0, 0, 0, 0, 0, 0, | |
715 | // sh_size: all section names | |
716 | 33, 0, 0, 0, 0, 0, 0, 0, | |
717 | // sh_link | |
718 | 0, 0, 0, 0, | |
719 | // sh_info | |
720 | 0, 0, 0, 0, | |
721 | // sh_addralign | |
722 | 1, 0, 0, 0, 0, 0, 0, 0, | |
723 | // sh_entsize | |
724 | 0, 0, 0, 0, 0, 0, 0, 0, | |
725 | ||
726 | // Offset 384 | |
727 | // Contents of .symtab section | |
728 | // Symbol 0 | |
729 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
730 | 0, 0, 0, 0, 0, 0, 0, 0, | |
731 | ||
732 | // Offset 408 | |
733 | // Symbol 1 | |
734 | // st_name | |
735 | 1, 0, 0, 0, | |
736 | // st_info: STT_NOTYPE, STB_GLOBAL | |
737 | 0x10, | |
738 | // st_other | |
739 | 0, | |
740 | // st_shndx: In .test | |
741 | 1, 0, | |
742 | // st_value | |
743 | 0, 0, 0, 0, 0, 0, 0, 0, | |
744 | // st_size | |
745 | 0, 0, 0, 0, 0, 0, 0, 0, | |
746 | ||
747 | // Offset 432 | |
748 | // Contents of .strtab section | |
749 | '\0', | |
750 | 't', 'e', 's', 't', '\0', | |
751 | ||
752 | // Offset 438 | |
753 | // Contents of .shstrtab section | |
754 | '\0', | |
755 | '.', 't', 'e', 's', 't', '\0', | |
756 | '.', 's', 'y', 'm', 't', 'a', 'b', '\0', | |
757 | '.', 's', 't', 'r', 't', 'a', 'b', '\0', | |
758 | '.', 's', 'h', 's', 't', 'r', 't', 'a', 'b', '\0' | |
759 | }; | |
760 | ||
761 | const unsigned int test_file_1_size_64_little = sizeof test_file_1_64_little; | |
762 | ||
763 | // 64-bit big-endian version of test_file_1_32_little. | |
764 | ||
765 | const unsigned char test_file_1_64_big[] = | |
766 | { | |
767 | // Ehdr | |
768 | // EI_MAG[0-3] | |
769 | 0x7f, 'E', 'L', 'F', | |
770 | // EI_CLASS: 64 bit. | |
771 | 2, | |
772 | // EI_DATA: big endian | |
773 | 2, | |
774 | // EI_VERSION | |
775 | 1, | |
776 | // EI_OSABI | |
777 | 0, | |
778 | // EI_ABIVERSION | |
779 | 0, | |
780 | // EI_PAD | |
781 | 0, 0, 0, 0, 0, 0, 0, | |
782 | // e_type: ET_REL | |
783 | 0, 1, | |
784 | // e_machine: a magic value used for testing. | |
785 | 0xff, 0xff, | |
786 | // e_version | |
787 | 0, 0, 0, 1, | |
788 | // e_entry | |
789 | 0, 0, 0, 0, 0, 0, 0, 0, | |
790 | // e_phoff | |
791 | 0, 0, 0, 0, 0, 0, 0, 0, | |
792 | // e_shoff: starts right after file header | |
793 | 0, 0, 0, 0, 0, 0, 0, 64, | |
794 | // e_flags | |
795 | 0, 0, 0, 0, | |
796 | // e_ehsize | |
797 | 0, 64, | |
798 | // e_phentsize | |
799 | 0, 56, | |
800 | // e_phnum | |
801 | 0, 0, | |
802 | // e_shentsize | |
803 | 0, 64, | |
804 | // e_shnum: dummy, .test, .symtab, .strtab, .shstrtab | |
805 | 0, 5, | |
806 | // e_shstrndx | |
807 | 0, 4, | |
808 | ||
809 | // Offset 64 | |
810 | // Shdr 0: dummy entry | |
811 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
812 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
813 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
814 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
815 | ||
816 | // Offset 128 | |
817 | // Shdr 1: .test | |
818 | // sh_name: after initial null | |
819 | 0, 0, 0, 1, | |
820 | // sh_type: SHT_PROGBITS | |
821 | 0, 0, 0, 1, | |
822 | // sh_flags: SHF_ALLOC | |
823 | 0, 0, 0, 0, 0, 0, 0, 2, | |
824 | // sh_addr | |
825 | 0, 0, 0, 0, 0, 0, 0, 0, | |
826 | // sh_offset: after file header + 5 section headers. 384 == 0x180. | |
827 | 0, 0, 0, 0, 0, 0, 0x1, 0x80, | |
828 | // sh_size | |
829 | 0, 0, 0, 0, 0, 0, 0, 0, | |
830 | // sh_link | |
831 | 0, 0, 0, 0, | |
832 | // sh_info | |
833 | 0, 0, 0, 0, | |
834 | // sh_addralign | |
835 | 0, 0, 0, 0, 0, 0, 0, 1, | |
836 | // sh_entsize | |
837 | 0, 0, 0, 0, 0, 0, 0, 0, | |
838 | ||
839 | // Offset 192 | |
840 | // Shdr 2: .symtab | |
841 | // sh_name: 1 null byte + ".test\0" | |
842 | 0, 0, 0, 7, | |
843 | // sh_type: SHT_SYMTAB | |
844 | 0, 0, 0, 2, | |
845 | // sh_flags | |
846 | 0, 0, 0, 0, 0, 0, 0, 0, | |
847 | // sh_addr | |
848 | 0, 0, 0, 0, 0, 0, 0, 0, | |
849 | // sh_offset: after file header + 5 section headers + empty section | |
850 | // 384 == 0x180. | |
851 | 0, 0, 0, 0, 0, 0, 0x1, 0x80, | |
852 | // sh_size: two symbols: dummy symbol + test symbol | |
853 | 0, 0, 0, 0, 0, 0, 0, 48, | |
854 | // sh_link: to .strtab | |
855 | 0, 0, 0, 3, | |
856 | // sh_info: one local symbol, the dummy symbol | |
857 | 0, 0, 0, 1, | |
858 | // sh_addralign | |
859 | 0, 0, 0, 0, 0, 0, 0, 8, | |
860 | // sh_entsize: size of symbol | |
861 | 0, 0, 0, 0, 0, 0, 0, 24, | |
862 | ||
863 | // Offset 256 | |
864 | // Shdr 3: .strtab | |
865 | // sh_name: 1 null byte + ".test\0" + ".symtab\0" | |
866 | 0, 0, 0, 15, | |
867 | // sh_type: SHT_STRTAB | |
868 | 0, 0, 0, 3, | |
869 | // sh_flags | |
870 | 0, 0, 0, 0, 0, 0, 0, 0, | |
871 | // sh_addr | |
872 | 0, 0, 0, 0, 0, 0, 0, 0, | |
873 | // sh_offset: after .symtab section. 432 == 0x1b0 | |
874 | 0, 0, 0, 0, 0, 0, 0x1, 0xb0, | |
875 | // sh_size: 1 null byte + "test\0" | |
876 | 0, 0, 0, 0, 0, 0, 0, 6, | |
877 | // sh_link | |
878 | 0, 0, 0, 0, | |
879 | // sh_info | |
880 | 0, 0, 0, 0, | |
881 | // sh_addralign | |
882 | 0, 0, 0, 0, 0, 0, 0, 1, | |
883 | // sh_entsize | |
884 | 0, 0, 0, 0, 0, 0, 0, 0, | |
885 | ||
886 | // Offset 320 | |
887 | // Shdr 4: .shstrtab | |
888 | // sh_name: 1 null byte + ".test\0" + ".symtab\0" + ".strtab\0" | |
889 | 0, 0, 0, 23, | |
890 | // sh_type: SHT_STRTAB | |
891 | 0, 0, 0, 3, | |
892 | // sh_flags | |
893 | 0, 0, 0, 0, 0, 0, 0, 0, | |
894 | // sh_addr | |
895 | 0, 0, 0, 0, 0, 0, 0, 0, | |
896 | // sh_offset: after .strtab section. 438 == 0x1b6 | |
897 | 0, 0, 0, 0, 0, 0, 0x1, 0xb6, | |
898 | // sh_size: all section names | |
899 | 0, 0, 0, 0, 0, 0, 0, 33, | |
900 | // sh_link | |
901 | 0, 0, 0, 0, | |
902 | // sh_info | |
903 | 0, 0, 0, 0, | |
904 | // sh_addralign | |
905 | 0, 0, 0, 0, 0, 0, 0, 1, | |
906 | // sh_entsize | |
907 | 0, 0, 0, 0, 0, 0, 0, 0, | |
908 | ||
909 | // Offset 384 | |
910 | // Contents of .symtab section | |
911 | // Symbol 0 | |
912 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
913 | 0, 0, 0, 0, 0, 0, 0, 0, | |
914 | ||
915 | // Offset 408 | |
916 | // Symbol 1 | |
917 | // st_name | |
918 | 0, 0, 0, 1, | |
919 | // st_info: STT_NOTYPE, STB_GLOBAL | |
920 | 0x10, | |
921 | // st_other | |
922 | 0, | |
923 | // st_shndx: In .test | |
924 | 0, 1, | |
925 | // st_value | |
926 | 0, 0, 0, 0, 0, 0, 0, 0, | |
927 | // st_size | |
928 | 0, 0, 0, 0, 0, 0, 0, 0, | |
929 | ||
930 | // Offset 432 | |
931 | // Contents of .strtab section | |
932 | '\0', | |
933 | 't', 'e', 's', 't', '\0', | |
934 | ||
935 | // Offset 438 | |
936 | // Contents of .shstrtab section | |
937 | '\0', | |
938 | '.', 't', 'e', 's', 't', '\0', | |
939 | '.', 's', 'y', 'm', 't', 'a', 'b', '\0', | |
940 | '.', 's', 't', 'r', 't', 'a', 'b', '\0', | |
941 | '.', 's', 'h', 's', 't', 'r', 't', 'a', 'b', '\0' | |
942 | }; | |
943 | ||
944 | const unsigned int test_file_1_size_64_big = sizeof test_file_1_64_big; | |
5a6f7e2d ILT |
945 | |
946 | } // End namespace gold_testsuite. |