[libcxx-commits] [PATCH] D105968: [libunwind][CET] Support exception handling stack unwind in CET environment

xiongji90 via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 15 00:57:51 PDT 2021


xiongji90 updated this revision to Diff 358855.
xiongji90 added a comment.

This update fixes some format issue and updates the way to jump to landing pad in 32bit node.
Previously, we used following code to jump to landing pad:
"
add $4, %esp
jmp *-4(%esp)
"
If interrupt comes in between these 2 instructions, interrupt handler may change the contents of "-4(%esp)" since there is no red zone in 32bit mode. To fix this issue, we align with gcc unwind to use %ecx to store landing pad address and jmp to it:
"
pop %ecx
jmp *%ecx
"

According to i386 ABI:
"Prior to executing code in the landing pad, the unwind library restores registers not altered by the personality routine, using the context record, to their state in that frame before the call that threw the exception, as follows. All registers specified as callee-saved by the base ABI are restored, as well as scratch registers %eax and %edx (see below). Except for those exceptions, scratch (or caller-saved) registers are not preserved, and their contents are undefined on transfer."
It is OK to use %ecx for jumping to landing pad.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105968/new/

https://reviews.llvm.org/D105968

Files:
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  libunwind/src/Registers.hpp
  libunwind/src/UnwindLevel1.c
  libunwind/src/UnwindRegistersRestore.S
  libunwind/src/UnwindRegistersSave.S
  libunwind/src/assembly.h
  libunwind/src/cet_unwind.h
  libunwind/test/libunwind/test/config.py
  libunwind/test/lit.site.cfg.in

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105968.358855.patch
Type: text/x-patch
Size: 12892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210715/13caee23/attachment-0001.bin>


More information about the libcxx-commits mailing list