# Calling Nested Functions on GCC Without an Executable Stack

Original title: Indirect Calling of Nested Functions on GCC Without Executable Stack

> Hacker News story 49490138 · language: en · submitted 2026-08-29
> Web version: https://zeli.app/story/49490138
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 74 · by [uecker](<https://news.ycombinator.com/user?id=uecker>) · 💬 60
[original](<https://uecker.codeberg.page/2026-08-29.html>) · [HN discussion](<https://news.ycombinator.com/item?id=49490138>)

## Summary

Martin Uecker explores a hack to support nested functions on older GCC versions without requiring an executable stack. By extracting the code address and static chain from the trampoline that GCC generates, and using `__builtin_call_with_static_chain`, the trampoline can be bypassed, allowing the stack to be cleared with `patchelf --clear-execstack`. He also proposes using trampolines as function descriptors, interpreting them at call sites. Implemented in his experimental library noplate.

## Key quote

> In some sense we could say that instead of invoking the trampoline, we are _interpreting_ the code of the trampoline at the call site using a super simple interpreter that only can interpret this specific code sequence and that is so simple that it can be inlined.

## HN discussion (60 comments)

### [inigyou](<https://news.ycombinator.com/item?id=49490756>)

> Self-modifying code is cool. It's a shame we had to disable it for security.

### [mananaysiempre](<https://news.ycombinator.com/item?id=49490798>)

> Related: previous article in the series, https://news.ycombinator.com/item?id=49308685 (103 points, 47 comments)

### [gue5t](<https://news.ycombinator.com/item?id=49490867>)

> At first, I was annoyed by having to read AT&T syntax. Then I was disoriented by realizing the next snippet was in AT&T syntax without the '%' sigil for registers. But the technique is cool.

### [Dwedit](<https://news.ycombinator.com/item?id=49490945>)

> What do you need the executable stack for?  You call using a function pointer, there's no executable read/write memory involved in using a function pointer.

---

## Cite

- Page: https://zeli.app/story/49490138
- Date: 2026-08-29
- Source: uecker.codeberg.page (https://uecker.codeberg.page/2026-08-29.html)
- Hacker News: https://news.ycombinator.com/item?id=49490138

## Other languages

- zh: https://zeli.app/zh/story/49490138 · markdown: https://zeli.app/zh/story/49490138.md
- ja: https://zeli.app/ja/story/49490138 · markdown: https://zeli.app/ja/story/49490138.md
- ko: https://zeli.app/ko/story/49490138 · markdown: https://zeli.app/ko/story/49490138.md
- de: https://zeli.app/de/story/49490138 · markdown: https://zeli.app/de/story/49490138.md
- es: https://zeli.app/es/story/49490138 · markdown: https://zeli.app/es/story/49490138.md
- ru: https://zeli.app/ru/story/49490138 · markdown: https://zeli.app/ru/story/49490138.md
