107 Commits
Author SHA1 Message Date
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 a6a04f5643 Refactoring & improvements 2026-06-11 10:17:04 -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 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 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 fe1949738c write/elf: handle e_phnum overflow (#907) 2026-05-22 12:32:11 +10:00
Philip Craig fcb2f43477 Add elf::NoteType 2026-05-13 20:51:59 +10:00
Philip Craig 6bbca29505 Add newtypes for PE/COFF constants (#898)
* Add pe::Machine

* Add pe::FileFlags

* Add pe::Subsystem

* Add pe::DllFlags

* Add pe::SectionFlags

* Add pe::SymbolSection

Also fix maximum index check in `read::pe::ImageSymbol::section_number`.

* Add pe::SymbolType and pe::SymbolClass

* Add pe::ComdatSelection and pe::WeakExternSearch

* Add pe::ImportObjectFlags

* Add pe::NAMES_DIRECTORY_ENTRY

* Add pe::NAMES_RT

* Add pe::DebugType

* Add misc PE newtypes
2026-05-12 16:01:51 +10:00
Philip Craig 006652c1ce Add newtypes for Mach-O constants (#897)
* Fix R_ABS type

* Add macho::CpuType and CpuSubtype

Fixes a subtype check in MachOFile::sub_architecture().

readobj no longer displays subtypes for non-modern architectures.

* Add macho::VmProt

* Add macho::FileType and macho::FileFlags

Also fixes flag printing in readobj example.

* Add macho::LoadCommandType

* Add macho::DyldCacheMappingFlags

* Add macho::SegmentFlags, SectionFlags, and SectionType

* Add macho::DylibUseFlags

* Add macho build version newtypes

* Add macho::SymbolFlags

* Add macho::SymbolDesc

Also avoid returning an error in MachOFile::imports for
DYNAMIC_LOOKUP_ORDINAL and EXECUTABLE_ORDINAL.

* Add macho::DiceKind

* Add macho::ExportSymbolFlags

Includes slightly better validation of the flags value.

* Add macho::IndirectSymbol
2026-05-12 14:34:34 +10:00
Philip Craig 130ca5e2d6 Add newtypes for ELF constants (#894)
* Add elf::SectionType

* Change ELF sh_flags to u64

This includes the SHF constants.

* Add elf::SectionFlags

* Add elf::ProgramType

* Add elf::SymbolInfo/SymbolBind/SymbolType

* Add elf::FileType

* Add elf::Machine

* Add elf::FileHeader field newtypes

* Add elf::SymbolSection

* Add elf::CompressionType and elf::GroupFlags

* Add elf::SyminfoBoundto and elf::SyminfoFlags

* Add elf::DynamicTag, DynamicFlags and DynamicFlags1

Also changes elf::DF_* constants to u64.

* Add elf::GnuPropertyType

* Add elf::AttributeTag

* Add elf::ProgramFlags

* Add elf::VersionIndex and elf::VersionFlags

Also removes unneeded VERSYM_HIDDEN masking for vd_ndx and vna_other.

* Add elf::SymbolOther

* readobj: delete unused field_enums

* Rename build::elf::AttributeTag to AttributeScope

Avoids sharing name with elf::AttributeTag.

* Rename elf::SectionIndex to SymbolIndex

Also add elf::SectionIndex::new+index

* write/elf: remove unwrap for sh_flags
2026-05-12 12:56:20 +10:00
Philip Craig eed21f6f88 Change edition to 2024 (#893) 2026-05-08 18:03:48 +10:00
Philip Craig 7f426a5a1d Add more type fields to common flag enums
The goal of these enums is to provide access to fields
that are not unambiguously provided by the unified API.
Some of these already provided type fields for some formats.
2026-05-08 12:28:28 +10:00
Philip Craig 3a68710e32 Move ELF sh_type from SectionKind::Elf to SectionFlags::Elf
SectionKind is format independent, and the Elf variant never belonged
there. Fixing this now because adding a newtype for sh_type will also
be a breaking change.
2026-05-08 12:28:28 +10:00
Philip Craig 0a7079ef74 write/elf: set flags for StandardSection::EhFrame (#877) 2026-04-10 15:53:20 +10:00
Philip Craig 745dfa8957 symbol_map: include symbol size
For this commit, the size always extends to the next symbol.
2026-03-28 17:56:50 +10:00
Philip Craig ad1d43950c Handle macho::ARM64_RELOC_BRANCH26 2026-03-20 12:29:18 +10:00
Philip Craig c0c3c8d14e Consistently handle elf::R_X86_64_PLT32 and macho::X86_64_RELOC_BRANCH
These are very similar relocations, but we were handling them
differently. Change them both to the more accurate
RelocationKind::PltRelative and RelocationEncoding::X86Branch.
2026-03-20 12:29:18 +10:00
Philip Craig f509cca380 Add round trip tests for generic relocations
This also serves to list the cases where generic relocation flags are
useful for writing. We still handle generic relocation flags for some
other relocation types during writing, but I don't consider those to be
useful cases and don't test them here.
2026-03-20 12:29:18 +10:00
Chris O'Hara e686d0f418 Extract Mach-O entry point from LC_UNIXTHREAD load command (#837) 2026-01-04 12:14:13 +10:00
Philip Craig 345c78b1c7 Add RelocationKind::None (#828)
Also ignore these relocations for `RelocationMap`.
2025-12-21 15:49:06 +10:00
Philip Craig b0edbd526d macho: basic PPC relocation support (#825) 2025-12-18 21:09:16 +10:00
John Paul Adrian Glaubitz 5c25da2843 Add initial support for HPPA (PA-RISC) (#793) 2025-07-24 20:21:45 +10:00
Fractal Fir(Michał Kostrubiec) 9a6b94c8ec Bare bones support for DEC Alpha (#790) 2025-07-20 11:43:20 +10:00
hev 8446af2292 Add LoongArch32 ELF basic support (#765) 2025-04-18 21:16:12 +10:00