This is an archive of the discontinued LLVM Phabricator instance.

[libunwind] Allow restoring SP while unwinding.
ClosedPublic

Authored by charco on Jul 22 2021, 6:09 PM.

Details

Reviewers
phosek
mcgrathr
Group Reviewers
Restricted Project
Commits
rGa085c23aa3c8: [libunwind] Allow restoring SP while unwinding.
Summary

This commit modifies stepWithDwarf allowing for CFI directives to
specify the value of the stack pointer.

Previously, the SP would be unconditionally set to the CFA, because it
(wrongly) stated that the CFA is the stack pointer at the call site of a
function, but that is not always true.

One situation in which that is false, is for example if you have
switched stacks. In that case if you set the CFA to the SP before
switching the stack, the CFA would be far away from where the current
call frame is located.

The CFA always points to the current call frame, and that call frame
could have a CFI directive that specifies how to restore the stack
pointer. If not, it is OK to fallback and set the SP = CFA.

This change sets SP = CFA before restoring the registers during
unwinding, allowing the stack frame to be restored with a value
different than the CFA.

Diff Detail

Event Timeline

charco created this revision.Jul 22 2021, 6:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2021, 6:09 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
charco requested review of this revision.Jul 22 2021, 6:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2021, 6:09 PM
charco added a subscriber: eep.
phosek accepted this revision.Jul 22 2021, 6:45 PM

LGTM

This revision is now accepted and ready to land.Jul 22 2021, 6:45 PM
charco updated this revision to Diff 361064.Jul 22 2021, 7:07 PM
charco edited the summary of this revision. (Show Details)

update commit msg

This revision was landed with ongoing or failed builds.Jul 23 2021, 12:40 PM
This revision was automatically updated to reflect the committed changes.