search for: e_phnum

Displaying 20 results from an estimated 54 matches for "e_phnum".

2015 Oct 10
3
[PATCH] Extend Multiboot1 with support for ELF64 file format
...32/mboot/map.c Sat Oct 10 09:13:45 2015 @@ -106,6 +106,11 @@ Elf32_Ehdr *eh = ptr; Elf32_Phdr *ph; Elf32_Shdr *sh; + + Elf64_Ehdr *eh64 = ptr; + Elf64_Phdr *ph64; + Elf64_Shdr *sh64; + unsigned int i, mbh_offset; uint32_t bad_flags; @@ -150,6 +155,17 @@ !eh->e_phnum || eh->e_phoff + eh->e_phentsize * eh->e_phnum > len) eh = NULL; /* No valid ELF header found */ + /* Determine 64-bit images */ + if ((eh != NULL) || + len < sizeof(Elf64_Ehdr) || + memcmp(eh64->e_ident, "\x7f" "ELF\2\1\1", 6) || + (eh64->e_machi...
2008 Feb 13
4
[PATCHv3 1/3] x86: use ELF format in compressed images.
...[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 || + ehdr.e_ident[EI_MAG3] != ELFMAG3) + { + error("Kernel is not a valid ELF file"); + return; + } + + putstr("Parsing ELF... "); + + phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); + if (!phdrs) + error("Failed to allocate space for phdrs"); + + memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); + + for (i=0; i<ehdr.e_phnum; i++) { + phdr = &phdrs[i]; + + switch (phdr->p_type) { + case PT_LOAD: +#ifdef CONFIG_RELOCATABLE + dest =...
2008 Feb 13
4
[PATCHv3 1/3] x86: use ELF format in compressed images.
...[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 || + ehdr.e_ident[EI_MAG3] != ELFMAG3) + { + error("Kernel is not a valid ELF file"); + return; + } + + putstr("Parsing ELF... "); + + phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); + if (!phdrs) + error("Failed to allocate space for phdrs"); + + memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); + + for (i=0; i<ehdr.e_phnum; i++) { + phdr = &phdrs[i]; + + switch (phdr->p_type) { + case PT_LOAD: +#ifdef CONFIG_RELOCATABLE + dest =...
2008 Jan 31
0
[PATCH] x86: use ELF format in compressed images.
...[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 || + ehdr.e_ident[EI_MAG3] != ELFMAG3) + { + error("Kernel is not a valid ELF file"); + return; + } + + putstr("Parsing ELF... "); + + phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); + if (!phdrs) + error("Failed to allocate space for phdrs"); + + memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); + + for (i=0; i<ehdr.e_phnum; i++) { + phdr = &phdrs[i]; + + switch (phdr->p_type) { + case PT_LOAD: + memcpy((void*)phdr->p_paddr, +...
2008 Jan 31
0
[PATCH] x86: use ELF format in compressed images.
...[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 || + ehdr.e_ident[EI_MAG3] != ELFMAG3) + { + error("Kernel is not a valid ELF file"); + return; + } + + putstr("Parsing ELF... "); + + phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); + if (!phdrs) + error("Failed to allocate space for phdrs"); + + memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); + + for (i=0; i<ehdr.e_phnum; i++) { + phdr = &phdrs[i]; + + switch (phdr->p_type) { + case PT_LOAD: + memcpy((void*)phdr->p_paddr, +...
2008 Feb 06
0
[PATCHv2 1/3] x86: use ELF format in compressed images.
...[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 || + ehdr.e_ident[EI_MAG3] != ELFMAG3) + { + error("Kernel is not a valid ELF file"); + return; + } + + putstr("Parsing ELF... "); + + phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); + if (!phdrs) + error("Failed to allocate space for phdrs"); + + memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); + + for (i=0; i<ehdr.e_phnum; i++) { + phdr = &phdrs[i]; + + switch (phdr->p_type) { + case PT_LOAD: +#ifdef CONFIG_RELOCATABLE + dest =...
2008 Feb 06
0
[PATCHv2 1/3] x86: use ELF format in compressed images.
...[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 || + ehdr.e_ident[EI_MAG3] != ELFMAG3) + { + error("Kernel is not a valid ELF file"); + return; + } + + putstr("Parsing ELF... "); + + phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); + if (!phdrs) + error("Failed to allocate space for phdrs"); + + memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); + + for (i=0; i<ehdr.e_phnum; i++) { + phdr = &phdrs[i]; + + switch (phdr->p_type) { + case PT_LOAD: +#ifdef CONFIG_RELOCATABLE + dest =...
2007 Apr 18
2
[PATCH] exec-shield style vdso move.
...o { \ NEW_AUX_ENT(AT_SYSINFO, VSYSCALL_ENTRY); \ @@ -148,15 +158,15 @@ do { \ * Dumping its extra ELF program headers includes all the other information * a debugger needs to easily find how the vsyscall DSO was being used. */ -#define ELF_CORE_EXTRA_PHDRS (VSYSCALL_EHDR->e_phnum) +#define ELF_CORE_EXTRA_PHDRS (__VSYSCALL_EHDR->e_phnum) #define ELF_CORE_WRITE_EXTRA_PHDRS \ do { \ const struct elf_phdr *const vsyscall_phdrs = \ - (const struct elf_phdr *) (VSYSCALL_BASE \ - + VSYSCALL_EHDR->e_phoff); \ + (const...
2007 Apr 18
2
[PATCH] exec-shield style vdso move.
...o { \ NEW_AUX_ENT(AT_SYSINFO, VSYSCALL_ENTRY); \ @@ -148,15 +158,15 @@ do { \ * Dumping its extra ELF program headers includes all the other information * a debugger needs to easily find how the vsyscall DSO was being used. */ -#define ELF_CORE_EXTRA_PHDRS (VSYSCALL_EHDR->e_phnum) +#define ELF_CORE_EXTRA_PHDRS (__VSYSCALL_EHDR->e_phnum) #define ELF_CORE_WRITE_EXTRA_PHDRS \ do { \ const struct elf_phdr *const vsyscall_phdrs = \ - (const struct elf_phdr *) (VSYSCALL_BASE \ - + VSYSCALL_EHDR->e_phoff); \ + (const...
2007 Apr 18
1
[PATCH] Unified lguest launcher
This is a new version of the unified lguest launcher that applies to the current tree. According to rusty's suggestion, I'm bothering less to be able to load 32 bit kernels on 64-bit machines: changing the launcher for such case would be the easy part! In the absence of further objections, I'll commit it. Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> -- =
2007 Apr 18
1
[PATCH] Unified lguest launcher
This is a new version of the unified lguest launcher that applies to the current tree. According to rusty's suggestion, I'm bothering less to be able to load 32 bit kernels on 64-bit machines: changing the launcher for such case would be the easy part! In the absence of further objections, I'll commit it. Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> -- =
2025 Apr 21
0
[PATCH] Permit zero-sized ELF program sections
...be able to handle when a program section has a zero on-disk size. Here's a patch with the necessary checks: --- a/com32/lib/sys/module/i386/elf_module.c +++ b/com32/lib/sys/module/i386/elf_module.c @@ -112,6 +112,14 @@ int load_segments(struct elf_module *mod for (i = 0; i < elf_hdr->e_phnum; i++) { cr_pht = (Elf32_Phdr*)(pht + i * elf_hdr->e_phentsize); + if (cr_pht->p_filesz == 0) + { + DBG_PRINT("Skipping loadable segment of zero size at vaddr 0x%08x at 0x%08x.\n" + cr_pht->p_vaddr, + (Elf32_Addr)module_get_absolute(cr_pht->p_vaddr, module)); +...
2007 Apr 18
1
[PATCH 0/2] Use a single loader for i386 and x86_64
...* Returns the entry point */ +static unsigned long map_elf64(int elf_fd, const Elf64_Ehdr *ehdr, unsigned long mem, + unsigned long *pgdir_addr, + const char *initrd, unsigned long *ird_size, + unsigned long *page_offset) +{ +#ifdef CONFIG_X86_64 + void *addr; + Elf64_Phdr phdr[ehdr->e_phnum]; + unsigned int i; + Elf64_Shdr sec[ehdr->e_shnum]; + Elf64_Sym *syms; + char *strtab = NULL; + unsigned long nsyms = 0; + + /* Sanity checks. */ + if (ehdr->e_type != ET_EXEC + || ehdr->e_machine != EM_X86_64 + || ehdr->e_phentsize != sizeof(Elf64_Phdr) + || ehdr->e_phn...
2007 Apr 18
1
[PATCH 0/2] Use a single loader for i386 and x86_64
...* Returns the entry point */ +static unsigned long map_elf64(int elf_fd, const Elf64_Ehdr *ehdr, unsigned long mem, + unsigned long *pgdir_addr, + const char *initrd, unsigned long *ird_size, + unsigned long *page_offset) +{ +#ifdef CONFIG_X86_64 + void *addr; + Elf64_Phdr phdr[ehdr->e_phnum]; + unsigned int i; + Elf64_Shdr sec[ehdr->e_shnum]; + Elf64_Sym *syms; + char *strtab = NULL; + unsigned long nsyms = 0; + + /* Sanity checks. */ + if (ehdr->e_type != ET_EXEC + || ehdr->e_machine != EM_X86_64 + || ehdr->e_phentsize != sizeof(Elf64_Phdr) + || ehdr->e_phn...
2013 Dec 01
0
[PATCH v2 4/4] efi: PE file size differ from in-memory size
...; if (e32_hdr.e_ident[EI_CLASS] == ELFCLASS32) { id = e32_hdr.e_ident; class = ELFCLASS32; entry = e32_hdr.e_entry; - shoff = e32_hdr.e_shoff; - shnum = e32_hdr.e_shnum; - shstrndx = e32_hdr.e_shstrndx; - shentsize = e32_hdr.e_shentsize; + phoff = e32_hdr.e_phoff; + phnum = e32_hdr.e_phnum; + phentsize = e32_hdr.e_phentsize; } else if (e32_hdr.e_ident[EI_CLASS] == ELFCLASS64) { /* read the header again for x86_64 @@ -217,10 +210,9 @@ int main(int argc, char **argv) fread((void *)&e64_hdr, sizeof(e64_hdr), 1, f_in); id = e64_hdr.e_ident; entry = e64_hdr.e_entry;...
2007 Apr 18
0
[RFC/PATCH LGUEST X86_64 07/13] lguest64 loader
...turn (unsigned long)pgdir; +} + +/* Returns the entry point */ +static u32 map_elf(int elf_fd, const Elf32_Ehdr *ehdr, unsigned long mem, + unsigned long *pgdir_addr, + const char *initrd, unsigned long *ird_size, + unsigned long *page_offset) +{ + void *addr; + Elf32_Phdr phdr[ehdr->e_phnum]; + unsigned int i; + + /* Sanity checks. */ + if (ehdr->e_type != ET_EXEC + || ehdr->e_machine != EM_386 + || ehdr->e_phentsize != sizeof(Elf32_Phdr) + || ehdr->e_phnum < 1 || ehdr->e_phnum > 65536U/sizeof(Elf32_Phdr)) + errx(1, "Malformed elf header");...
2007 Apr 18
0
[RFC/PATCH LGUEST X86_64 07/13] lguest64 loader
...turn (unsigned long)pgdir; +} + +/* Returns the entry point */ +static u32 map_elf(int elf_fd, const Elf32_Ehdr *ehdr, unsigned long mem, + unsigned long *pgdir_addr, + const char *initrd, unsigned long *ird_size, + unsigned long *page_offset) +{ + void *addr; + Elf32_Phdr phdr[ehdr->e_phnum]; + unsigned int i; + + /* Sanity checks. */ + if (ehdr->e_type != ET_EXEC + || ehdr->e_machine != EM_386 + || ehdr->e_phentsize != sizeof(Elf32_Phdr) + || ehdr->e_phnum < 1 || ehdr->e_phnum > 65536U/sizeof(Elf32_Phdr)) + errx(1, "Malformed elf header");...
2013 Nov 27
0
[PATCH 4/4] efi: PE file size differ from in-memory size
...; if (e32_hdr.e_ident[EI_CLASS] == ELFCLASS32) { id = e32_hdr.e_ident; class = ELFCLASS32; entry = e32_hdr.e_entry; - shoff = e32_hdr.e_shoff; - shnum = e32_hdr.e_shnum; - shstrndx = e32_hdr.e_shstrndx; - shentsize = e32_hdr.e_shentsize; + phoff = e32_hdr.e_phoff; + phnum = e32_hdr.e_phnum; + phentsize = e32_hdr.e_phentsize; } else if (e32_hdr.e_ident[EI_CLASS] == ELFCLASS64) { /* read the header again for x86_64 @@ -213,10 +206,9 @@ int main(int argc, char **argv) fread((void *)&e64_hdr, sizeof(e64_hdr), 1, f_in); id = e64_hdr.e_ident; entry = e64_hdr.e_entry;...
2007 May 09
0
[patch 9/9] lguest: the documentation, example launcher
...(long)p + strlen("GenuineLguest") + page_offset; + + err(1, "Is this image a genuine lguest?"); +} + +/* Returns the entry point */ +static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr, + unsigned long *page_offset) +{ + void *addr; + Elf32_Phdr phdr[ehdr->e_phnum]; + unsigned int i; + unsigned long start = -1UL, end = 0; + + /* Sanity checks. */ + if (ehdr->e_type != ET_EXEC + || ehdr->e_machine != EM_386 + || ehdr->e_phentsize != sizeof(Elf32_Phdr) + || ehdr->e_phnum < 1 || ehdr->e_phnum > 65536U/sizeof(Elf32_Phdr)) + errx...
2007 May 09
0
[patch 9/9] lguest: the documentation, example launcher
...(long)p + strlen("GenuineLguest") + page_offset; + + err(1, "Is this image a genuine lguest?"); +} + +/* Returns the entry point */ +static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr, + unsigned long *page_offset) +{ + void *addr; + Elf32_Phdr phdr[ehdr->e_phnum]; + unsigned int i; + unsigned long start = -1UL, end = 0; + + /* Sanity checks. */ + if (ehdr->e_type != ET_EXEC + || ehdr->e_machine != EM_386 + || ehdr->e_phentsize != sizeof(Elf32_Phdr) + || ehdr->e_phnum < 1 || ehdr->e_phnum > 65536U/sizeof(Elf32_Phdr)) + errx...