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