Merged
Conversation
kami922
added a commit
to kami922/GoReSym
that referenced
this pull request
Jan 12, 2026
…adata with enums; generic parsers updated; tests adjusted; add InterfaceLayout scaffolding
stevemk14ebr
pushed a commit
that referenced
this pull request
Jan 13, 2026
* Refactor moduledata parsing using field offset tables (Issue #55) This commit refactors moduledata parsing for Go versions 1.16-1.24 to use a data-driven approach with field offset tables instead of repetitive version-specific switch statements. Changes: - Add objfile/layouts.go with generic field offset layout system - Add objfile/layouts_test.go with comprehensive test coverage - Refactor objfile/objfile.go to use generic parser for Go 1.16-1.24 - Reduce code from ~430 lines of switches to ~60 lines of generic code Benefits: - 85% code reduction for supported versions (430 → 62 lines) - Adding new Go versions requires only ~8 lines of layout data - Single parsing logic eliminates duplicate code - Comprehensive test suite ensures correctness Testing: - All existing tests pass - New tests verify layout offsets match struct definitions - Backward compatibility tests ensure identical output - Tested against real Go 1.17.2 binary (testproject) Fixes #55 * Extend moduledata refactoring to Go 1.5-1.15 (Issue #55) Extends the layout table approach to older Go versions (1.5-1.15), eliminating 228 lines of repetitive switch statements. Changes: - Add layout definitions for Go 1.5-1.6, 1.7, and 1.8-1.15 to layouts.go - Add validateAndConvertModuleData_Legacy() for Go 1.7-1.15 - Add validateAndConvertModuleData_Legacy_NoTypes() for Go 1.5-1.6 - Refactor objfile.go case "1.2" block (228 lines → 75 lines) - Add comprehensive tests for legacy versions (17 new test cases) Benefits: - 67% code reduction in legacy version handling - Consistent parsing approach across Go 1.5-1.24 (20 versions) - Improved maintainability and extensibility - Single source of truth for moduledata layouts Testing: - All existing unit tests pass - Added TestLayoutOffsets_Legacy_Versions (6 subtests) - Added TestVersionMapping_Legacy (11 subtests) - Total: 17 new test cases validating legacy version support Code Metrics: - objfile/objfile.go: 1,783 → 1,628 lines (-155 lines) - objfile/layouts.go: 436 → 564 lines (+128 lines infrastructure) - objfile/layouts_test.go: 380 → 590 lines (+210 lines tests) - Net: -155 lines of duplicate code eliminated Addresses maintainer feedback on PR #78 (moduledata portion). Type parsing refactoring (Phase 2) to follow in next commit. * Extend type parsing refactoring to all Go versions (Issue #55) Refactors type parsing (ParseType_impl) to use the layout table approach, eliminating 158 lines of repetitive version-specific switch statements. Changes: - Add RtypeLayout system to layouts.go for Go 1.5-1.24 - Add parseRtypeGeneric() for generic type parsing - Add getRtypeFieldOffset() helper function - Refactor ParseType_impl() to use generic parser (208 lines → 50 lines) - Add comprehensive tests for Rtype layouts (23 test cases) Benefits: - 76% code reduction in type parsing (208 lines → 50 lines) - Consistent parsing approach for all Go 1.5-1.24 type structures - Single source of truth for Rtype layouts - Improved maintainability Testing: - All existing tests pass - Added TestRtypeLayoutOffsets (3 subtests) - Added TestRtypeVersionMapping (20 subtests) - Total: 23 new test cases validating Rtype support Code Metrics: - objfile/objfile.go: 1,628 → 1,470 lines (-158 lines) - objfile/layouts.go: 564 → 786 lines (+222 lines infrastructure) - objfile/layouts_test.go: 590 → 748 lines (+158 lines tests) Combined with Phase 1: - Total code reduction: 313 lines from objfile.go - ModuleData + Type parsing: ~650 lines → ~125 lines (81% reduction) Completes maintainer feedback on PR #78 (type parsing portion). * PR #78: Change #1 complete – replace string field metadata with enums; generic parsers updated; tests adjusted; add InterfaceLayout scaffolding
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.
Permissive - have fun :)