Commit bd620ffb authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

dbghelp: Read the ELF program header corresponding to the target's architecture.

parent 88a6936d
...@@ -332,7 +332,6 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* ...@@ -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 }; static const BYTE elf_signature[4] = { ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3 };
struct stat statbuf; struct stat statbuf;
unsigned int i; unsigned int i;
Elf_Phdr phdr;
size_t tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1; size_t tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1;
char* filename; char* filename;
unsigned len; unsigned len;
...@@ -429,13 +428,31 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map* ...@@ -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; fmap->u.elf.elf_start = ~0L;
for (i = 0; i < fmap->u.elf.elfhdr.e_phnum; i++) for (i = 0; i < fmap->u.elf.elfhdr.e_phnum; i++)
{ {
if (elf_map_file_read(fmap, emfd, &phdr, sizeof(phdr), if (fmap->addr_size == 32)
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; Elf32_Phdr phdr;
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 (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 /* if non relocatable ELF, then remove fixed address from computation
......
...@@ -59,12 +59,10 @@ typedef struct section macho_section; ...@@ -59,12 +59,10 @@ typedef struct section macho_section;
#ifdef __ELF__ #ifdef __ELF__
#ifdef _WIN64 #ifdef _WIN64
#define Elf_Phdr Elf64_Phdr
#define Elf_Dyn Elf64_Dyn #define Elf_Dyn Elf64_Dyn
#define Elf_Sym Elf64_Sym #define Elf_Sym Elf64_Sym
#define Elf_auxv_t Elf64_auxv_t #define Elf_auxv_t Elf64_auxv_t
#else #else
#define Elf_Phdr Elf32_Phdr
#define Elf_Dyn Elf32_Dyn #define Elf_Dyn Elf32_Dyn
#define Elf_Sym Elf32_Sym #define Elf_Sym Elf32_Sym
#define Elf_auxv_t Elf32_auxv_t #define Elf_auxv_t Elf32_auxv_t
......
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