Skip to content

test(acceptance): pin SHF_GNU_RETAIN survives --gc-sections (reld#123 Phase 2) - #147

Merged
zackees merged 3 commits into
mainfrom
phase2-retain-gc
Sep 16, 2026
Merged

zackees merged 3 commits into
mainfrom
phase2-retain-gc

Conversation

@zackees

@zackees zackees commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

What

reld already honors SHF_GNU_RETAIN in GC (should_retain() → must_load), but had no test pinning it. Add a fixture where an unreferenced __attribute__((used)) section must survive --gc-sections.

Part of reld#123 Phase 2 (SHF_GNU_RETAIN honored in GC, with a test).

Verification

  • Fixture auto-discovered by the acceptance harness; --gc-sections + ExpectSym asserts the retained symbol's section survives.

🤖 Generated with Claude Code

zackees and others added 3 commits September 16, 2026 15:27
… Phase 2)

reld already honors SHF_GNU_RETAIN (should_retain -> must_load), but had no
test. Add a fixture where an unreferenced `__attribute__((used))` section must
survive --gc-sections.

Co-Authored-By: Claude Code <[email protected]>
…hase 2)

The fixture defined main() but linked without a CRT, so reld warned it
could not find the _start entry symbol. Drive the link through gcc
(-Wl,--gc-sections) so crt0 supplies _start, matching trivial-main.

Co-Authored-By: Claude Code <[email protected]>
…23 Phase 2)

C's __attribute__((used)) does not set SHF_GNU_RETAIN, so the fixture was
silently GC'd. Use __attribute__((retain)) (the C equivalent of Rust's
#[used]) so the section carries SHF_GNU_RETAIN and survives --gc-sections.

Co-Authored-By: Claude Code <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant