testfile.cc 21 KB

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