Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/dbghelp/elf_module.c | 31 ++++++++++++++++++++++++------- dlls/dbghelp/image_private.h | 2 -- 2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index 8049210..f84df83 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -332,7 +332,6 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* static const BYTE elf_signature[4] = { ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3 }; struct stat statbuf; unsigned int i; - Elf_Phdr phdr; size_t tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1; char* filename; unsigned len; @@ -429,13 +428,31 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* fmap->u.elf.elf_start = ~0L; for (i = 0; i < fmap->u.elf.elfhdr.e_phnum; i++) { - if (elf_map_file_read(fmap, emfd, &phdr, sizeof(phdr), - fmap->u.elf.elfhdr.e_phoff + i * sizeof(phdr)) && - phdr.p_type == PT_LOAD) + if (fmap->addr_size == 32) { - tmp = (phdr.p_vaddr + phdr.p_memsz + page_mask) & ~page_mask; - if (fmap->u.elf.elf_size < tmp) fmap->u.elf.elf_size = tmp; - if (phdr.p_vaddr < fmap->u.elf.elf_start) fmap->u.elf.elf_start = phdr.p_vaddr; + Elf32_Phdr phdr; + + if (elf_map_file_read(fmap, emfd, &phdr, sizeof(phdr), + fmap->u.elf.elfhdr.e_phoff + i * sizeof(phdr)) && + phdr.p_type == PT_LOAD) + { + tmp = (phdr.p_vaddr + phdr.p_memsz + page_mask) & ~page_mask; + if (fmap->u.elf.elf_size < tmp) fmap->u.elf.elf_size = tmp; + if (phdr.p_vaddr < fmap->u.elf.elf_start) fmap->u.elf.elf_start = phdr.p_vaddr; + } + } + else + { + Elf64_Phdr phdr; + + if (elf_map_file_read(fmap, emfd, &phdr, sizeof(phdr), + fmap->u.elf.elfhdr.e_phoff + i * sizeof(phdr)) && + phdr.p_type == PT_LOAD) + { + tmp = (phdr.p_vaddr + phdr.p_memsz + page_mask) & ~page_mask; + if (fmap->u.elf.elf_size < tmp) fmap->u.elf.elf_size = tmp; + if (phdr.p_vaddr < fmap->u.elf.elf_start) fmap->u.elf.elf_start = phdr.p_vaddr; + } } } /* if non relocatable ELF, then remove fixed address from computation diff --git a/dlls/dbghelp/image_private.h b/dlls/dbghelp/image_private.h index 42781e4..3951464 100644 --- a/dlls/dbghelp/image_private.h +++ b/dlls/dbghelp/image_private.h @@ -59,12 +59,10 @@ typedef struct section macho_section; #ifdef __ELF__
#ifdef _WIN64 -#define Elf_Phdr Elf64_Phdr #define Elf_Dyn Elf64_Dyn #define Elf_Sym Elf64_Sym #define Elf_auxv_t Elf64_auxv_t #else -#define Elf_Phdr Elf32_Phdr #define Elf_Dyn Elf32_Dyn #define Elf_Sym Elf32_Sym #define Elf_auxv_t Elf32_auxv_t