Commit 799e0bfa authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

dbghelp: Translate the 32-bit ELF header to the 64-bit one.

parent a612f1f5
......@@ -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]));
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment