https://git.reactos.org/?p=reactos.git;a=commitdiff;h=23a2d2713d732b1e1a63db...
commit 23a2d2713d732b1e1a63db0824536a576981bf2a Author: winesync ros-dev@reactos.org AuthorDate: Fri Sep 11 13:03:11 2020 +0200 Commit: Jérôme Gardou jerome.gardou@reactos.org CommitDate: Wed Sep 16 10:35:32 2020 +0200
[WINESYNC] dbghelp: Translate the 32-bit ELF section header to the 64-bit one.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
wine commit id 4005901773bf1842804c40d928a944623e11d238 by Zebediah Figura zfigura@codeweavers.com --- dll/win32/dbghelp/elf_module.c | 35 ++++++++++++++++++++++++++++++++--- dll/win32/dbghelp/image_private.h | 4 +--- sdk/tools/winesync/dbghelp.cfg | 2 +- 3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index edf32b59f11..8049210c550 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -292,6 +292,36 @@ static BOOL elf_map_file_read(struct image_file_map* fmap, struct elf_map_file_d } }
+static BOOL elf_map_shdr(struct elf_map_file_data* emfd, struct image_file_map* fmap, unsigned int i) +{ + if (fmap->addr_size == 32) + { + Elf32_Shdr shdr32; + + if (!elf_map_file_read(fmap, emfd, &shdr32, sizeof(shdr32), + fmap->u.elf.elfhdr.e_shoff + i * sizeof(Elf32_Shdr))) + return FALSE; + + fmap->u.elf.sect[i].shdr.sh_name = shdr32.sh_name; + fmap->u.elf.sect[i].shdr.sh_type = shdr32.sh_type; + fmap->u.elf.sect[i].shdr.sh_flags = shdr32.sh_flags; + fmap->u.elf.sect[i].shdr.sh_addr = shdr32.sh_addr; + fmap->u.elf.sect[i].shdr.sh_offset = shdr32.sh_offset; + fmap->u.elf.sect[i].shdr.sh_size = shdr32.sh_size; + fmap->u.elf.sect[i].shdr.sh_link = shdr32.sh_link; + fmap->u.elf.sect[i].shdr.sh_info = shdr32.sh_info; + fmap->u.elf.sect[i].shdr.sh_addralign = shdr32.sh_addralign; + fmap->u.elf.sect[i].shdr.sh_entsize = shdr32.sh_entsize; + } + else + { + if (!elf_map_file_read(fmap, emfd, &fmap->u.elf.sect[i].shdr, sizeof(fmap->u.elf.sect[i].shdr), + fmap->u.elf.elfhdr.e_shoff + i * sizeof(Elf64_Shdr))) + return FALSE; + } + return TRUE; +} + /****************************************************************** * elf_map_file * @@ -385,8 +415,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map*
for (i = 0; i < fmap->u.elf.elfhdr.e_shnum; i++) { - if (!elf_map_file_read(fmap, emfd, &fmap->u.elf.sect[i].shdr, sizeof(fmap->u.elf.sect[i].shdr), - fmap->u.elf.elfhdr.e_shoff + i * sizeof(fmap->u.elf.sect[i].shdr))) + if (!elf_map_shdr(emfd, fmap, i)) { HeapFree(GetProcessHeap(), 0, fmap->u.elf.sect); fmap->u.elf.sect = NULL; @@ -1225,7 +1254,7 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, if (elf_find_section(fmap, ".dynamic", SHT_DYNAMIC, &ism)) { Elf_Dyn dyn; - char* ptr = (char*)fmap->u.elf.sect[ism.sidx].shdr.sh_addr; + char* ptr = (char*)(ULONG_PTR)fmap->u.elf.sect[ism.sidx].shdr.sh_addr; unsigned long len;
if (load_offset) ptr += load_offset - fmap->u.elf.elf_start; diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 6c6da64f247..47fd7eed91e 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -61,13 +61,11 @@ typedef struct section macho_section; #if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
#ifdef _WIN64 -#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_Shdr Elf32_Shdr #define Elf_Phdr Elf32_Phdr #define Elf_Dyn Elf32_Dyn #define Elf_Sym Elf32_Sym @@ -100,7 +98,7 @@ struct image_file_map Elf64_Ehdr elfhdr; struct { - Elf_Shdr shdr; + Elf64_Shdr shdr; const char* mapped; }* sect; #endif diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 69e8113da58..bb7500be148 100644 --- a/sdk/tools/winesync/dbghelp.cfg +++ b/sdk/tools/winesync/dbghelp.cfg @@ -3,4 +3,4 @@ directories: files: include/dbghelp.h: sdk/include/psdk/dbghelp.h tags: - wine: 799e0bfa57c4c2a7922c43031bd0d95c6add6a1a + wine: 4005901773bf1842804c40d928a944623e11d238