From 2a6ce37910ac9765c36cbcc3a0a09916da4debe3 Mon Sep 17 00:00:00 2001 From: Riteo Date: Sat, 21 Jan 2023 16:14:33 +0100 Subject: Make PIE relocation detection glibc-only Musl doesn't compile with it, and by looking online I think that this is a glibc only thing. --- platform/linuxbsd/crash_handler_linuxbsd.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'platform/linuxbsd') diff --git a/platform/linuxbsd/crash_handler_linuxbsd.cpp b/platform/linuxbsd/crash_handler_linuxbsd.cpp index 8d03e3d31c..3a245460b4 100644 --- a/platform/linuxbsd/crash_handler_linuxbsd.cpp +++ b/platform/linuxbsd/crash_handler_linuxbsd.cpp @@ -81,7 +81,13 @@ static void handle_crash(int sig) { print_error(vformat("Dumping the backtrace. %s", msg)); char **strings = backtrace_symbols(bt_buffer, size); // PIE executable relocation, zero for non-PIE executables +#ifdef __GLIBC__ + // This is a glibc only thing apparently. uintptr_t relocation = _r_debug.r_map->l_addr; +#else + // Non glibc systems apparently don't give PIE relocation info. + uintptr_t relocation = 0; +#endif //__GLIBC__ if (strings) { List args; for (size_t i = 0; i < size; i++) { -- cgit v1.2.3