Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:gcc
libgcj43
gcc43-stack-probe.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gcc43-stack-probe.diff of Package libgcj43
Index: gcc/common.opt =================================================================== --- gcc/common.opt.orig 2017-09-25 20:07:01.000000000 +0200 +++ gcc/common.opt 2017-09-25 20:07:03.000000000 +0200 @@ -966,6 +966,10 @@ fstack-check Common Report Var(flag_stack_check) Insert stack checking code into the program +fstack-clash-protection +Common Report Var(flag_stack_clash_protection) +Insert probes per page for dynamically allocated stack space + fstack-limit Common Index: gcc/explow.c =================================================================== --- gcc/explow.c.orig 2017-09-25 20:07:01.000000000 +0200 +++ gcc/explow.c 2017-09-25 22:17:46.000000000 +0200 @@ -1071,6 +1071,9 @@ update_nonlocal_goto_save_area (void) rtx allocate_dynamic_stack_space (rtx size, rtx target, int known_align) { + rtx loop_lab, end_lab, skip_lab, last_size, before_skip; + int probe_pass = 0; + /* If we're asking for zero bytes, it doesn't matter what we point to since we can't dereference it. But return a reasonable address anyway. */ @@ -1203,6 +1206,30 @@ allocate_dynamic_stack_space (rtx size, mark_reg_pointer (target, known_align); + if (flag_stack_clash_protection) + { + size = copy_to_mode_reg (Pmode, convert_to_mode (Pmode, size, 1)); + loop_lab = gen_label_rtx (); + end_lab = gen_label_rtx (); + skip_lab = gen_label_rtx (); + /* We insert 'target = virtual_stack_dynamic_rtx' here, but target + is changed later, so that insn can be constructed only later. */ + before_skip = get_last_insn (); + emit_cmp_and_jump_insns (size, CONST0_RTX (Pmode), EQ, NULL_RTX, + Pmode, 1, skip_lab); + emit_label (loop_lab); +#ifndef STACK_GROWS_DOWNWARD +#error stack must grow down +#endif + emit_cmp_and_jump_insns (size, GEN_INT (STACK_CHECK_PROBE_INTERVAL), LTU, + NULL_RTX, Pmode, 1, end_lab); + last_size = expand_binop (Pmode, sub_optab, size, GEN_INT (STACK_CHECK_PROBE_INTERVAL), size, + 1, OPTAB_WIDEN); + gcc_assert (last_size == size); + size = GEN_INT (STACK_CHECK_PROBE_INTERVAL); + } + +again: /* Perform the required allocation from the stack. Some systems do this differently than simply incrementing/decrementing from the stack pointer, such as acquiring the space by calling malloc(). */ @@ -1264,6 +1291,15 @@ allocate_dynamic_stack_space (rtx size, emit_move_insn (target, virtual_stack_dynamic_rtx); #endif } + if ((flag_stack_clash_protection) && probe_pass == 0) + { + probe_pass = 1; + emit_stack_probe (target); + emit_jump (loop_lab); + emit_label (end_lab); + size = last_size; + goto again; + } if (MUST_ALIGN) { @@ -1280,6 +1316,18 @@ allocate_dynamic_stack_space (rtx size, GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT), NULL_RTX, 1); } + if (flag_stack_clash_protection) + { + rtx seq; + emit_stack_probe (target); + emit_label (skip_lab); + + start_sequence (); + emit_move_insn (target, virtual_stack_dynamic_rtx); + seq = get_insns (); + end_sequence (); + emit_insn_after (seq, before_skip); + } /* Record the new stack level for nonlocal gotos. */ if (cfun->nonlocal_goto_save_area != 0)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor