Skip to content

Add support for .obj files in COFF - #64

Merged
topolarity merged 2 commits into
JuliaIO:masterfrom
topolarity:ct/coff-objects
Oct 22, 2026
Merged

topolarity merged 2 commits into
JuliaIO:masterfrom
topolarity:ct/coff-objects

Conversation

@topolarity

Copy link
Copy Markdown
Collaborator

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 COFFSymbols would report garbage / erroneous symbols, due to iterating auxiliary symbols incorrectly.

Assisted-by: Claude Code (Opus 5.5)

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.55556% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.32%. Comparing base (7fc488d) to head (e82bece).

Files with missing lines Patch % Lines
src/COFF/COFFHandle.jl 96.29% 1 Missing ⚠️
src/COFF/COFFSymbol.jl 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #64      +/-   ##
==========================================
+ Coverage   71.90%   72.32%   +0.41%     
==========================================
  Files          47       47              
  Lines        1488     1514      +26     
==========================================
+ Hits         1070     1095      +25     
- Misses        418      419       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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>
@topolarity

Copy link
Copy Markdown
Collaborator Author

Largely AI-generated, but the test coverage looks sufficient to me and the changes are straightforward. Let's merge.

@topolarity
topolarity merged commit 7bfcb48 into JuliaIO:master Oct 22, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant