Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/dbghelp/elf_module.c | 29 +++++++++++++++++++++++++++-- dlls/dbghelp/image_private.h | 4 +--- 2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index d0b483a..edf32b5 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -351,8 +351,33 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map*
fmap->addr_size = e_ident[EI_CLASS] == ELFCLASS64 ? 64 : 32;
- if (!elf_map_file_read(fmap, emfd, &fmap->u.elf.elfhdr, sizeof(fmap->u.elf.elfhdr), 0)) - goto done; + if (fmap->addr_size == 32) + { + Elf32_Ehdr elfhdr32; + + if (!elf_map_file_read(fmap, emfd, &elfhdr32, sizeof(elfhdr32), 0)) + goto done; + + memcpy(fmap->u.elf.elfhdr.e_ident, elfhdr32.e_ident, EI_NIDENT); + fmap->u.elf.elfhdr.e_type = elfhdr32.e_type; + fmap->u.elf.elfhdr.e_machine = elfhdr32.e_machine; + fmap->u.elf.elfhdr.e_version = elfhdr32.e_version; + fmap->u.elf.elfhdr.e_entry = elfhdr32.e_entry; + fmap->u.elf.elfhdr.e_phoff = elfhdr32.e_phoff; + fmap->u.elf.elfhdr.e_shoff = elfhdr32.e_shoff; + fmap->u.elf.elfhdr.e_flags = elfhdr32.e_flags; + fmap->u.elf.elfhdr.e_ehsize = elfhdr32.e_ehsize; + fmap->u.elf.elfhdr.e_phentsize = elfhdr32.e_phentsize; + fmap->u.elf.elfhdr.e_phnum = elfhdr32.e_phnum; + fmap->u.elf.elfhdr.e_shentsize = elfhdr32.e_shentsize; + fmap->u.elf.elfhdr.e_shnum = elfhdr32.e_shnum; + fmap->u.elf.elfhdr.e_shstrndx = elfhdr32.e_shstrndx; + } + else + { + if (!elf_map_file_read(fmap, emfd, &fmap->u.elf.elfhdr, sizeof(fmap->u.elf.elfhdr), 0)) + goto done; + }
fmap->u.elf.sect = HeapAlloc(GetProcessHeap(), 0, fmap->u.elf.elfhdr.e_shnum * sizeof(fmap->u.elf.sect[0])); diff --git a/dlls/dbghelp/image_private.h b/dlls/dbghelp/image_private.h index 429b8fb..fa15000 100644 --- a/dlls/dbghelp/image_private.h +++ b/dlls/dbghelp/image_private.h @@ -59,14 +59,12 @@ typedef struct section macho_section; #ifdef __ELF__
#ifdef _WIN64 -#define Elf_Ehdr Elf64_Ehdr #define Elf_Shdr Elf64_Shdr #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_Ehdr Elf32_Ehdr #define Elf_Shdr Elf32_Shdr #define Elf_Phdr Elf32_Phdr #define Elf_Dyn Elf32_Dyn @@ -97,7 +95,7 @@ struct image_file_map struct image_file_map* alternate; /* another ELF file (linked to this one) */ char* target_copy; #ifdef __ELF__ - Elf_Ehdr elfhdr; + Elf64_Ehdr elfhdr; struct { Elf_Shdr shdr;