#include <sys/elf64.h>
Go to the source code of this file.
◆ Loader_CheckHeader()
Loader_CheckHeader –
Check that the program has a valid ELF header.
Definition at line 34 of file loader.c.
35{
40 return false;
41
43 return false;
44 }
45
47 return false;
48 }
49
50 return true;
51}
unsigned char e_ident[EI_NIDENT]
◆ Loader_Load()
Loader_Load –
Load the ELF binary into the process belonging to the thread.
Definition at line 131 of file loader.c.
132{
133 int i;
137
140
142 Log(loader,
"Not a valid executable!\n");
143 return false;
144 }
145
146 Log(loader,
"%8s %16s %8s %8s\n",
"Offset",
"VAddr",
"FileSize",
"MemSize");
147 for (i = 0; i < ehdr->
e_phnum; i++)
148 {
150 if (phdr[i].p_type ==
PT_LOAD) {
153 Log(loader,
"%08llx %016llx %08llx %08llx\n", phdr[i].p_offset,
154 phdr[i].p_vaddr, phdr[i].p_filesz, phdr[i].p_memsz);
155
156
159
160 Log(loader,
"AllocMap %016llx %08llx\n", va, memsz);
162
164 return false;
165 }
166 }
167 }
168
170
171
172
173
175
176 return true;
177}
#define Log(_module, _format,...)
bool Loader_CheckHeader(const Elf64_Ehdr *ehdr)
#define MEM_USERSPACE_STKLEN
#define MEM_USERSPACE_STKBASE
bool PMap_AllocMap(AS *as, uint64_t virt, uint64_t len, uint64_t flags)