search for: p_memsz

Displaying 20 results from an estimated 33 matches for "p_memsz".

2020 Aug 13
2
Adding sections in a binary
...of the memory image and not used by the program (unless for some rare introspection use cases) * adding a SHF_ALLOC section is difficult. You likely need to fix the containing PT_LOAD segment. llvm-objcopy only does the base p_offset fix. You need to take care p_vaddr/p_paddr/p_filesz/p_memsz by your self. + adding a section smaller than the known lowest address (ET_EXEC with a non-zero image base) or larger than the known largest address: The PT_LOAD fixes are doable. + adding a section within the existing address ranges: this is very difficult due to many implici...
2007 Apr 18
1
[PATCH 0/2] Use a single loader for i386 and x86_64
...lf32_Ehdr *ehdr, unsigned long mem, unsigned long *pgdir_addr, const char *initrd, unsigned long *ird_size, unsigned long *page_offset) @@ -210,7 +227,7 @@ static u32 map_elf(int elf_fd, const Elf continue; verbose("Section %i: size %i addr %p\n", - i, phdr[i].p_memsz, (void *)phdr[i].p_paddr); + i, phdr[i].p_memsz, (void *)(long)phdr[i].p_paddr); /* We map everything private, writable. */ if (phdr[i].p_paddr + phdr[i].p_memsz > mem) errx(1, "Segment %i overlaps end of memory", i); @@ -227,6 +244,77 @@ static u32 map_elf(int elf_fd, cons...
2007 Apr 18
1
[PATCH 0/2] Use a single loader for i386 and x86_64
...lf32_Ehdr *ehdr, unsigned long mem, unsigned long *pgdir_addr, const char *initrd, unsigned long *ird_size, unsigned long *page_offset) @@ -210,7 +227,7 @@ static u32 map_elf(int elf_fd, const Elf continue; verbose("Section %i: size %i addr %p\n", - i, phdr[i].p_memsz, (void *)phdr[i].p_paddr); + i, phdr[i].p_memsz, (void *)(long)phdr[i].p_paddr); /* We map everything private, writable. */ if (phdr[i].p_paddr + phdr[i].p_memsz > mem) errx(1, "Segment %i overlaps end of memory", i); @@ -227,6 +244,77 @@ static u32 map_elf(int elf_fd, cons...
2007 May 31
1
[patch rfc wip] first cut of ELF bzImage
...m + .word 0 # e_shstrndx +e_ehdr: + + .org 71 +normalize: # Normalize the start address ljmp $BOOTSEG, $start2 + + .org 80 +phdr: + .int PT_LOAD # p_type + .int _text # p_offset + .int 0x8000 # p_vaddr + .int 0x8000 # p_paddr + .int _filesz # p_filesz + .int _memsz # p_memsz + .int PF_R | PF_W | PF_X # p_flags + .int 4 # p_align +e_phdr1: + .int PT_LOAD # p_type + .int kernel - bootsect_start # p_offset + .int LOAD_PHYSICAL_ADDR # p_vaddr + .int LOAD_PHYSICAL_ADDR # p_paddr + .int kernel_size # p_filesz + .int kernel_size # p_memsz + .int PF_R...
2007 May 31
1
[patch rfc wip] first cut of ELF bzImage
...m + .word 0 # e_shstrndx +e_ehdr: + + .org 71 +normalize: # Normalize the start address ljmp $BOOTSEG, $start2 + + .org 80 +phdr: + .int PT_LOAD # p_type + .int _text # p_offset + .int 0x8000 # p_vaddr + .int 0x8000 # p_paddr + .int _filesz # p_filesz + .int _memsz # p_memsz + .int PF_R | PF_W | PF_X # p_flags + .int 4 # p_align +e_phdr1: + .int PT_LOAD # p_type + .int kernel - bootsect_start # p_offset + .int LOAD_PHYSICAL_ADDR # p_vaddr + .int LOAD_PHYSICAL_ADDR # p_paddr + .int kernel_size # p_filesz + .int kernel_size # p_memsz + .int PF_R...
2013 Dec 01
0
[PATCH v2 4/4] efi: PE file size differ from in-memory size
...- if (i == shnum) { - fprintf(stderr, "Failed to find .bss section\n"); - exit(EXIT_FAILURE); - } - - datasz = shdr.sh_offset; - } - else if (e32_hdr.e_ident[EI_CLASS] == ELFCLASS64) { - const char *shstrtab, *name; - Elf64_Shdr shdr; + datasz = phdr.p_filesz; + memsz = phdr.p_memsz; + } else if (e32_hdr.e_ident[EI_CLASS] == ELFCLASS64) { + Elf64_Phdr phdr; int i; - void *strtab; - - fseek(f_in, shoff, SEEK_SET); - /* First find the strtab section */ - fseek(f_in, shstrndx * shentsize, SEEK_CUR); - fread(&shdr, sizeof(shdr), 1, f_in); - - strtab = malloc(shdr.s...
2013 Nov 27
0
[PATCH 4/4] efi: PE file size differ from in-memory size
...- if (i == shnum) { - fprintf(stderr, "Failed to find .bss section\n"); - exit(EXIT_FAILURE); - } - - datasz = shdr.sh_offset; - } - else if (e32_hdr.e_ident[EI_CLASS] == ELFCLASS64) { - const char *shstrtab, *name; - Elf64_Shdr shdr; + datasz = phdr.p_filesz; + memsz = phdr.p_memsz; + } else if (e32_hdr.e_ident[EI_CLASS] == ELFCLASS64) { + Elf64_Phdr phdr; int i; - void *strtab; - - fseek(f_in, shoff, SEEK_SET); - /* First find the strtab section */ - fseek(f_in, shstrndx * shentsize, SEEK_CUR); - fread(&shdr, sizeof(shdr), 1, f_in); - - strtab = malloc(shdr.s...
2020 Aug 13
2
Adding sections in a binary
Hey, LLVM has logic to parse ELF and PE binaries using `llvm::object::createBinary`. I tried to search in the codebase to see if there's a possibility to add/remove sections after parsing a binary and re-write the binary to another location. Basically, like what llvm-objcopy does. Can you point me to the right classes to look into, if this is something that LLVM has? Many thanks Joseph
2012 Jul 05
10
[PATCH] kexec-tools: Read always one vmcoreinfo file
..."vmcoreinfo header", phdr); } - if (has_vmcoreinfo_xen) { - phdr = (PHDR *) bufp; - bufp += sizeof(PHDR); - phdr->p_type = PT_NOTE; - phdr->p_flags = 0; - phdr->p_offset = phdr->p_paddr = vmcoreinfo_addr_xen; - phdr->p_vaddr = 0; - phdr->p_filesz = phdr->p_memsz = vmcoreinfo_len_xen; - /* Do we need any alignment of segments? */ - phdr->p_align = 0; - - (elf->e_phnum)++; - dbgprintf_phdr("vmcoreinfo_xen header", phdr); - } - /* Setup an PT_LOAD type program header for the region where * Kernel is mapped if elf_info->kern_size is...
2015 Oct 10
3
[PATCH] Extend Multiboot1 with support for ELF64 file format
...wever, if + * e_entry falls within the p_vaddr range of this PHDR, then + * adjust it to match the p_paddr range... this is how Grub + * behaves, so it's by definition correct (it doesn't have to + * make sense...) + */ + addr_t addr = ph64->p_paddr; + addr_t msize = ph64->p_memsz; + addr_t dsize = min(msize, ph64->p_filesz); + + if (eh64->e_entry >= ph64->p_vaddr + && eh64->e_entry < ph64->p_vaddr + msize) + regs.eip = eh64->e_entry + (ph64->p_paddr - ph64->p_vaddr); + + dprintf("Segment at 0x%08x data 0x%08x len 0x%08...
2007 Jun 06
7
[PATCH RFC 0/7] proposed updates to boot protocol and paravirt booting
This series: 1. Updates the boot protocol to version 2.07 2. Clean up the existing build process, to get rid of tools/build and make the linker do more heavy lifting 3. Make the bzImage payload an ELF file. The bootloader can extract this as a naked ELF file by skipping over boot_params.setup_sects worth of 16-bit setup code. 4. Update the boot_params to 2.07, and update the
2007 Jun 06
7
[PATCH RFC 0/7] proposed updates to boot protocol and paravirt booting
This series: 1. Updates the boot protocol to version 2.07 2. Clean up the existing build process, to get rid of tools/build and make the linker do more heavy lifting 3. Make the bzImage payload an ELF file. The bootloader can extract this as a naked ELF file by skipping over boot_params.setup_sects worth of 16-bit setup code. 4. Update the boot_params to 2.07, and update the
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 Mar 31
3
[PATCH 3/4] extract vmcoreinfo from /proc/vmcore for Xen
..."vmcoreinfo header", phdr); } + if (has_vmcoreinfo_xen) { + phdr = (PHDR *) bufp; + bufp += sizeof(PHDR); + phdr->p_type = PT_NOTE; + phdr->p_flags = 0; + phdr->p_offset = phdr->p_paddr = vmcoreinfo_addr_xen; + phdr->p_vaddr = 0; + phdr->p_filesz = phdr->p_memsz = vmcoreinfo_len_xen; + /* Do we need any alignment of segments? */ + phdr->p_align = 0; + + (elf->e_phnum)++; + dbgprintf_phdr("vmcoreinfo_xen header", phdr); + } + /* Setup an PT_LOAD type program header for the region where * Kernel is mapped if info->kern_size is non...
2007 Apr 18
0
[RFC/PATCH LGUEST X86_64 07/13] lguest64 loader
...* We map the loadable segments at virtual addresses corresponding + * to their physical addresses (our virtual == guest physical). */ + for (i = 0; i < ehdr->e_phnum; i++) { + if (phdr[i].p_type != PT_LOAD) + continue; + + verbose("Section %i: size %i addr %p\n", + i, phdr[i].p_memsz, (void *)phdr[i].p_paddr); + /* We map everything private, writable. */ + if (phdr[i].p_paddr + phdr[i].p_memsz > mem) + errx(1, "Segment %i overlaps end of memory", i); + + /* We expect linear address space. */ + if (!*page_offset) + *page_offset = phdr[i].p_vaddr - phdr[i].p_...
2007 Apr 18
0
[RFC/PATCH LGUEST X86_64 07/13] lguest64 loader
...* We map the loadable segments at virtual addresses corresponding + * to their physical addresses (our virtual == guest physical). */ + for (i = 0; i < ehdr->e_phnum; i++) { + if (phdr[i].p_type != PT_LOAD) + continue; + + verbose("Section %i: size %i addr %p\n", + i, phdr[i].p_memsz, (void *)phdr[i].p_paddr); + /* We map everything private, writable. */ + if (phdr[i].p_paddr + phdr[i].p_memsz > mem) + errx(1, "Segment %i overlaps end of memory", i); + + /* We expect linear address space. */ + if (!*page_offset) + *page_offset = phdr[i].p_vaddr - phdr[i].p_...
2007 Jun 15
11
[PATCH 00/10] paravirt/subarchitecture boot protocol
This series updates the boot protocol to 2.07 and uses it to implement paravirtual booting. This allows the bootloader to tell the kernel what kind of hardware/pseudo-hardware environment it's coming up under, and the kernel can use the appropriate boot sequence code. Specifically: - Update the boot protocol to 2.07, which adds fields to specify the hardware subarchitecture and some
2007 Jun 15
11
[PATCH 00/10] paravirt/subarchitecture boot protocol
This series updates the boot protocol to 2.07 and uses it to implement paravirtual booting. This allows the bootloader to tell the kernel what kind of hardware/pseudo-hardware environment it's coming up under, and the kernel can use the appropriate boot sequence code. Specifically: - Update the boot protocol to 2.07, which adds fields to specify the hardware subarchitecture and some
2007 Jun 15
11
[PATCH 00/10] paravirt/subarchitecture boot protocol
This series updates the boot protocol to 2.07 and uses it to implement paravirtual booting. This allows the bootloader to tell the kernel what kind of hardware/pseudo-hardware environment it's coming up under, and the kernel can use the appropriate boot sequence code. Specifically: - Update the boot protocol to 2.07, which adds fields to specify the hardware subarchitecture and some
2007 Jun 01
2
another RFC patch: bzImage with ELF payload
...nts define the permissions on sections in the program header, p_flags. */ @@ -230,6 +237,7 @@ struct elf64_hdr { #define PF_W 0x2 #define PF_X 0x1 +#ifndef __ASSEMBLY__ struct elf32_phdr { Elf32_Word p_type; Elf32_Off p_offset; @@ -251,6 +259,7 @@ struct elf64_phdr { Elf64_Xword p_memsz; /* Segment size in memory */ Elf64_Xword p_align; /* Segment alignment, file & memory */ }; +#endif /* __ASSEMBLY__ */ /* sh_type */ #define SHT_NULL 0 @@ -285,7 +294,8 @@ struct elf64_phdr { #define SHN_ABS 0xfff1 #define SHN_COMMON 0xfff2 #define SHN_HIRESERVE 0xffff - + +#ifn...