Adapt OMF to upstream API changes (permissions, subtractor)

This commit is contained in:
Luke Street
2026-06-11 10:20:23 -06:00
parent 958fd5bf94
commit aa88ee5582
2 changed files with 15 additions and 2 deletions
+1
View File
@@ -136,6 +136,7 @@ impl<'data, 'file, R: ReadRef<'data>> Iterator for OmfRelocationIterator<'data,
target,
addend: (reloc.target_displacement as i64) + base_addend,
implicit_addend: false,
subtractor: None,
flags: RelocationFlags::Omf {
location: reloc.location,
mode: if reloc.is_segment_relative {
+14 -2
View File
@@ -1,7 +1,7 @@
use alloc::vec::Vec;
use crate::read::{self, ObjectSegment, ReadRef, Result};
use crate::{omf, SegmentFlags};
use crate::read::{self, ObjectSegment, ReadRef, Result, SectionKind};
use crate::{omf, Permissions, SegmentFlags};
use super::{OmfFile, OmfFixup};
@@ -126,6 +126,18 @@ impl<'data, 'file, R: ReadRef<'data>> ObjectSegment<'data> for OmfSegmentRef<'da
fn flags(&self) -> SegmentFlags {
SegmentFlags::None
}
fn permissions(&self) -> Permissions {
// OMF segment definitions don't carry permission flags, so derive them
// from the segment's class name.
match self.file.segment_section_kind(self.index) {
SectionKind::Text => Permissions::new(true, false, true),
SectionKind::ReadOnlyData | SectionKind::ReadOnlyString | SectionKind::Debug => {
Permissions::new(true, false, false)
}
_ => Permissions::new(true, true, false),
}
}
}
/// An iterator over OMF segments.