Crashlog: Windows: Handle negative address offsets from BFD symbol

This commit is contained in:
Jonathan G Rennison
2022-11-02 22:13:56 +00:00
parent 60ed858707
commit 652d6c8181

View File

@@ -544,7 +544,11 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
free(demangled);
#endif
if (symbol_ok && bfd_info.function_addr) {
buffer += seprintf(buffer, last, " + " OTTD_PRINTF64U, frame.AddrPC.Offset - static_cast<DWORD64>(bfd_info.function_addr));
if (bfd_info.function_addr < frame.AddrPC.Offset) {
buffer += seprintf(buffer, last, " - " OTTD_PRINTF64U, static_cast<DWORD64>(bfd_info.function_addr) - frame.AddrPC.Offset);
} else {
buffer += seprintf(buffer, last, " + " OTTD_PRINTF64U, frame.AddrPC.Offset - static_cast<DWORD64>(bfd_info.function_addr));
}
}
}
if (bfd_info.file_name != nullptr) {