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
This commit is contained in:
Luke Street
2026-06-11 10:52:10 -06:00
parent b1b72c6b7d
commit d45abb631b
5 changed files with 23 additions and 7 deletions
+5 -2
View File
@@ -7,7 +7,7 @@ use crate::read::{
Object, ObjectKind, ObjectSection, ReadRef, Result, SectionIndex, SectionKind, SymbolIndex,
SymbolKind,
};
use crate::{omf, SubArchitecture};
use crate::{SubArchitecture, omf};
use super::{
OmfComdat, OmfComdatData, OmfComdatIterator, OmfComdatSelection, OmfDataChunk, OmfFixup,
@@ -282,7 +282,10 @@ impl<'data, R: ReadRef<'data>> OmfFile<'data, R> {
break;
}
_ => {
// Skip unknown record types
if !omf::record_type::is_valid(record_type) {
return Err(Error("Invalid OMF record type"));
}
// Skip unhandled record types (e.g. LINNUM, LINSYM)
}
}
+13 -1
View File
@@ -1,4 +1,16 @@
//! Support for reading OMF files.
//! Support for reading OMF (Relocatable Object Module Format) files.
//!
//! OMF is the object file format used by most DOS and early Windows
//! compilers, such as Borland C++ and Open Watcom. Both 16-bit and 32-bit
//! variants are supported, including vendor extensions such as COMDAT
//! records and Borland virtual segments.
//!
//! [`OmfFile`] implements the [`Object`](crate::read::Object) trait for
//! OMF files.
//!
//! OMF doesn't have a notion of sections; instead, data is contributed to
//! segments (`SEGDEF`) and COMDATs. This implementation maps both to
//! sections in the unified read API.
mod comdat;
pub use comdat::*;
+2 -2
View File
@@ -1,7 +1,7 @@
use crate::read::ReadRef;
use crate::{
omf, Relocation, RelocationEncoding, RelocationFlags, RelocationKind, RelocationTarget,
SectionIndex,
Relocation, RelocationEncoding, RelocationFlags, RelocationKind, RelocationTarget,
SectionIndex, omf,
};
use super::{FrameMethod, OmfFile, TargetMethod};
+2 -2
View File
@@ -1,9 +1,9 @@
use alloc::vec::Vec;
use crate::read::{self, Error, ObjectSegment, ReadRef, Result, SectionKind};
use crate::{omf, Permissions, SegmentFlags};
use crate::{Permissions, SegmentFlags, omf};
use super::{expand_iterated_data, iterated_data_expanded_len, OmfFile, OmfFixup};
use super::{OmfFile, OmfFixup, expand_iterated_data, iterated_data_expanded_len};
/// A section in an OMF file.
///
+1
View File
@@ -130,6 +130,7 @@ fn cmd_features() -> Result<(), DynError> {
"read_core,write_core,coff",
"read_core,write_core,build_core,elf",
"read_core,write_core,macho",
"read_core,omf",
"read_core,write_core,pe",
"read_core,write_core,xcoff",
"read_core,wasm",