195 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
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
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 ceb1d59f82 write/elf: add Encoder (#910)
This is the struct writing component of `Writer`, without any state management.
`Encoder` also includes size methods, replacing the need for `Class`.

`build::elf::Builder` already does a lot of its own state management, so
change it to use `Encoder`.

Breaking change: the structs for writing need more information computed
by the caller (string offsets and version string hashes).
Added `Writer` methods to return string offsets.
2026-05-31 16:47:58 +10:00
Philip Craig 5060df4d5e Add elfcopy example (#911)
This will be needed to test the two-phase ELF writer.
It's largely code that existed prior to the addition of elf::Builder.
2026-05-31 16:31:35 +10:00
Philip Craig c42c699b77 Add elfstub example
This tests `write::elf::SinglePhaseWriter`
2026-05-29 18:38:24 +10:00
Philip Craig 638654d9e8 names! syntax rework
Change syntax from:
    consts et: FileType = NAMES_ET;
to:
    consts et = NAMES_ET: FileType;

This better matches the syntax of constant_names! and flag_names!.
Also allow both name and definition to be specified; this is possible
now (but not used yet):
    consts et = NAMES_ET: FileType(u16) = {
	    /// No file type.
	    ET_NONE = 0,
    };

Also allow meta attributes and visibility on statics.
2026-05-15 14:04:12 +10:00
Philip Craig 5bcfe697ef Rename constants! to names!
This better fits its usage.
2026-05-15 14:04:12 +10:00
Philip Craig fcb2f43477 Add elf::NoteType 2026-05-13 20:51:59 +10:00
Philip Craig 20f33d36e0 Implement BitAnd/BitAndAssign for flag newtypes 2026-05-13 20:51:59 +10:00
Philip Craig bd07b52c38 read/elf: change VersionTable::version argument
This is more flexible.
2026-05-13 20:51:59 +10:00
Philip Craig 9228c181b5 Add newtypes for XCOFF constants (#899)
* Add xcoff::FileFlags

* Add xcoff::SectionFlags, SectionType

* Add xcoff::SymbolSection, SymbolClass, and SymbolType

* Add xcoff::CsectAuxSmtyp and CsectAuxClass

* Add xcoff::AuxType, FileAuxType, and relocation names
2026-05-12 16:48:25 +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
lapla 01c7b91d8e read/wasm: Classify all reloc.* custom sections as Linker (#896) 2026-05-11 15:45:44 +10:00
lapla 5b53725e35 read/wasm: Implement reloc.* section reading (#895) 2026-05-11 13:14:57 +10:00
Philip Craig 8cf8be5c51 constants: newtype support (#878) 2026-05-10 12:09:38 +10:00
Philip Craig eed21f6f88 Change edition to 2024 (#893) 2026-05-08 18:03:48 +10:00
Philip Craig 12cf5f764c Change MSRV to 1.85.0 (#892) 2026-05-08 17:45:11 +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 6f8e9501ab Reduce the size of some test output (#890) 2026-05-07 16:10:58 +10:00
Philip Craig 70e12cfb27 Add constants module (#876)
This module contains macros to create data structures containing
constant names at the same time as the constants are defined.
The data structures support inheriting sets of constants, which
is useful for processor and OS specific constants.

Use these macros to define elf/macho/pe constants, and replace most
of the architecture-specific constant names in the readobj example.
2026-05-06 21:48:51 +10:00