[all-commits] [llvm/llvm-project] a085c2: [libunwind] Allow restoring SP while unwinding.

Marco Vanotti via All-commits all-commits at lists.llvm.org
Fri Jul 23 12:40:08 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a085c23aa3c8f91866d7f4588d4f683407dc775d
      https://github.com/llvm/llvm-project/commit/a085c23aa3c8f91866d7f4588d4f683407dc775d
  Author: Marco Vanotti <mvanotti at google.com>
  Date:   2021-07-23 (Fri, 23 Jul 2021)

  Changed paths:
    M libunwind/src/DwarfInstructions.hpp

  Log Message:
  -----------
  [libunwind] Allow restoring SP while unwinding.

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.

Reviewed By: #libunwind, phosek

Differential Revision: https://reviews.llvm.org/D106626




More information about the All-commits mailing list