1184 Commits

Author SHA1 Message Date
Luke Street 1659fc29f3 Harden OMF parsing against malformed input
- Reject zero-length records (slice panic)
- Check for overflow when computing FIXUP offsets
- Limit iterated data block nesting depth (stack overflow)
2026-06-11 11:03:15 -06:00
Luke Street d45abb631b OMF quality pass
- Format with rustfmt; fix clippy lints
- Add module documentation
- Reject invalid record types instead of silently skipping
- Recognize the DWARF segment class as debug sections
- Add read_core,omf to the feature test matrix
2026-06-11 10:52:10 -06:00
Luke Street b1b72c6b7d Add OMF objdump snapshot tests and strengthen handwritten tests
- Add Borland and Watcom test files (from object-testfiles)
- Add objdump snapshot outputs for all OMF test files
- Verify LIDATA expansion content and COMDAT sections/symbols in tests
2026-06-11 10:47:15 -06:00
Luke Street ebd9c41b4a Rework OMF sections to include COMDATs; fix Borland/Watcom parsing
- Fix SEGDEF length field size to depend on record type, not the P (use32)
  bit, and honor the B (big) bit. This fixes parsing of Borland objects.
- Parse COMDAT records per the TIS spec (separate align byte, conditional
  public base fields), synthesize sections and symbols for them, and
  support continuation and iterated data.
- Allow FIXUPP records to follow COMDAT records.
- Support Borland virtual segments (COMDEF with a segment index data type,
  referenced via segment indices with bit 14 set).
- Read the FIXUP M bit from the correct byte (LOCAT instead of fix data).
- Fix iterated data (LIDATA) repeat/block counts to be plain integers
  rather than COMDEF-style encoded values, support multiple consecutive
  blocks, and propagate expansion errors.
- Fix relocation section targets to use 1-based section indices.
- Rework relocation kind mapping: self-relative fixups map to Relative
  with an end-of-location addend; segment-relative offsets map to Absolute
  (FLAT frame) or SectionOffset (target-section frame).
- Return empty imports/exports like other relocatable formats.
2026-06-11 10:42:04 -06:00
Luke Street aa88ee5582 Adapt OMF to upstream API changes (permissions, subtractor) 2026-06-11 10:20:23 -06:00
Luke Street 958fd5bf94 Update testfiles 2026-06-11 10:18:13 -06:00
Luke Street a6a04f5643 Refactoring & improvements 2026-06-11 10:17:04 -06:00
Luke Street be97f1a321 Improve LIDATA expansion 2026-06-11 10:16:47 -06:00
Luke Street d24826ea58 OMF module reorganization 2026-06-11 10:16:47 -06:00
Luke Street fe36b32f70 Check for LEDATA/LIDATA before FIXUPP/FIXUPP32 2026-06-11 10:16:02 -06:00
Luke Street 3ceabdf081 Rework internal symbol layout; support local records 2026-06-11 10:16:02 -06:00
Luke Street cbfb7e2b15 Remove WKEXT handling and handle ABS symbols 2026-06-11 10:16:02 -06:00
Luke Street ba4f5d6cb0 Initial read support for OMF 2026-06-11 10:16:02 -06:00
Philip Craig 57716c0d83 write/elf: Encoder address size cleanups (#917)
Change Encoder::address_size to u64 to avoid conversions in
callers, and remove unneeded Encoder::address_align.
2026-06-08 19:02:15 +10:00
Philip Craig 6573ce5e0a write/elf: avoid temp Vec for strtab in SinglePhase mode (#916)
Change `StringTable::write` to allow writing directly to the
WritableBuffer.

Also add `Encoder::strtab`.
2026-06-08 18:49:03 +10:00
Philip Craig b87fc2f0cb write: use u64 for file offsets (#914)
The goal is to reduce the amount of casts required by API users, and
make it easier to correctly handle overflow later (not implemented by
this commit).

usize is still used in many places for counts.

Breaking changes:

- WritableBuffer trait method signatures
- various low level writer APIs
2026-06-08 18:38:59 +10:00
Philip Craig 6ffc31a4cc elfcopy: style fixes (#915) 2026-06-08 18:34:06 +10:00
Mark Danial 75da283f29 Support for z/OS archive files (#904)
Co-authored-by: Philip Craig <philipjcraig@gmail.com>
2026-06-04 11:43:11 +10:00
Philip Craig a06449bc0b write/elf: versym size improvements in Writer
Handle differing dynsym and versym counts (although this shouldn't
happen in practice).
2026-06-04 11:41:49 +10:00
Philip Craig 86b0798ca9 write/elf: .gnu.attributes section alignment is 1 2026-06-04 11:41:49 +10:00
Philip Craig a15a3d1362 write/elf: remove Writer::set_gnu_ver*_count methods
Move the count parameter to the write_gnu_ver*_align calls.
2026-06-04 11:41:49 +10:00
Philip Craig cd7aa028f4 write/elf: fix need_dynstr handling in Writer
.dynsym needs to link to .dynstr. This matches the existing logic
for .symtab and .strtab. Also some minor dynstr_len cleanup.

Writer originally required this, but was changed in f3432e98. This
change was because there are files in the wild that are missing .dynstr,
and Builder needed to be able to handle them. Now that Builder is no
longer using Writer, I don't see any downside to writing the empty
.dynstr, so I think it's better to change Writer back again.

It's still possible to omit .dynstr if you use Builder (which uses
Encoder directly, not Writer), and there is a test for this.
2026-06-04 11:41:49 +10:00
Philip Craig 165712e6a8 write/elf: delete some Writer methods
These were added for use by elf::Builder, but are no longer needed,
and so removing to reduce clutter in the Writer API.
2026-06-04 11:41:49 +10:00
Philip Craig f87e69f6c5 write/elf: move AttributesWriter to encoder module 2026-06-04 11:41:49 +10:00
Philip Craig cdd9d43a82 write: make StringTable public
Needed for use with elf::Encoder.

Also change StringId from usize to u32, since offsets are limited
to that anyway.
2026-06-04 11:41:49 +10:00