Skip to content

Conversation

@fosterbrereton
Copy link
Contributor

@fosterbrereton fosterbrereton commented Oct 3, 2025

Adds COFF (Common Object File Format) support to ORC, enabling it to parse and extract DWARF debug information from Windows object files in addition to existing Mach-O support.

New COFF Implementation:

  • Created coff.cpp and coff.hpp implementing COFF/PE format parsing (IMAGE_FILE_HEADER, IMAGE_SECTION_HEADER structures)
  • Added dwarf_from_coff() to extract DWARF sections from COFF objects
  • Detects x64 COFF files via machine type code (0x8664)

Generalized Architecture:

  • Renamed macho_paramsreader_params and macho_reader_modereader_mode throughout codebase
  • Updated all file format readers (ar, fat, macho) to use generic params
  • Created dwarf_from_object_file() dispatcher that routes to format-specific (COFF/Mach-O) DWARF extractors

DWARF Section Handling:

  • Extended section name matching to recognize both Mach-O (__debug_*) and COFF (.debug*) prefixes
  • Improved section registration with better error handling (finalized state machine transitions)
  • Enhanced freader with leftovers() and templated read<T>() methods

Robustness:

  • Added invariant checks for buffer boundaries in freader operations
  • Better error reporting for missing DWARF sections
  • Handles COFF string table lookups for long section names

@fosterbrereton fosterbrereton changed the title Working on COFF parsing COFF Support Oct 3, 2025
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.

2 participants