diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2023-08-05 14:54:11 +0200 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2023-10-22 14:01:06 +0100 |
commit | 28d8c680aaea46137170fef2bd1c6a98301518dc (patch) | |
tree | 34fbb9b6ab1e438882449d5ed337483c98b70195 /libgcc | |
parent | 11f50716eee812c4a27b66f894e7f3ed0c870534 (diff) | |
download | gcc-28d8c680aaea46137170fef2bd1c6a98301518dc.zip gcc-28d8c680aaea46137170fef2bd1c6a98301518dc.tar.gz gcc-28d8c680aaea46137170fef2bd1c6a98301518dc.tar.bz2 |
core: Support heap-based trampolines
Generate heap-based nested function trampolines
Add support for allocating nested function trampolines on an
executable heap rather than on the stack. This is motivated by targets
such as AArch64 Darwin, which globally prohibit executing code on the
stack.
The target-specific routines for allocating and writing trampolines are
to be provided in libgcc.
The gcc flag -ftrampoline-impl controls whether to generate code
that instantiates trampolines on the stack, or to emit calls to
__builtin_nested_func_ptr_created and
__builtin_nested_func_ptr_deleted. Note that this flag is completely
independent of libgcc: If libgcc is for any reason missing those
symbols, you will get a link failure.
This implementation imposes some implicit restrictions as compared to
stack trampolines. longjmp'ing back to a state before a trampoline was
created will cause us to skip over the corresponding
__builtin_nested_func_ptr_deleted, which will leak trampolines
starting from the beginning of the linked list of allocated
trampolines. There may be scope for instrumenting longjmp/setjmp to
trigger cleanups of trampolines.
Co-Authored-By: Maxim Blinov <maxim.blinov@embecosm.com>
Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
gcc/ChangeLog:
* builtins.def (BUILT_IN_NESTED_PTR_CREATED): Define.
(BUILT_IN_NESTED_PTR_DELETED): Ditto.
* common.opt (ftrampoline-impl): Add option to control
generation of trampoline instantiation (heap or stack).
* coretypes.h: Define enum trampoline_impl.
* tree-nested.cc (convert_tramp_reference_op): Don't bother calling
__builtin_adjust_trampoline for heap trampolines.
(finalize_nesting_tree_1): Emit calls to
__builtin_nested_...{created,deleted} if we're generating with
-ftrampoline-impl=heap.
* tree.cc (build_common_builtin_nodes): Build
__builtin_nested_...{created,deleted}.
* doc/invoke.texi (-ftrampoline-impl): Document.
Diffstat (limited to 'libgcc')
0 files changed, 0 insertions, 0 deletions