search for: p_filesz

Displaying 20 results from an estimated 39 matches for "p_filesz".

2025 Apr 21
0
[PATCH] Permit zero-sized ELF program sections
...o load the ldlinux.e32 file. The issue occurs in com32/lib/sys/module/i386/elf_module.c in the load_segments() function, particularly when iterating through the module's program headers and loading the PT_LOAD ones. The code hits a program section which has a zero on-disk size, the cr_pht->p_filesz field is 0, and looking at the cr_pht->p_vaddr and comparing that with an objdump of the ldlinux.e32 file, that was the .BSS section, and it's reasonable for it to not be stored in the file, the memory should be initialized to zero, and the System V ABI document, chapter 5 [0] specifies that...
2020 Aug 13
2
Adding sections in a binary
...not part 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...
2015 Oct 10
3
[PATCH] Extend Multiboot1 with support for ELF64 file format
...r 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%08x\n", + addr, dsize, msize); + + if (sys...
2007 May 06
1
[PATCH 1/3] lguest: 2.6.21-mm1 update: lguest-remove-unnecessary-gdt-load.patch
Andrew did a great job of merging in the PDA->percpu changes and lguest code for 2.6.21-mm1, but the load_gdt is now unnecessary. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> --- drivers/lguest/lguest.c | 4 ---- 1 file changed, 4 deletions(-) =================================================================== --- a/drivers/lguest/lguest.c +++ b/drivers/lguest/lguest.c @@
2007 May 06
1
[PATCH 1/3] lguest: 2.6.21-mm1 update: lguest-remove-unnecessary-gdt-load.patch
Andrew did a great job of merging in the PDA->percpu changes and lguest code for 2.6.21-mm1, but the load_gdt is now unnecessary. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> --- drivers/lguest/lguest.c | 4 ---- 1 file changed, 4 deletions(-) =================================================================== --- a/drivers/lguest/lguest.c +++ b/drivers/lguest/lguest.c @@
2013 Dec 01
0
[PATCH v2 4/4] efi: PE file size differ from in-memory size
...PT_LOAD) break; } - 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); -...
2013 Nov 27
0
[PATCH 4/4] efi: PE file size differ from in-memory size
...PT_LOAD) break; } - 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); -...
2007 May 31
1
[patch rfc wip] first cut of ELF bzImage
...ntsize + .word 0 # e_shnum + .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_s...
2007 May 31
1
[patch rfc wip] first cut of ELF bzImage
...ntsize + .word 0 # e_shnum + .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_s...
2007 Apr 18
1
[PATCH 0/2] Use a single loader for i386 and x86_64
...1, "Segment %i overlaps end of memory", i); @@ -227,6 +244,77 @@ static u32 map_elf(int elf_fd, const Elf phdr[i].p_offset -= (phdr[i].p_paddr % getpagesize()); phdr[i].p_paddr -= (phdr[i].p_paddr % getpagesize()); } + addr = mmap((void *)(long)phdr[i].p_paddr, + phdr[i].p_filesz, + PROT_READ|PROT_WRITE|PROT_EXEC, + MAP_FIXED|MAP_PRIVATE, + elf_fd, phdr[i].p_offset); + if (addr != (void *)(long)phdr[i].p_paddr) + err(1, "Mmaping vmlinux segment %i returned %p not %p (%p)", + i, addr, (void *)(long)phdr[i].p_paddr, &phdr[i].p_paddr);...
2007 Apr 18
1
[PATCH 0/2] Use a single loader for i386 and x86_64
...1, "Segment %i overlaps end of memory", i); @@ -227,6 +244,77 @@ static u32 map_elf(int elf_fd, const Elf phdr[i].p_offset -= (phdr[i].p_paddr % getpagesize()); phdr[i].p_paddr -= (phdr[i].p_paddr % getpagesize()); } + addr = mmap((void *)(long)phdr[i].p_paddr, + phdr[i].p_filesz, + PROT_READ|PROT_WRITE|PROT_EXEC, + MAP_FIXED|MAP_PRIVATE, + elf_fd, phdr[i].p_offset); + if (addr != (void *)(long)phdr[i].p_paddr) + err(1, "Mmaping vmlinux segment %i returned %p not %p (%p)", + i, addr, (void *)(long)phdr[i].p_paddr, &phdr[i].p_paddr);...
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
..., dbgprintf_phdr("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_in...
2008 Feb 13
4
[PATCHv3 1/3] x86: use ELF format in compressed images.
...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 + memcpy(dest, + output + phdr->p_offset, + phdr->p_filesz); + break; + default: /* Ignore other PT_* */ break; + } + } +} + asmlinkage void decompress_kernel(void *rmode, memptr heap, uch *input_data, unsigned long input_len, uch *output) @@ -408,6 +463,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, makecrc(); puts...
2008 Feb 13
4
[PATCHv3 1/3] x86: use ELF format in compressed images.
...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 + memcpy(dest, + output + phdr->p_offset, + phdr->p_filesz); + break; + default: /* Ignore other PT_* */ break; + } + } +} + asmlinkage void decompress_kernel(void *rmode, memptr heap, uch *input_data, unsigned long input_len, uch *output) @@ -408,6 +463,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, makecrc(); puts...
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
...@ dbgprintf_phdr("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-&...
2008 Jan 31
0
[PATCH] x86: use ELF format in compressed images.
...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_* */ break; + } + } +} + asmlinkage void decompress_kernel(void *rmode, memptr heap, uch *input_data, unsigned long input_len, uch *output) @@ -408,6 +456,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, makecrc(); puts...
2008 Jan 31
0
[PATCH] x86: use ELF format in compressed images.
...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_* */ break; + } + } +} + asmlinkage void decompress_kernel(void *rmode, memptr heap, uch *input_data, unsigned long input_len, uch *output) @@ -408,6 +456,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, makecrc(); puts...
2008 Feb 06
0
[PATCHv2 1/3] x86: use ELF format in compressed images.
...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 + memcpy(dest, + output + phdr->p_offset, + phdr->p_filesz); + break; + default: /* Ignore other PT_* */ break; + } + } +} + asmlinkage void decompress_kernel(void *rmode, memptr heap, uch *input_data, unsigned long input_len, uch *output) @@ -408,6 +463,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, makecrc(); puts...