• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2
3# testfile-phdrs.elf generated with python3 script
4# import struct
5# import sys
6#
7# phnum = 66000
8#
9# sys.stdout.buffer.write(
10#     struct.pack(
11#         "<16BHHIQQQIHHHHHH",
12#         # EI_MAG
13#         *b"\x7fELF",
14#         # EI_CLASS = ELFCLASS64
15#         2,
16#         # EI_DATA = ELFDATA2LSB
17#         1,
18#         # EI_VERSION
19#         1,
20#         # EI_OSABI = ELFOSABI_SYSV
21#         0,
22#         # EI_ABIVERSION
23#         0,
24#         # EI_PAD
25#         *bytes(7),
26#         # e_type = ET_CORE
27#         4,
28#         # e_machine = EM_X86_64
29#         62,
30#         # e_version
31#         1,
32#         # e_entry
33#         0,
34#         # e_phoff = sizeof(Elf64_Ehdr) + sizeof(Elf64_Shdr)
35#         128,
36#         # e_shoff = sizeof(Elf64_Ehdr)
37#         64,
38#         # e_flags
39#         0,
40#         # e_ehsize
41#         64,
42#         # e_phentsize
43#         56,
44#         # e_phnum = PN_XNUM
45#         0xFFFF,
46#         # e_shentsize
47#         64,
48#         # e_shnum
49#         1,
50#         # e_shstrndx
51#         0,
52#     )
53# )
54#
55# sys.stdout.buffer.write(
56#     struct.pack(
57#         "<IIQQQQIIQQ",
58#         # sh_name
59#         0,
60#         # sh_type = SHT_NULL
61#         0,
62#         # sh_flags
63#         0,
64#         # sh_addr
65#         0,
66#         # sh_offset
67#         0,
68#         # sh_size
69#         0,
70#         # sh_link
71#         0,
72#         # sh_info
73#         phnum,
74#         # sh_addralign
75#         0,
76#         # sh_entsize
77#         0,
78#     )
79# )
80#
81# for i in range(phnum):
82#     sys.stdout.buffer.write(
83#         struct.pack(
84#             "<IIQQQQQQ",
85#             # p_type = PT_LOAD
86#             1,
87#             # p_flags = PF_X|PF_W|PF_R
88#             0x7,
89#             # p_offset
90#             0,
91#             # p_vaddr
92#             # i * 4096,
93#             4096,
94#             # p_paddr
95#             0,
96#             # p_filesz
97#             0,
98#             # p_memsz
99#             4096,
100#             # p_align
101#             0,
102#         )
103#     )
104
105. $srcdir/test-subr.sh
106
107testfiles testfile-phdrs.elf
108
109testrun_compare ${abs_top_builddir}/src/readelf -h testfile-phdrs.elf<<\EOF
110ELF Header:
111  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
112  Class:                             ELF64
113  Data:                              2's complement, little endian
114  Ident Version:                     1 (current)
115  OS/ABI:                            UNIX - System V
116  ABI Version:                       0
117  Type:                              CORE (Core file)
118  Machine:                           AMD x86-64
119  Version:                           1 (current)
120  Entry point address:               0
121  Start of program headers:          128 (bytes into file)
122  Start of section headers:          64 (bytes into file)
123  Flags:
124  Size of this header:               64 (bytes)
125  Size of program header entries:    56 (bytes)
126  Number of program headers entries: 65535 (66000 in [0].sh_info)
127  Size of section header entries:    64 (bytes)
128  Number of section headers entries: 1
129  Section header string table index: 0
130
131EOF
132
133testrun_compare ${abs_builddir}/getphdrnum testfile-phdrs.elf<<\EOF
13466000
135EOF
136
137exit 0
138