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