From: Joerg Sonnenberger Date: Tue, 17 Jul 2018 19:00:51 +0000 (+0000) Subject: The semantics of DW_CFA_GNU_args_size have changed subtile over the X-Git-Tag: llvmorg-7.0.0-rc1~1216 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0166a0a9377cb3861210e9d5f2b629d77f1a97e;p=platform%2Fupstream%2Fllvm.git The semantics of DW_CFA_GNU_args_size have changed subtile over the years. Adopt the new convention that it is call-site specific and that it should be applied before moving the IP by personality routines, but not during normal unwinding. Differential Revision: https://reviews.llvm.org/D38680 llvm-svn: 337312 --- diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 6b99c38..0be4cd98 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -1411,8 +1411,6 @@ int UnwindCursor::step() { this->setInfoBasedOnIPRegister(true); if (_unwindInfoMissing) return UNW_STEP_END; - if (_info.gp) - setReg(UNW_REG_SP, getReg(UNW_REG_SP) + _info.gp); } return result; diff --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp index a3bcfb5..3bd8ef1 100644 --- a/libunwind/src/libunwind.cpp +++ b/libunwind/src/libunwind.cpp @@ -188,8 +188,20 @@ _LIBUNWIND_EXPORT int unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, co->setReg(regNum, (pint_t)value); // specical case altering IP to re-find info (being called by personality // function) - if (regNum == UNW_REG_IP) + if (regNum == UNW_REG_IP) { + unw_proc_info_t info; + // First, get the FDE for the old location and then update it. + co->getInfo(&info); co->setInfoBasedOnIPRegister(false); + // If the original call expects stack adjustment, perform this now. + // Normal frame unwinding would have included the offset already in the + // CFA computation. + // Note: for PA-RISC and other platforms where the stack grows up, + // this should actually be - info.gp. LLVM doesn't currently support + // any such platforms and Clang doesn't export a macro for them. + if (info.gp) + co->setReg(UNW_REG_SP, co->getReg(UNW_REG_SP) + info.gp); + } return UNW_ESUCCESS; } return UNW_EBADREG;