1 // testfile.cc -- Dummy ELF objects for testing purposes.
6 #include "target-select.h"
11 namespace gold_testsuite
16 // A Target used for testing purposes.
18 class Target_test
: public Sized_target
<32, false>
22 : Sized_target
<32, false>(&test_target_info
)
26 scan_relocs(const General_options
&, Symbol_table
*, Layout
*,
27 Sized_relobj
<32, false>*, unsigned int, unsigned int,
28 const unsigned char*, size_t, size_t, const unsigned char*,
30 { ERROR("call to Target_test::scan_relocs"); }
33 relocate_section(const Relocate_info
<32, false>*, unsigned int,
34 const unsigned char*, size_t, unsigned char*,
35 elfcpp::Elf_types
<32>::Elf_Addr
, off_t
)
36 { ERROR("call to Target_test::relocate_section"); }
38 static const Target::Target_info test_target_info
;
41 const Target::Target_info
Target_test::test_target_info
=
44 false, // is_big_endian
45 static_cast<elfcpp::EM
>(0xffff), // machine_code
46 false, // has_make_symbol
48 "/dummy", // dynamic_linker
49 0x08000000, // text_segment_address
50 0x1000, // abi_pagesize
51 0x1000 // common_pagesize
54 // The single test target.
56 Target_test target_test
;
58 // A pointer to the test target. This is used in CHECKs.
60 Target
* target_test_pointer
= &target_test
;
62 // Select the test target.
64 class Target_selector_test
: public Target_selector
67 Target_selector_test()
68 : Target_selector(0xffff, 32, false)
72 recognize(int, int, int)
73 { return &target_test
; }
76 // Register the test target selector.
78 Target_selector_test target_selector_test
;
80 // A simple ELF object with one empty section, named ".test" and one
81 // globally visible symbol named "test".
83 const unsigned char test_file_1
[] =
90 // EI_DATA: little endian
102 // e_machine: a magic value used for testing.
110 // e_shoff: starts right after file header
122 // e_shnum: dummy, .test, .symtab, .strtab, .shstrtab
128 // Shdr 0: dummy entry
129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
131 0, 0, 0, 0, 0, 0, 0, 0,
135 // sh_name: after initial null
137 // sh_type: SHT_PROGBITS
139 // sh_flags: SHF_ALLOC
143 // sh_offset: after file header + 5 section headers
158 // sh_name: 1 null byte + ".test\0"
160 // sh_type: SHT_SYMTAB
166 // sh_offset: after file header + 5 section headers + empty section
168 // sh_size: two symbols: dummy symbol + test symbol
170 // sh_link: to .strtab
172 // sh_info: one local symbol, the dummy symbol
176 // sh_entsize: size of symbol
181 // sh_name: 1 null byte + ".test\0" + ".symtab\0"
183 // sh_type: SHT_STRTAB
189 // sh_offset: after .symtab section. 284 == 0x11c
191 // sh_size: 1 null byte + "test\0"
204 // sh_name: 1 null byte + ".test\0" + ".symtab\0" + ".strtab\0"
206 // sh_type: SHT_STRTAB
212 // sh_offset: after .strtab section. 290 == 0x122
214 // sh_size: all section names
226 // Contents of .symtab section
228 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
238 // st_info: STT_NOTYPE, STB_GLOBAL
242 // st_shndx: In .test
246 // Contents of .strtab section
248 't', 'e', 's', 't', '\0',
251 // Contents of .shstrtab section
253 '.', 't', 'e', 's', 't', '\0',
254 '.', 's', 'y', 'm', 't', 'a', 'b', '\0',
255 '.', 's', 't', 'r', 't', 'a', 'b', '\0',
256 '.', 's', 'h', 's', 't', 'r', 't', 'a', 'b', '\0'
259 const unsigned int test_file_1_size
= sizeof test_file_1
;
261 } // End namespace gold_testsuite.