Repository navigation
Add support for .obj files in COFF - #64
Open
topolarity wants to merge 3 commits into
Open
topolarity wants to merge 3 commits into
topolarity wants to merge 3 commits into
Conversation
Static libraries (`libfoo.a`, `foo.lib`) are `ar` archives of object files. `readmeta(io, ArchiveHandle)` lists an archive's members, and `readmeta(ah, member)` / `read(ah, member)` open one as an object file or read its contents. Each member starts with an `ArchiveMemberHeader`. `ar` has no single specification: each kind of archive (GNU, BSD and COFF, and the 64-bit variants of the former two) indexes its symbols and stores long member names in members of its own reserved names. As in LLVM, the kind is determined once from the first member(s), see `archive_kind()`, and member names are then decoded by that kind's rules only, with its symbol and name tables only accepted where they belong. GNU thin archives, whose members are stored outside of the archive, are supported too. `ArchiveHandle` is not registered in `ObjTypes`, so `readmeta(io)` still only returns object files: existing callers that iterate the result of `readmeta(io)` would otherwise start receiving archives. The test fixtures are generated by `test/archives/build.sh`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
COFF symbol table entries may be followed by auxiliary records, which `scan_symbol_offsets()` found but `Symbols` never used: iterating a `COFFSymbols` listed every record, auxiliary or not, as a symbol. It also stopped one record short, dropping a final symbol without any. Index through the scanned (non-auxiliary) symbol table indices instead. `symbol_number()` remains the symbol's index within the symbol table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Object files (e.g. `foo.obj`, or the members of `foo.lib`) have no MZ stub, PE signature or optional header: they start directly with their COFF header. `readmeta(io, COFFHandle)` now falls back to reading one, identifying it by its `Machine` (which is all the magic an object has) and a header consistent with an object of its size. Such handles have no `opt_header`, and no `DynamicLinks`. Also: - Add the ARM64EC and ARM64X machine types. - Only prefix symbols with an underscore on 32-bit x86, not on all 32-bit architectures (e.g. ARMv7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #64 +/- ##
==========================================
+ Coverage 69.94% 72.25% +2.31%
==========================================
Files 46 47 +1
Lines 1364 1514 +150
==========================================
+ Hits 954 1094 +140
- Misses 410 420 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Dependent on #63 .
Beyond increasing our format support, this is required to be able to distinguish MSVC-style import libraries on Windows. These files are pure COFF (no PE / COFF header, as in a usual PE image) so the "optional" header is finally truly optional.
Also fix a bug where
COFFSymbolswould report garbage / erroneous symbols, due to iterating auxiliary symbols incorrectly.Assisted-by: Claude Code (Opus 5.5)