1 // testfile.cc -- Dummy ELF objects for testing purposes.
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
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.
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.
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.
26 #include "target-select.h"
31 namespace gold_testsuite
36 // A Target used for testing purposes.
38 class Target_test : public Sized_target<32, false>
42 : Sized_target<32, false>(&test_target_info)
46 scan_relocs(const General_options&, Symbol_table*, Layout*,
47 Sized_relobj<32, false>*, unsigned int, unsigned int,
48 const unsigned char*, size_t, size_t, const unsigned char*,
50 { ERROR("call to Target_test::scan_relocs"); }
53 relocate_section(const Relocate_info<32, false>*, unsigned int,
54 const unsigned char*, size_t, unsigned char*,
55 elfcpp::Elf_types<32>::Elf_Addr, off_t)
56 { ERROR("call to Target_test::relocate_section"); }
58 static const Target::Target_info test_target_info;
61 const Target::Target_info Target_test::test_target_info =
64 false, // is_big_endian
65 static_cast<elfcpp::EM>(0xffff), // machine_code
66 false, // has_make_symbol
68 false, // has_code_fill
69 "/dummy", // dynamic_linker
70 0x08000000, // text_segment_address
71 0x1000, // abi_pagesize
72 0x1000 // common_pagesize
75 // The single test target.
77 Target_test target_test;
79 // A pointer to the test target. This is used in CHECKs.
81 Target* target_test_pointer = &target_test;
83 // Select the test target.
85 class Target_selector_test : public Target_selector
88 Target_selector_test()
89 : Target_selector(0xffff, 32, false)
93 recognize(int, int, int)
94 { return &target_test; }
97 // Register the test target selector.
99 Target_selector_test target_selector_test;
101 // A simple ELF object with one empty section, named ".test" and one
102 // globally visible symbol named "test".
104 const unsigned char test_file_1[] =
111 // EI_DATA: little endian
123 // e_machine: a magic value used for testing.
131 // e_shoff: starts right after file header
143 // e_shnum: dummy, .test, .symtab, .strtab, .shstrtab
149 // Shdr 0: dummy entry
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
152 0, 0, 0, 0, 0, 0, 0, 0,
156 // sh_name: after initial null
158 // sh_type: SHT_PROGBITS
160 // sh_flags: SHF_ALLOC
164 // sh_offset: after file header + 5 section headers
179 // sh_name: 1 null byte + ".test\0"
181 // sh_type: SHT_SYMTAB
187 // sh_offset: after file header + 5 section headers + empty section
189 // sh_size: two symbols: dummy symbol + test symbol
191 // sh_link: to .strtab
193 // sh_info: one local symbol, the dummy symbol
197 // sh_entsize: size of symbol
202 // sh_name: 1 null byte + ".test\0" + ".symtab\0"
204 // sh_type: SHT_STRTAB
210 // sh_offset: after .symtab section. 284 == 0x11c
212 // sh_size: 1 null byte + "test\0"
225 // sh_name: 1 null byte + ".test\0" + ".symtab\0" + ".strtab\0"
227 // sh_type: SHT_STRTAB
233 // sh_offset: after .strtab section. 290 == 0x122
235 // sh_size: all section names
247 // Contents of .symtab section
249 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
259 // st_info: STT_NOTYPE, STB_GLOBAL
263 // st_shndx: In .test
267 // Contents of .strtab section
269 't', 'e', 's', 't', '\0',
272 // Contents of .shstrtab section
274 '.', 't', 'e', 's', 't', '\0',
275 '.', 's', 'y', 'm', 't', 'a', 'b', '\0',
276 '.', 's', 't', 'r', 't', 'a', 'b', '\0',
277 '.', 's', 'h', 's', 't', 'r', 't', 'a', 'b', '\0'
280 const unsigned int test_file_1_size = sizeof test_file_1;
282 } // End namespace gold_testsuite.