GCC Explores Trampoline-Free Nested Functions Using Wide Pointers
GCC has long supported nested functions as a non-standard C extension, but implementing them typically requires generating small executable code stubs called trampolines at runtime. This approach causes headaches on systems with strict memory protections, like those enforcing non-executable stacks or W^X policies.
A new writeup continues earlier work exploring an alternative: using 'wide pointers' that bundle a function pointer with its enclosing context, avoiding the need to generate code on the stack at all. This follow-up post digs deeper into the technical tradeoffs of the approach, refining how these pointers are represented and passed around in generated code.
While niche, this is the kind of low-level compiler engineering that quietly improves security and portability for anyone using GCC extensions.