Skip to content

feat(loaders): analyze x86/x64 ELF and COFF objects - #432

Closed
r0ny123 wants to merge 3 commits into
danielplohmann:masterfrom
r0ny123:codex/object-formats
Closed

r0ny123 wants to merge 3 commits into
danielplohmann:masterfrom
r0ny123:codex/object-formats

Conversation

@r0ny123

@r0ny123 r0ny123 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Adds analysis of little-endian x86/x64 ELF relocatable objects (.o and uncompressed .ko) and conventional COFF .obj files. Static archives remain unsupported.

The loader assigns deterministic analysis addresses, resolves section-relative symbols and supported relocations, and preserves the original input hash. Optional xmetadata.object_image records the derived layout, aliases, known function sizes and unresolved external references.

NOP padding is distinguished from function bodies using bounded byte inspection and symbol extents. Known object-function extents prevent interior prologues from splitting their owners. Unsupported relocations and object variants are rejected explicitly; allocation and table limits remain bounded. Existing linked-image loaders, CIL support and hash-escape versions are unchanged.

How it was verified

  • Full suite: 2,744 passed, 3 skipped.
  • Final object-format regression suite: 52 passed.
  • Ruff lint/format checks and type checking pass; type checking retains warnings.
  • Ubuntu crc32_generic.ko from linux-modules-6.8.0-31-generic 6.8.0-31.31: all nine distinct bodies match original symbol addresses, extents and independent instruction counts. Module SHA-256: 8dcf24cc22b706cc3ee8d8c3368b0ba42a45441198af5ba44c5de60be1567982.
  • Existing MCRIT 1.16.0 corpus exporter accepts the report: nine function entries and four indexable minhashes, with matching corpus configuration hashes.
  • Linked PE/ELF probe controls retain their PicHashes. Golden fixtures are unchanged.

No analyzed binary was executed or loaded into a kernel. No binary fixture, corpus data or workflow change is included. Supported relocation subsets and limitations are documented in docs/OBJECT_FILES.md.

  • Lint and formatting
  • Full test suite
  • Changelog entry
  • Golden fixtures unchanged

- keep call sites inside sized functions as reference sources
- support R_386_PLT32
- wrap absolute relocation values to the field width
- ignore COFF debug symbols instead of placing them as common storage
- only claim COFF input whose section and symbol tables fit the file
- resolve weak external chains in linear time and drop them from imports
- place unresolved externals after the image instead of past MAX_IMAGE_SIZE
- report a relocation count in xmetadata instead of every record
- read the ELF OS ABI from the header instead of a second parse
@r0ny123

r0ny123 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 4408f0b after another review pass over the loader:

  • calls inside a sized function were dropped as reference sources, so callees without their own symbol were never seeded
  • R_386_PLT32 added; default gcc -m32 output failed to load without it
  • absolute relocations wrap to the field width; negative COFF addends failed before
  • COFF .file debug symbols were placed as common storage
  • input starting with 4C 01 / 64 86 is only treated as COFF when its section and symbol tables fit the file, so raw buffers behave as on master again
  • weak externals resolve in linear time and no longer leave an import entry
  • unresolved externals sit right after the image instead of past MAX_IMAGE_SIZE
  • xmetadata.object_image carries relocation_count instead of every relocation record

@r0ny123 r0ny123 closed this Nov 17, 2026
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