feat(coff): per-function sections, honor scope:local#3
Merged
bwrsandman merged 3 commits intoJul 18, 2026
Merged
Conversation
- write_coff cuts code sections at function-symbol boundaries so each function gets its own .text section (MSVC /Gy style). Tooling then sees exact per-function sizes instead of sizes inferred from symbol gaps, which included alignment padding. Inter-function padding and trailing jump tables stay attached to the preceding chunk and non-first chunks use alignment 1, so relinked output is unchanged. Gated by new ProjectConfig field function_sections (default true). - scope:local now emits IMAGE_SYM_CLASS_STATIC even with export_all; the globalize pass still promotes cross-unit-referenced locals to external first, so links are unaffected. - resolve_link_order warns clearly when a unit has non-contiguous ranges within one section instead of a cryptic cycle warning. - docs/coff.md documents COFF-specific semantics: section layout, symbol visibility, re-split requirements, non-contiguous units. Verified on BW1W120: relinked exe and LHAudio.dll byte-identical to originals with function_sections on and off; multi-function objects show one .text section per function; scope:local symbols emit STATIC. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Re-emit compiler comment strings left in the PE header padding (leaked Intel #pragma comment(exestr) directives) as -?comment .drectve directives so a comment-aware linker reproduces them, instead of a hardcoded post-link patch. Comment ranges are declared in the splits file like any segment (type:comment, shared in Sections: or under a unit), read via read_comment_regions and skipped by apply_splits. Each is attributed to its owning unit and emitted into that unit's object; unattributed ones go in a shared comment object linked first (lowest header address). type:comment declarations round-trip through a splits-file rewrite. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
obj_path_for_unit returns a native path (backslash-separated on Windows); normalize separators before comparing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Verified on BW1W120: relinked exe and LHAudio.dll byte-identical to originals with function_sections on and off; multi-function objects show one .text section per function; scope:local symbols emit STATIC.