Displaying 20 results from an estimated 45 matches for "e_phoff".
2015 Oct 10
3
[PATCH] Extend Multiboot1 with support for ELF64 file format
...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_machine != EM_X86_64) |...
2015 Jul 21
5
[LLVMdev] Some thought on handling ELF shared libraries in lld
Most ELF shared libraries can be sliced in two ways. One is following
the information in the program headers (e_phoff). The other is
following the information in the section headers (e_shoff).
Regular relocatable objects only have the section header.
At runtime, the dynamic linker only uses the program headers. In fact,
the section headers is optional.
When given a shared library, how should the static linker h...
2007 Apr 18
2
[PATCH] exec-shield style vdso move.
...(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 struct elf_phdr *) (__VSYSCALL_BASE \
+ + __VSYSCALL_EHDR->e_phoff); \
int i; \
Elf32_Off ofs = 0; \
- for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) { \
+ for (i = 0; i < __VSYSCALL_EHDR->e_phnum; ++i) {...
2007 Apr 18
2
[PATCH] exec-shield style vdso move.
...(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 struct elf_phdr *) (__VSYSCALL_BASE \
+ + __VSYSCALL_EHDR->e_phoff); \
int i; \
Elf32_Off ofs = 0; \
- for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) { \
+ for (i = 0; i < __VSYSCALL_EHDR->e_phnum; ++i) {...
2013 Dec 01
0
[PATCH v2 4/4] efi: PE file size differ from in-memory size
...r, sizeof(e32_hdr), 1, f_in);
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;...
2013 Nov 27
0
[PATCH 4/4] efi: PE file size differ from in-memory size
...r, sizeof(e32_hdr), 1, f_in);
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;...
2008 Feb 13
4
[PATCHv3 1/3] x86: use ELF format in compressed images.
...r.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 = output;
+ dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
+#else
+ dest = (void*)(phdr->p_paddr);
+#endif...
2008 Feb 13
4
[PATCHv3 1/3] x86: use ELF format in compressed images.
...r.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 = output;
+ dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
+#else
+ dest = (void*)(phdr->p_paddr);
+#endif...
2008 Oct 20
0
PATCH[001/001]: mboot.c: prefer ELF header over multiboot header
...nt[EI_CLASS] != ELFCLASS32
- || ehdr->e_machine != EM_386)
- {
- printf("Fatal: kernel has neither ELF32/x86 nor multiboot load"
- " headers.\n");
- exit(1);
- }
if (ehdr->e_phoff + ehdr->e_phnum*sizeof (*phdr) > load_size) {
printf("Fatal: malformed ELF header overruns EOF.\n");
exit(1);
@@ -760,6 +700,60 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
/* Done! */
return eh...
2013 Nov 27
20
[PATCH 0/4] efi: PE header generation fix
The PE headers of the generated efi file were quite buggy. And since OVMF
perform a few consistency checks, syslinux was unable to run on it. I don't
pretend to have a thorough understanding of the PE+ headers, some bugs may
remain. :)
Celelibi (4):
efi: Fix PE header field rva_and_sizes_nr
efi: Location, size and alignment of .text section
efi: Useless relocations in PE file
efi: PE
2008 Jan 31
0
[PATCH] x86: use ELF format in compressed images.
...r.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,
+ output + phdr->p_offset,
+ phdr->p_filesz);
+ break;
+ default: /* Ignore other PT_* */...
2008 Jan 31
0
[PATCH] x86: use ELF format in compressed images.
...r.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,
+ output + phdr->p_offset,
+ phdr->p_filesz);
+ break;
+ default: /* Ignore other PT_* */...
2008 Feb 06
0
[PATCHv2 1/3] x86: use ELF format in compressed images.
...r.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 = output;
+ dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
+#else
+ dest = (void*)(phdr->p_paddr);
+#endif...
2008 Feb 06
0
[PATCHv2 1/3] x86: use ELF format in compressed images.
...r.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 = output;
+ dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
+#else
+ dest = (void*)(phdr->p_paddr);
+#endif...
2007 Apr 18
2
[RFC, PATCH] Fixup COMPAT_VDSO to work with CONFIG_PARAVIRT
...trcmp(secstrings+sechdrs[i].sh_name, ".useless") =3D=3D 0) {
+ /* This is demonic; see vsyscall.lds.S; it puts the
+ * .got in a section named .useless */
+ uint32_t *got =3D (void *)hdr + sechdrs[i].sh_offset;
+ *got +=3D VDSO_HIGH_BASE;
+ }
+ }
+ phdr =3D (void *)hdr + hdr->e_phoff;
+ for (i =3D 0; i < hdr->e_phnum; i++) {
+ phdr[i].p_vaddr +=3D VDSO_HIGH_BASE;
+ phdr[i].p_paddr +=3D VDSO_HIGH_BASE;
+ }
+
+#if 0
+/* =
+ * To verify the binary image in memory is identical, linked in the VDSO p=
age
+ * from a COMPAT_VDSO compile without this patch; then diff the two....
2007 Apr 18
2
[RFC, PATCH] Fixup COMPAT_VDSO to work with CONFIG_PARAVIRT
...trcmp(secstrings+sechdrs[i].sh_name, ".useless") =3D=3D 0) {
+ /* This is demonic; see vsyscall.lds.S; it puts the
+ * .got in a section named .useless */
+ uint32_t *got =3D (void *)hdr + sechdrs[i].sh_offset;
+ *got +=3D VDSO_HIGH_BASE;
+ }
+ }
+ phdr =3D (void *)hdr + hdr->e_phoff;
+ for (i =3D 0; i < hdr->e_phnum; i++) {
+ phdr[i].p_vaddr +=3D VDSO_HIGH_BASE;
+ phdr[i].p_paddr +=3D VDSO_HIGH_BASE;
+ }
+
+#if 0
+/* =
+ * To verify the binary image in memory is identical, linked in the VDSO p=
age
+ * from a COMPAT_VDSO compile without this patch; then diff the two....
2009 Jan 14
5
[PATCH] Support cross-bitness guest when core-dumping
This patch allows core-dumping to work on a cross-bit host/guest configuration, whereas previously that was not supported. It supports both PV and FV guests. The core file format generated by the host, needs to match that of the guest, so an alignment issue is addressed, along with the p2m frame list handling being done according to the guest size.
Signed-off-by: Bruce Rogers
2007 Mar 05
7
[PATCH 2/10] linux 2.6.18: COMPAT_VDSO
...N(ehdr->e_ident[EI_DATA] != ELFDATA2LSB);
+ BUG_ON(ehdr->e_ehsize < sizeof(*ehdr));
+ ehdr->e_entry += new_base - old_base;
+ BUG_ON(ehdr->e_phentsize < sizeof(Elf32_Phdr));
+ for (i = 0; i < ehdr->e_phnum; ++i) {
+ Elf32_Phdr *phdr = (void *)((unsigned long)ehdr + ehdr->e_phoff + i * ehdr->e_phentsize);
+
+ phdr->p_vaddr += new_base - old_base;
+ switch(phdr->p_type) {
+ case PT_LOAD:
+ case PT_NOTE:
+ break;
+ case PT_DYNAMIC: {
+ Elf32_Dyn *dyn = (void *)(phdr->p_vaddr - new_base + (unsigned long)ehdr);
+ unsigned j;
+
+ for(j = 0; dyn[j].d_t...
2007 Mar 05
7
[PATCH 2/10] linux 2.6.18: COMPAT_VDSO
...N(ehdr->e_ident[EI_DATA] != ELFDATA2LSB);
+ BUG_ON(ehdr->e_ehsize < sizeof(*ehdr));
+ ehdr->e_entry += new_base - old_base;
+ BUG_ON(ehdr->e_phentsize < sizeof(Elf32_Phdr));
+ for (i = 0; i < ehdr->e_phnum; ++i) {
+ Elf32_Phdr *phdr = (void *)((unsigned long)ehdr + ehdr->e_phoff + i * ehdr->e_phentsize);
+
+ phdr->p_vaddr += new_base - old_base;
+ switch(phdr->p_type) {
+ case PT_LOAD:
+ case PT_NOTE:
+ break;
+ case PT_DYNAMIC: {
+ Elf32_Dyn *dyn = (void *)(phdr->p_vaddr - new_base + (unsigned long)ehdr);
+ unsigned j;
+
+ for(j = 0; dyn[j].d_t...
2007 Mar 05
7
[PATCH 2/10] linux 2.6.18: COMPAT_VDSO
...N(ehdr->e_ident[EI_DATA] != ELFDATA2LSB);
+ BUG_ON(ehdr->e_ehsize < sizeof(*ehdr));
+ ehdr->e_entry += new_base - old_base;
+ BUG_ON(ehdr->e_phentsize < sizeof(Elf32_Phdr));
+ for (i = 0; i < ehdr->e_phnum; ++i) {
+ Elf32_Phdr *phdr = (void *)((unsigned long)ehdr + ehdr->e_phoff + i * ehdr->e_phentsize);
+
+ phdr->p_vaddr += new_base - old_base;
+ switch(phdr->p_type) {
+ case PT_LOAD:
+ case PT_NOTE:
+ break;
+ case PT_DYNAMIC: {
+ Elf32_Dyn *dyn = (void *)(phdr->p_vaddr - new_base + (unsigned long)ehdr);
+ unsigned j;
+
+ for(j = 0; dyn[j].d_t...