aboutsummaryrefslogtreecommitdiff
path: root/libgcc/unwind-generic.h
diff options
context:
space:
mode:
authoritsimbal <itsimbal@138bc75d-0d04-0410-961f-82ee72b054a4>2017-11-17 15:21:23 +0000
committeritsimbal <itsimbal@138bc75d-0d04-0410-961f-82ee72b054a4>2017-11-17 15:21:23 +0000
commitc05f99c6eb8a42664a8655240f43323b500a11b9 (patch)
tree714437517f3bed4370e786ffd6a22ca4d11f139f /libgcc/unwind-generic.h
parente773de65bc57bb0e8021d2469eafed593028cc23 (diff)
Add Intel CET support for EH in libgcc.
Control-flow Enforcement Technology (CET), published by Intel, introduces the Shadow Stack feature, which ensures a return from a function is done to exactly the same location from where the function was called. When EH is present the control-flow transfer may skip some stack frames and the shadow stack has to be adjusted not to signal a violation of a control-flow transfer. It's done by counting a number of skiping frames and adjasting shadow stack pointer by this number. Having new semantic of the 'ret' instruction if CET is supported in HW the 'ret' instruction cannot be generated in ix86_expand_epilogue when we are returning after EH is processed. Added a code in ix86_expand_epilogue to adjust Shadow Stack pointer and to generate an indirect jump instead of 'ret'. As sp register is used during this adjustment thus the argument in pro_epilogue_adjust_stack is changed to update cfa_reg based on whether control-flow instrumentation is set. Without updating the cfa_reg field there is an assert later in dwarf2 pass related to mismatch the stack register and cfa_reg value. gcc/ * config/i386/i386.c (ix86_expand_epilogue): Change simple return to indirect jump for EH return if control-flow protection is enabled. Change explicit 'false' argument in pro_epilogue_adjust_stack with a value of flag_cf_protection. * config/i386/i386.md (simple_return_indirect_internal): Remove SImode restriction to support 64-bit. libgcc/ * config/i386/linux-unwind.h: Include config/i386/shadow-stack-unwind.h. * config/i386/shadow-stack-unwind.h: New file. * unwind-dw2.c: (uw_install_context): Add a frame parameter and pass it to _Unwind_Frames_Extra. * unwind-generic.h (_Unwind_Frames_Extra): New. * unwind.inc (_Unwind_RaiseException_Phase2): Add frames_p parameter. Add local variable frames to count number of frames. (_Unwind_ForcedUnwind_Phase2): Likewise. (_Unwind_RaiseException): Add local variable frames to count number of frames, pass it to _Unwind_RaiseException_Phase2 and uw_install_context. (_Unwind_ForcedUnwind): Likewise. (_Unwind_Resume): Likewise. (_Unwind_Resume_or_Rethrow): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254876 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgcc/unwind-generic.h')
-rw-r--r--libgcc/unwind-generic.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/libgcc/unwind-generic.h b/libgcc/unwind-generic.h
index 77dd5a90202..570ea50a5a6 100644
--- a/libgcc/unwind-generic.h
+++ b/libgcc/unwind-generic.h
@@ -288,4 +288,7 @@ EXCEPTION_DISPOSITION _GCC_specific_handler (PEXCEPTION_RECORD, void *,
#pragma GCC visibility pop
#endif
+/* Additional actions to unwind number of stack frames. */
+#define _Unwind_Frames_Extra(frames)
+
#endif /* unwind.h */