When getauxval isn't available we can read the auxillary vector after environment pointers according to System V ABI.
Signed-off-by: Rémi Bernon [email protected] ---
I'm not sure if this is very useful, but some runtimes (steamrt for instance) have old glibc where getauxval isn't available and it then causes SymInitializeW to fail because of NULL process image addresses.
dlls/ntdll/unix/loader.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index bd3a0958757..02ffc0ca775 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1343,6 +1343,27 @@ ULONG_PTR get_image_address(void)
if (task_info(mach_task_self(), TASK_DYLD_INFO, (task_info_t)&dyld_info, &size) == KERN_SUCCESS) return dyld_info.all_image_info_addr; +#elif defined(__linux__) + ULONG_PTR size, num, phdr_addr; + ElfW(Phdr) *phdr; + Elf64_auxv_t *auxp; + char **envp = main_envp; + while (*envp++ != NULL); + + for (auxp = (Elf64_auxv_t *)envp; auxp->a_type != 0; auxp++) + { + if (auxp->a_type == AT_PHDR) phdr_addr = auxp->a_un.a_val; + if (auxp->a_type == AT_PHENT) size = auxp->a_un.a_val; + if (auxp->a_type == AT_PHNUM) num = auxp->a_un.a_val; + } + + if (!phdr_addr) return 0; + phdr = (ElfW(Phdr) *)phdr_addr; + while (num--) + { + if (phdr->p_type == PT_PHDR) return phdr_addr - phdr->p_offset; + phdr = (ElfW(Phdr) *)((char *)phdr + size); + } #endif return 0; }
When fInvadeProcess is used, we return an error if the target process is found but its debug info is not. We should only return an error if the process is not found.
This fixes a SymInitializeW popup error on Hard Reset Redux startup.
Signed-off-by: Rémi Bernon [email protected] --- dlls/dbghelp/dbghelp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c index a2dba4cfe3e..1e8cab18bed 100644 --- a/dlls/dbghelp/dbghelp.c +++ b/dlls/dbghelp/dbghelp.c @@ -354,7 +354,9 @@ static BOOL check_live_target(struct process* pcs) if (!base) return FALSE;
TRACE("got debug info address %#lx from PEB %p\n", base, pbi.PebBaseAddress); - return elf_read_wine_loader_dbg_info(pcs, base) || macho_read_wine_loader_dbg_info(pcs, base); + if (elf_read_wine_loader_dbg_info(pcs, base) || macho_read_wine_loader_dbg_info(pcs, base)) + WARN("couldn't load process debug info at %p\n", base); + return TRUE; }
/****************************************************************** @@ -456,7 +458,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP { if (fInvadeProcess) EnumerateLoadedModulesW64(hProcess, process_invade_cb, hProcess); - pcs->loader->synchronize_module_list(pcs); + if (pcs->loader) pcs->loader->synchronize_module_list(pcs); } else if (fInvadeProcess) {
Signed-off-by: Jacek Caban [email protected]
On 2020-07-31 13:58, Jacek Caban wrote:
Signed-off-by: Jacek Caban [email protected]
Actually I messed up the condition, it should be negated before printing the warning.
On 2020-07-31 11:51, Rémi Bernon wrote:
When getauxval isn't available we can read the auxillary vector after environment pointers according to System V ABI.
Signed-off-by: Rémi Bernon [email protected]
I'm not sure if this is very useful, but some runtimes (steamrt for instance) have old glibc where getauxval isn't available and it then causes SymInitializeW to fail because of NULL process image addresses.
dlls/ntdll/unix/loader.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index bd3a0958757..02ffc0ca775 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1343,6 +1343,27 @@ ULONG_PTR get_image_address(void)
if (task_info(mach_task_self(), TASK_DYLD_INFO, (task_info_t)&dyld_info, &size) == KERN_SUCCESS) return dyld_info.all_image_info_addr;
+#elif defined(__linux__)
- ULONG_PTR size, num, phdr_addr;
- ElfW(Phdr) *phdr;
- Elf64_auxv_t *auxp;
- char **envp = main_envp;
- while (*envp++ != NULL);
- for (auxp = (Elf64_auxv_t *)envp; auxp->a_type != 0; auxp++)
And this is obviously 64bit specific, please ignore it.