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

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id bd620ffb443eaa2dba997dc5597cb37c44d757b7 by Zebediah Figura <zfigura@codeweavers.com>
This commit is contained in:
winesync 2020-09-11 13:04:09 +02:00 committed by Jérôme Gardou
parent 8428b1f8c3
commit 48c551a237
3 changed files with 25 additions and 10 deletions

View File

@ -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

View File

@ -61,12 +61,10 @@ typedef struct section macho_section;
#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
#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

View File

@ -3,4 +3,4 @@ directories:
files:
include/dbghelp.h: sdk/include/psdk/dbghelp.h
tags:
wine: cf78601b3781e64ea2745cf8084848acb69300a8
wine: bd620ffb443eaa2dba997dc5597cb37c44d757b7