gcc/libgcc/config
Igor Tsimbalist 6a10fff4e2 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.

From-SVN: r254876
2017-11-17 16:21:23 +01:00
..
aarch64 [libgcc] Remove semicolon after do {} while (0) in FP_HANDLE_EXCEPTIONS 2017-11-07 08:11:43 +00:00
alpha Use ucontext_t not struct ucontext in linux-unwind.h files. 2017-06-28 10:21:16 +01:00
arc [ARC] Fix to unwinding. 2017-11-03 11:51:18 +01:00
arm config.gcc (arm-wrs-vxworks*): Rework to handle arm-wrs-vxworks7 as well as arm-wrs-vxworks. 2017-08-01 14:14:21 +00:00
avr Update copyright years. 2017-01-01 13:07:43 +01:00
bfin Use ucontext_t not struct ucontext in linux-unwind.h files. 2017-06-28 10:21:16 +01:00
c6x Fix numerous typos in comments 2017-04-03 23:30:56 +01:00
cr16 Update copyright years. 2017-01-01 13:07:43 +01:00
cris Update copyright years. 2017-01-01 13:07:43 +01:00
epiphany Update copyright years. 2017-01-01 13:07:43 +01:00
fr30 Update copyright years. 2017-01-01 13:07:43 +01:00
frv Update copyright years. 2017-01-01 13:07:43 +01:00
ft32 crti-hw.S: Add watchdog vector, FT930 IRQ support. 2017-09-29 01:01:52 +00:00
h8300 Update copyright years. 2017-01-01 13:07:43 +01:00
i386 Add Intel CET support for EH in libgcc. 2017-11-17 16:21:23 +01:00
ia64 [libgcc] Remove semicolon after do {} while (0) in FP_HANDLE_EXCEPTIONS 2017-11-07 08:11:43 +00:00
iq2000 Update copyright years. 2017-01-01 13:07:43 +01:00
libbid Update copyright years. 2017-01-01 13:07:43 +01:00
lm32 Update copyright years. 2017-01-01 13:07:43 +01:00
m32c Update copyright years. 2017-01-01 13:07:43 +01:00
m32r Update copyright years. 2017-01-01 13:07:43 +01:00
m68k Use ucontext_t not struct ucontext in linux-unwind.h files. 2017-06-28 10:21:16 +01:00
mcore Update copyright years. 2017-01-01 13:07:43 +01:00
microblaze Enable no-exec stacks for more targets using the Linux kernel. 2017-09-26 17:35:53 +01:00
mips [libgcc] Remove semicolon after do {} while (0) in FP_HANDLE_EXCEPTIONS 2017-11-07 08:11:43 +00:00
mmix Update copyright years. 2017-01-01 13:07:43 +01:00
moxie Update copyright years. 2017-01-01 13:07:43 +01:00
msp430 t-msp430 (LIB2ADD): Remove mpy.c 2017-01-17 22:56:10 -05:00
nds32 Update copyright years. 2017-01-01 13:07:43 +01:00
nios2 Use ucontext_t not struct ucontext in linux-unwind.h files. 2017-06-28 10:21:16 +01:00
nvptx Update copyright years. 2017-01-01 13:07:43 +01:00
pa Enable no-exec stacks for more targets using the Linux kernel. 2017-09-26 17:35:53 +01:00
pdp11
riscv Use ucontext_t not struct ucontext in linux-unwind.h files. 2017-06-28 10:21:16 +01:00
rl78 rl78.md: New define_expand "subdi3". 2017-10-23 13:54:02 -04:00
rs6000 [libgcc, rs6000] Remove semicolon after do {} while (0) in REGISTER_CFA_OFFSET_FOR 2017-11-07 09:21:40 +00:00
rx Update copyright years. 2017-01-01 13:07:43 +01:00
s390 Update copyright years. 2017-01-01 13:07:43 +01:00
score Update copyright years. 2017-01-01 13:07:43 +01:00
sh Use ucontext_t not struct ucontext in linux-unwind.h files. 2017-06-28 10:21:16 +01:00
sol2 Adapt Solaris 12 references 2017-11-14 18:31:01 +00:00
sparc lb1spc.S: Emit .note.GNU-stack section for a non-executable stack. 2017-05-15 07:36:18 +00:00
spu Update copyright years. 2017-01-01 13:07:43 +01:00
stormy16 Update copyright years. 2017-01-01 13:07:43 +01:00
tilegx
tilepro Use ucontext_t not struct ucontext in linux-unwind.h files. 2017-06-28 10:21:16 +01:00
v850 Update copyright years. 2017-01-01 13:07:43 +01:00
vax Update copyright years. 2017-01-01 13:07:43 +01:00
visium Update copyright years. 2017-01-01 13:07:43 +01:00
vms Update copyright years. 2017-01-01 13:07:43 +01:00
xtensa Use ucontext_t not struct ucontext in linux-unwind.h files. 2017-06-28 10:21:16 +01:00
darwin-64.c Update copyright years. 2017-01-01 13:07:43 +01:00
darwin-crt-tm.c Update copyright years. 2017-01-01 13:07:43 +01:00
darwin-crt3.c Update copyright years. 2017-01-01 13:07:43 +01:00
gthr-lynx.h Update copyright years. 2017-01-01 13:07:43 +01:00
gthr-rtems.h Update copyright years. 2017-01-01 13:07:43 +01:00
gthr-vxworks.h Update copyright years. 2017-01-01 13:07:43 +01:00
hardfp.c Update copyright years. 2017-01-01 13:07:43 +01:00
libgcc-glibc.ver Update copyright years. 2017-01-01 13:07:43 +01:00
libgcc-libsystem.ver
no-sfp-machine.h
no-unwind.h
t-crtfm
t-crtstuff-pic
t-darwin [Darwin] fix PR67710 by updating 'as' specs to handle newer assembler versions. 2016-11-27 15:07:22 +00:00
t-dfprules
t-eh-dw2-dip
t-fdpbit
t-fixedpoint-gnu-prefix
t-fpbit
t-freebsd-thread
t-gnu-prefix
t-hardfp Update copyright years. 2017-01-01 13:07:43 +01:00
t-hardfp-sfdf Update copyright years. 2017-01-01 13:07:43 +01:00
t-libgcc-pic
t-libunwind
t-libunwind-elf Update copyright years. 2017-01-01 13:07:43 +01:00
t-linux
t-openbsd-thread
t-rtems
t-slibgcc Update copyright years. 2017-01-01 13:07:43 +01:00
t-slibgcc-darwin
t-slibgcc-elf-ver
t-slibgcc-fuchsia Add fuchsia support to libgcc 2017-05-06 00:22:38 +00:00
t-slibgcc-gld
t-slibgcc-gld-nover
t-slibgcc-hpux
t-slibgcc-libgcc Update copyright years. 2017-01-01 13:07:43 +01:00
t-slibgcc-nolc-override
t-slibgcc-sld
t-slibgcc-vms
t-softfp Update copyright years. 2017-01-01 13:07:43 +01:00
t-softfp-compat
t-softfp-excl
t-softfp-sfdf
t-softfp-sfdftf
t-softfp-tf
t-stack
t-tls
t-vxworks t-vxworks (LIBGCC2_INCLUDES): Start with -I. 2017-08-01 13:23:06 +00:00
t-vxworks7 t-vxworks (LIBGCC2_INCLUDES): Start with -I. 2017-08-01 13:23:06 +00:00
unwind-dw2-fde-darwin.c Update copyright years. 2017-01-01 13:07:43 +01:00
vxlib-tls.c Update copyright years. 2017-01-01 13:07:43 +01:00
vxlib.c vxlib.c (__gthread_once): Add missing value to nested return statement. 2017-06-02 16:24:28 +00:00