Skip to content
uecker.codeberg.page·

💻GCC 17 Removes Trampolines for Nested Functions

Nested functions get a security boost in GCC 17

TL;DR

GCC 17 introduces new built-in functions that eliminate trampolines for nested functions, enhancing security by allowing non-executable stacks. This change impacts developers using GCC and writing callback functions.

GCC 17 now supports two new built-in functions to write nested functions without requiring trampolines, a feature previously necessary due to the need for executable stack space. This update enhances security by enabling non-executable stacks while maintaining performance. Developers who rely on GCC for complex callback functions will see improved code clarity and reduced overhead. For instance, if you're writing a nested function that doesn't capture variables from its parent scope, GCC 17 guarantees no trampoline is needed, simplifying the process.

Key Points

1

GCC 16 introduced a feature to avoid trampolines if variables from parent functions aren't accessed; now it's guaranteed even without optimization (2023).

2

New built-in functions in GCC 17 enable nested function calls without trampolines, enhancing security by allowing non-executable stacks.

3

GCC automatically transforms code to use a special register for static chain passing, optimizing performance and reducing overhead.

4

Nested functions can still access static variables, named constants, or types if not variably modified, offering flexibility in callback design.

5

The feature is GCC-specific; other compilers like Clang do not support nested functions with the same capabilities.

Why It Matters

If you're developing complex applications using GCC and nested functions, this update simplifies your codebase by eliminating trampolines. For instance, a developer working on a real-time system can now ensure non-executable stacks without compromising performance or functionality.

GCCnested-functionssecurityperformance

Frequently Asked Questions

Why does this matter?

If you're developing complex applications using GCC and nested functions, this update simplifies your codebase by eliminating trampolines. For instance, a developer working on a real-time system can now ensure non-executable stacks without compromising performance or functionality.

What happened?

GCC 17 introduces new built-in functions that eliminate trampolines for nested functions, enhancing security by allowing non-executable stacks. This change impacts developers using GCC and writing callback functions.

Comments

Subscribe to join the conversation...

Be the first to comment

Enjoyed this article?

Get it daily. 7am. Free. Reads in 5 minutes.

Join 3,017 builders reading daily.

Also get