Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dbghelp_private.h | 2 +- dlls/dbghelp/elf_module.c | 18 +++++++++++++++++- dlls/dbghelp/macho_module.c | 3 ++- dlls/dbghelp/module.c | 6 +++--- dlls/dbghelp/pe_module.c | 6 ++++-- 5 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index d6280a5189b..0c324a827e9 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -636,7 +636,7 @@ extern struct module* module_new(struct process* pcs, const WCHAR* name, enum module_type type, BOOL virtual, DWORD64 addr, DWORD64 size, - ULONG_PTR stamp, ULONG_PTR checksum) DECLSPEC_HIDDEN; + ULONG_PTR stamp, ULONG_PTR checksum, WORD machine) DECLSPEC_HIDDEN; extern struct module* module_get_containee(const struct process* pcs, const struct module* inner) DECLSPEC_HIDDEN; diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index e23de1a8c63..553b212c526 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -121,6 +121,21 @@ struct elf_module_info
#define ELF_AT_SYSINFO_EHDR 33
+static DWORD elf_get_machine(unsigned mach) +{ + switch (mach) + { + default: + FIXME("No mapping yet for ELF e_machine %u\n", mach); + /* fall through */ + case /*EM_NONE*/ 0: return IMAGE_FILE_MACHINE_UNKNOWN; + case /*EM_386*/ 3: return IMAGE_FILE_MACHINE_I386; + case /*EM_ARM*/ 40: return IMAGE_FILE_MACHINE_ARMNT; + case /*EM_X86_64*/ 62: return IMAGE_FILE_MACHINE_AMD64; + case /*EM_AARCH64*/ 183: return IMAGE_FILE_MACHINE_ARM64; + } +} + /****************************************************************** * elf_map_section * @@ -1227,7 +1242,8 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, sizeof(struct module_format) + sizeof(struct elf_module_info)); if (!modfmt) return FALSE; elf_info->module = module_new(pcs, filename, DMT_ELF, FALSE, modbase, - fmap->u.elf.elf_size, 0, calc_crc32(fmap->u.elf.handle)); + fmap->u.elf.elf_size, 0, calc_crc32(fmap->u.elf.handle), + elf_get_machine(fmap->u.elf.elfhdr.e_machine)); if (!elf_info->module) { HeapFree(GetProcessHeap(), 0, modfmt); diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c index 7b17d1c30df..34bc4f2c4ea 100644 --- a/dlls/dbghelp/macho_module.c +++ b/dlls/dbghelp/macho_module.c @@ -1479,7 +1479,8 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename, if (!load_addr) load_addr = fmap.u.macho.segs_start; macho_info->module = module_new(pcs, filename, DMT_MACHO, FALSE, load_addr, - fmap.u.macho.segs_size, 0, calc_crc32(fmap.u.macho.handle)); + fmap.u.macho.segs_size, 0, calc_crc32(fmap.u.macho.handle), + IMAGE_FILE_MACHINE_UNKNOWN); if (!macho_info->module) { HeapFree(GetProcessHeap(), 0, modfmt); diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 01803b027d8..cda12f4c350 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -185,7 +185,7 @@ static const char* get_module_type(enum module_type type, BOOL virtual) struct module* module_new(struct process* pcs, const WCHAR* name, enum module_type type, BOOL virtual, DWORD64 mod_addr, DWORD64 size, - ULONG_PTR stamp, ULONG_PTR checksum) + ULONG_PTR stamp, ULONG_PTR checksum, WORD machine) { struct module* module; unsigned i; @@ -229,7 +229,7 @@ struct module* module_new(struct process* pcs, const WCHAR* name, module->module.TypeInfo = FALSE; module->module.SourceIndexed = FALSE; module->module.Publics = FALSE; - module->module.MachineType = 0; + module->module.MachineType = machine; module->module.Reserved = 0;
module->reloc_delta = 0; @@ -792,7 +792,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam if (Flags & SLMFLAG_VIRTUAL) { if (!wImageName) return 0; - module = module_new(pcs, wImageName, DMT_PE, TRUE, BaseOfDll, SizeOfDll, 0, 0); + module = module_new(pcs, wImageName, DMT_PE, TRUE, BaseOfDll, SizeOfDll, 0, 0, IMAGE_FILE_MACHINE_UNKNOWN); if (!module) return 0; if (wModuleName) module_set_module(module, wModuleName); module->module.SymType = SymVirtual; diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 383d2b52429..38829d6e6de 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -815,7 +815,8 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size, modfmt->u.pe_info->fmap.u.pe.file_header.TimeDateStamp, - PE_FROM_OPTHDR(&modfmt->u.pe_info->fmap, CheckSum)); + PE_FROM_OPTHDR(&modfmt->u.pe_info->fmap, CheckSum), + modfmt->u.pe_info->fmap.u.pe.file_header.Machine); if (module) { module->real_path = builtin.path; @@ -877,7 +878,8 @@ struct module* pe_load_builtin_module(struct process* pcs, const WCHAR* name, if (!size) size = nth.OptionalHeader.SizeOfImage; module = module_new(pcs, name, DMT_PE, FALSE, base, size, nth.FileHeader.TimeDateStamp, - nth.OptionalHeader.CheckSum); + nth.OptionalHeader.CheckSum, + nth.FileHeader.Machine); } } return module;