* clarify Go runtime version vs GoReSym layout version
* Add Go 1.26 support
* Cleanup debugging prints
* Remove remaining debug print in main.go
* Fix redundant nil check in pe.go
* Final touches: fix sudo in build script and rename layout convention to 1.22
* Run go fmt
* Revert unnecessary moduledata scanning changes in executable parsers
* refactor fixes
* better variable name for refactor
* Fix lots of version issues and bugs in magic prefix check, as well as concurrent lock bug
* fmt
* Refactor slice, textsec, and more to use offsets. Cleanup dead code in internal.go
* fmt
---------
Co-authored-by: Stephen Eckels <stevemk14ebr@gmail.com>
* Add lint and test jobs to CI pipeline
Addresses issue #81 — current CI only checks compilation, no tests run.
- lint (ubuntu-latest): gofmt -l and go vet ./... using default Go
tooling only, no third-party linters per maintainer guidance
- test (ubuntu-latest): runs build_test_files.sh via Docker to generate
all 18 Go version binaries (stripped/non-stripped x lin/win/mac x
32/64-bit), then go test ./... covering TestAllVersions,
TestWeirdBins, and TestExtractStrings_CompareWithFLOSS
- build (windows-latest): existing release job unchanged
* Fix CI failures: gofmt, missing test binary, and add Go 1.23/1.24
* Add Go 1.23/1.24 to test matrix
- Add Go 1.23 and 1.24 to versions array in both build_test_files.sh
and main_test.go — all 10 binary variants pass for both versions
* Add -strings flag and ExtractMetadata field
- Add Strings []string to ExtractMetadata struct
- Add -strings command-line flag for string extraction
- Update main_impl and main_impl_tmpfile signatures to accept printStrings parameter
- Add placeholder string extraction logic with TODO marker
- Update printForHuman to display extracted strings section
- Verified flag appears in help and outputs correctly in both JSON and human format
Part of #45
* Implement Go string extraction algorithm
- Create objfile/strings.go with core extraction logic
- Implement FLOSS-based string internment table detection
- Add string candidate scanning (pointer + length pairs)
- Implement findLongestMonotonicRun() for pattern detection
- Add UTF-8 validation and printability filtering
- Minimum string length: 4 characters, 80% printable
- Add helper methods to elfFile: getSections(), is64Bit(), isLittleEndian()
- Update main.go to call file.ExtractStrings() instead of placeholder
- Tested with testproject/testproject: extracts 512 strings successfully
- Extracts real Go strings: type names, runtime symbols, error messages
Based on FLOSS floss/language/go/extract.py algorithm
Part of #45
* Update README with -strings flag documentation
- Add -strings flag to available flags list
- Add Strings field to example JSON output
- Document purpose: extract embedded Go strings from binary
Part of #45
* Add tests validated against FLOSS output
Per maintainer request, added comprehensive test suite:
- strings_floss_test.go: Validates GoReSym against FLOSS reference output
* 99.2% match rate (648/653 strings match FLOSS)
* Uses FLOSS output from testproject.exe as ground truth
* Reference saved in testdata/floss_reference.txt
- strings_test.go: Additional unit tests for:
* ELF and PE binary string extraction
* Monotonic run detection algorithm
* String filtering (printability, minimum length)
- pe.go: Added helper methods (getSections, is64Bit, isLittleEndian)
to enable string extraction from PE binaries
All tests pass.
* Address PR #77 review comments
- Convert getSections() to iterateSections() using callback pattern to avoid memory pressure
- Add Strings field to GoReSym.proto for external parsers
- Implement iterateSections() for Mach-O format (previously missing)
Changes requested by @stevemk14ebr in review:
1. Memory optimization: Replace array-based section loading with generator pattern
2. Proto definition: Add 'repeated string strings = 13' field
3. Mach-O support: Add missing iterateSections() implementation
* Fix test failures and expand string extraction testing per PR #77 feedback
- Fixed 4 test compilation errors by adding missing printStrings parameter to main_impl() calls
- Added comprehensive TestStringExtraction function with 7 test cases covering Linux/macOS/Windows binaries
- Implemented isPrintable() helper for ASCII validation (range 32-126)
* Align string extraction with FLOSS algorithm per PR #77 review
Rewrite string extraction to match FLOSS (extract.py) logic:
- Sort candidates by address (not length) to fix monotonic run detection
- Add image VA range and max section size filtering for candidates
- Use candidate (pointer, length) pairs for direct extraction from blob
- Replace 80% printable threshold with 100% fully printable check
- Fix PE section addresses to include ImageBase for correct VA comparison
Results: 648 strings extracted from PE test binary, 100% match with FLOSS.
* Run string extraction on test build files
* Extend main test to cover all new versions
* Fix string extraction for old Windows binaries and add length sanity check
1. Add .text to data sections for old Go Windows binaries (1.7-1.10)
that store strings in the code section instead of .rdata
2. Add maxReasonableStringLength (64KB) to filter out garbage candidates
with huge lengths that cause incorrect blob boundary detection
3. Update TestIsDataSection to reflect .text being a valid data section
Fixes string extraction failures on:
- Old Windows PE binaries (Go 1.7-1.10): 0 -> 256 strings
- Modern Windows: 574 strings
- macOS: 284 strings
All tests pass including TestWeirdBins on 15 real binaries.
* Fix test failures for Go 1.5/1.6 and Go 1.22 macOS; fix build script typo
1. main_test.go: Skip Strings check for Go 1.5/1.6
Pre-SSA C-based linker does not produce length-sorted string blobs,
so findLongestMonotonicRun never reaches the minimum threshold of 10.
Pattern mirrors the existing interface-parsing guard.
2. objfile/strings.go: Handle prevNull == -1 in findStringBlobRange
Apple's linker on newer Go/macOS (1.22+) packs sections without leading
padding, so no null bytes exist before the first string candidate.
bytes.LastIndex returns -1 in that case; treat it as offset 0 instead
of bailing out with nil.
3. objfile/macho.go: Add missing is64Bit/isLittleEndian for machoFile
elfFile and peFile already implement these interface methods; machoFile
was the only rawFile implementation without them. Detect CPU type
(CpuAmd64/Arm64 = 64-bit) and byte order from the macho.File struct.
4. build_test_files.sh: Fix $ver typo -> $GO_VER on mkdir line
The directory was never created before Docker ran, causing Go 1.5
builds to produce no output. Now all 12 binaries are built for
every version including 1.5 and 1.6.
---------
Co-authored-by: Stephen Eckels <stevemk14ebr@gmail.com>
* 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
* Add Go 1.24 support with ABIType parsing
- Add ABIType64/ABIType32 structs for Go 1.20+ type descriptors
- Extend moduledata version switch to support Go 1.21-1.24
- Update readRTypeName to handle Go 1.23-1.24 varint encoding
- Modify ParseType_impl to use ABIType for Go 1.20-1.24
- Add Go 1.21-1.24 support to interface methods and struct fields parsing
- Update pclntab parser version overrides for Go 1.21-1.24
- Document Go 1.24 support in README
Maintains backward compatibility while adding full support for
Go 1.24 binaries and newer runtime type descriptor formats.
* Remove specific Go 1.24 mention from version support section
* Optionally skip printing the function sections
Add a new -no-functions command line flag to skip printing the
UserFunctions and StdFunctions detailed sections.
This is useful to get a quick summary of what is in a Go binary.
The default is to always print the function sections.
Reference: https://github.com/mandiant/GoReSym/issues/49
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* Optionally skip printing the function sections
Use -nofuncs command line flag instead.
Reorder main_impl() function arguments.
Reference: https://github.com/mandiant/GoReSym/issues/49
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
---------
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>