testfile.cc 20 KB

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