Skip to content

Discard the unused .eh_frame unwind tables - #652

Draft
samoht wants to merge 1 commit into
Solo5:mainfrom
samoht:drop-eh-frame
Draft

Discard the unused .eh_frame unwind tables#652
samoht wants to merge 1 commit into
Solo5:mainfrom
samoht:drop-eh-frame

Conversation

@samoht

@samoht samoht commented Jul 10, 2026

Copy link
Copy Markdown

Every unikernel image maps .eh_frame and .eh_frame_hdr, but nothing in a Solo5 guest unwinds through them: the tenders don't, and the runtimes that target Solo5 (OCaml/MirageOS, freestanding C) either use their own unwinding or none at all. Because the sections are SHF_ALLOC they land in a PT_LOAD segment, so they are loaded into every image and strip cannot reclaim them.

This moves .eh_frame/.eh_frame_hdr to /DISCARD/ in all six bindings' linker scripts, the same way the scripts already discard the GNU NOTEs. It removes about 0.5 MiB from every image: a hello-world unikernel drops from 1,2M to 600k, and larger images shrink by the same absolute amount.

A guest that genuinely relies on DWARF unwinding (C++ exceptions, Rust panic=unwind) would need these tables. If that is a use case worth keeping, I am happy to gate the discard behind an option instead.

A unikernel never unwinds through DWARF, but .eh_frame and .eh_frame_hdr
are SHF_ALLOC and sit in a PT_LOAD segment, so they are mapped into every
image and strip cannot reclaim them. Moving them to /DISCARD/ removes about
0.5 MiB from every unikernel (a hello-world image shrinks ~45%).
@dinosaure

Copy link
Copy Markdown
Collaborator

A guest that genuinely relies on DWARF unwinding (C++ exceptions, Rust panic=unwind) would need these tables. If that is a use case worth keeping, I am happy to gate the discard behind an option instead.

It is, in fact, necessary. Solo5 is not exclusive to OCaml.

@hannesm

hannesm commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Does the solo5-hvt-debug with the gdb interaction use eh_frame? I'm not sure whether this is part of the test suite.

Because the sections are SHF_ALLOC they land in a PT_LOAD segment, so they are loaded into every image and strip cannot reclaim them.

Is there another path to solve this? Can there be arguments passed to "strip" to allow discarding these? Can it be marked differently? Would a custom strip (how hard can it be?) be sensible? Are there different strip utilities with the same behaviour, or are they all the same?

@samoht
samoht marked this pull request as draft July 12, 2026 22:31
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.

3 participants