Tag
This article explains GCC's implementation of nested functions by creating a synthetic structure for parent variable access, comparing it to C++ lambdas in a technical blog post.
The article presents a technique to indirectly call nested functions in GCC without an executable stack by reading pointers from trampolines, suitable for older GCC versions, and implemented in the noplate library.
GCC 16 ensures nested functions that don't capture variables require no trampolines, improving security. GCC 17 introduces built-in functions to avoid trampolines even for captured nested functions, using wide pointers and static chain registers.