Stop the linker folding main() into a skipped test - #1226
Open
ejohnstown wants to merge 1 commit into
Open
Conversation
When a test is configured out, its entry function compiles down to "return 77", the automake skip code, and the main() that forwards to it inlines to the same two instructions. Apple's ld folds the two identical bodies together and then writes LC_MAIN entryoff 0, so the binary starts executing at the Mach-O header and dies with SIGILL instead of skipping. tests/kex.test, tests/api.test and tests/auth.test all hit this under --enable-all CPPFLAGS=-DWOLFSSH_TEST_BLOCK, and kex.test hits it again under --disable-server. Probe for -Wl,-no_deduplicate and add it to AM_LDFLAGS when the linker takes it. GNU ld rejects the flag, so the check leaves Linux alone. Making the skipped body differ does not help: anything added to the entry function inlines into main() and the two fold again.
ejohnstown
requested review from
wolfSSL-Fenrir-bot
and
a lite review from Copilot
September 3, 2026 00:18
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1226
No scan targets match the changed files in this PR. Review skipped.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped to a conditional linker-flag probe and only applies the flag when supported, minimizing cross-platform risk while addressing the described Mach-O runtime failure.
Pull request overview
This PR updates the Autoconf configuration to prevent Apple’s ld (Mach-O) from deduplicating identical main() and “skipped test” bodies, which can otherwise result in LC_MAIN entryoff 0 and a SIGILL at runtime when a configured-out test collapses to the automake “return 77” skip path.
Changes:
- Adds a link-flag probe for
-Wl,-no_deduplicate. - Appends
-Wl,-no_deduplicatetoAM_LDFLAGSonly when the linker accepts it (leaving GNUldunaffected).
File summaries
| File | Description |
|---|---|
| configure.ac | Probes for and conditionally enables -Wl,-no_deduplicate to avoid Mach-O linker deduplication causing invalid entrypoint offsets in skipped-test binaries. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A configured-out test compiles down to "return 77" and the main()
forwarding to it inlines to the same body, so Apple's ld folds the two
and writes LC_MAIN entryoff 0: the binary starts executing at the Mach-O
header and dies with SIGILL instead of skipping.
takes it. GNU ld rejects the flag, so Linux is left alone.
--enable-all CPPFLAGS=-DWOLFSSH_TEST_BLOCK, and kex.test again under
--disable-server.