Skip to content

[libunwind] [SEH] Implement parsing of aarch64 pdata/xdata #137949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions libunwind/src/UnwindCursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,52 @@ bool UnwindCursor<A, R>::getInfoFromSEH(pint_t pc) {
_info.handler = 0;
}
}
#elif defined(_LIBUNWIND_TARGET_AARCH64)
if (unwindEntry->Flag != 0) { // Packed unwind info
_info.end_ip = _info.start_ip + unwindEntry->FunctionLength * 4;
// Only fill in the handler and LSDA if they're stale.
if (pc != getLastPC()) {
// Packed unwind info doesn't have an exception handler.
_info.lsda = 0;
_info.handler = 0;
}
} else {
IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA *xdata =
reinterpret_cast<IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA *>(
base + unwindEntry->UnwindData);
_info.end_ip = _info.start_ip + xdata->FunctionLength * 4;
// Only fill in the handler and LSDA if they're stale.
if (pc != getLastPC()) {
if (xdata->ExceptionDataPresent) {
uint32_t offset = 1; // The main xdata
uint32_t codeWords = xdata->CodeWords;
uint32_t epilogScopes = xdata->EpilogCount;
if (xdata->EpilogCount == 0 && xdata->CodeWords == 0) {
uint32_t extensionWord = reinterpret_cast<uint32_t *>(xdata)[1];
codeWords = (extensionWord >> 16) & 0xff;
epilogScopes = extensionWord & 0xffff;
offset++;
}
if (!xdata->EpilogInHeader)
offset += epilogScopes;
offset += codeWords;
uint32_t *exceptionHandlerInfo =
reinterpret_cast<uint32_t *>(xdata) + offset;
_dispContext.HandlerData = &exceptionHandlerInfo[1];
_dispContext.LanguageHandler = reinterpret_cast<EXCEPTION_ROUTINE *>(
base + exceptionHandlerInfo[0]);
_info.lsda = reinterpret_cast<unw_word_t>(_dispContext.HandlerData);
if (exceptionHandlerInfo[0])
_info.handler =
reinterpret_cast<unw_word_t>(__libunwind_seh_personality);
else
_info.handler = 0;
} else {
_info.lsda = 0;
_info.handler = 0;
}
}
}
#endif
setLastPC(pc);
return true;
Expand Down
Loading