ELF image format.
Definition in file elf.h.
Process ELF segments.
- Parameters
-
| image | ELF file |
| ehdr | ELF executable header |
| process | Segment processor |
- Return values
-
| entry | Entry point, if found |
| max | Maximum used address |
| rc | Return status code |
Definition at line 157 of file elf.c.
161 {
164 unsigned int phnum;
166
167
169
170
171 *entry = 0;
172
173
177 ( (
image->
len - phoff ) < sizeof ( *phdr ) ) ) {
178 DBGC (
image,
"ELF %s program header %d outside "
181 }
184 entry,
max ) ) != 0 )
186 }
187
188
189 if ( ! *entry ) {
190 DBGC (
image,
"ELF %s entry point %lx outside image\n",
193 }
194
195 return 0;
196}
struct arbelprm_rc_send_wqe rc
static int elf_segment(struct image *image, const Elf_Ehdr *ehdr, const Elf_Phdr *phdr, int(*process)(struct image *image, const Elf_Phdr *phdr, physaddr_t dest), physaddr_t *entry, physaddr_t *max)
Process ELF segment.
#define ENOEXEC
Exec format error.
const void * data
Read-only data.
size_t len
Length of raw file image.
References image::data, DBGC, dest, Elf32_Ehdr::e_entry, Elf32_Ehdr::e_phentsize, Elf32_Ehdr::e_phnum, Elf32_Ehdr::e_phoff, elf_segment(), ENOEXEC, image::len, max, image::name, and rc.
Referenced by elf_load(), and elfboot_probe().
Load ELF image into memory.
- Parameters
-
- Return values
-
| entry | Entry point |
| max | Maximum used address |
| rc | Return status code |
Definition at line 206 of file elf.c.
206 {
207 static const uint8_t e_ident[] = {
213 };
216
217
218 if (
image->
len < sizeof ( *ehdr ) ) {
219 DBGC (
image,
"ELF %s too short for ELF header\n",
222 }
224 if (
memcmp ( ehdr->
e_ident, e_ident, sizeof ( e_ident ) ) != 0 ) {
227 }
228
229
231 entry,
max ) ) != 0 )
233
234 return 0;
235}
static int elf_load_segment(struct image *image, const Elf_Phdr *phdr, physaddr_t dest)
Load ELF segment into memory.
int elf_segments(struct image *image, const Elf_Ehdr *ehdr, int(*process)(struct image *image, const Elf_Phdr *phdr, physaddr_t dest), physaddr_t *entry, physaddr_t *max)
Process ELF segments.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
unsigned char e_ident[EI_NIDENT]
References image::data, DBGC, Elf32_Ehdr::e_ident, EI_CLASS, EI_MAG0, EI_MAG1, EI_MAG2, EI_MAG3, elf_load_segment(), elf_segments(), ELFCLASS, ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ENOEXEC, image::len, max, memcmp(), image::name, and rc.
Referenced by elfboot_exec(), and multiboot_load_elf().