[WIP] OMF object support

This commit is contained in:
Luke Street 2025-09-25 00:50:35 -06:00
parent 90e81fad7e
commit 9f37d99fbd
6 changed files with 7 additions and 3 deletions

3
Cargo.lock generated
View File

@ -3624,8 +3624,7 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.37.3" version = "0.37.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/encounter/object?branch=omf#f8023933c931335a1ea55384bfef538457c412a5"
checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]

View File

@ -132,7 +132,7 @@ itertools = { version = "0.14", default-features = false, features = ["use_alloc
log = { version = "0.4", default-features = false, optional = true } log = { version = "0.4", default-features = false, optional = true }
memmap2 = { version = "0.9", optional = true } memmap2 = { version = "0.9", optional = true }
num-traits = { version = "0.2", default-features = false, optional = true } num-traits = { version = "0.2", default-features = false, optional = true }
object = { version = "0.37", default-features = false, features = ["read_core", "elf", "coff"] } object = { git = "https://github.com/encounter/object", branch = "omf", default-features = false, features = ["read_core", "elf", "coff", "omf"] }
pbjson = { version = "0.8", default-features = false, optional = true } pbjson = { version = "0.8", default-features = false, optional = true }
prost = { version = "0.14", default-features = false, features = ["derive"], optional = true } prost = { version = "0.14", default-features = false, features = ["derive"], optional = true }
regex = { version = "1.11", default-features = false, features = [], optional = true } regex = { version = "1.11", default-features = false, features = [], optional = true }

View File

@ -332,6 +332,7 @@ impl Arch for ArchPpc {
pe::IMAGE_REL_PPC_PAIR => Some("IMAGE_REL_PPC_PAIR"), pe::IMAGE_REL_PPC_PAIR => Some("IMAGE_REL_PPC_PAIR"),
_ => None, _ => None,
}, },
_ => None,
} }
} }

View File

@ -72,6 +72,7 @@ impl ArchX86 {
elf::R_386_16 => Some(2), elf::R_386_16 => Some(2),
_ => None, _ => None,
}, },
RelocationFlags::Omf() => Some(4), // TODO
}, },
Architecture::X86_64 => match flags { Architecture::X86_64 => match flags {
RelocationFlags::Coff(typ) => match typ { RelocationFlags::Coff(typ) => match typ {
@ -84,6 +85,7 @@ impl ArchX86 {
elf::R_X86_64_64 => Some(8), elf::R_X86_64_64 => Some(8),
_ => None, _ => None,
}, },
RelocationFlags::Omf() => None, // TODO
}, },
} }
} }

View File

@ -370,6 +370,7 @@ pub struct Relocation {
pub enum RelocationFlags { pub enum RelocationFlags {
Elf(u32), Elf(u32),
Coff(u16), Coff(u16),
Omf(/* TODO */),
} }
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]

View File

@ -510,6 +510,7 @@ fn map_section_relocations(
let flags = match reloc.flags() { let flags = match reloc.flags() {
object::RelocationFlags::Elf { r_type } => RelocationFlags::Elf(r_type), object::RelocationFlags::Elf { r_type } => RelocationFlags::Elf(r_type),
object::RelocationFlags::Coff { typ } => RelocationFlags::Coff(typ), object::RelocationFlags::Coff { typ } => RelocationFlags::Coff(typ),
object::RelocationFlags::Omf { .. } => RelocationFlags::Omf(/* TODO */),
flags => bail!("Unhandled relocation flags: {:?}", flags), flags => bail!("Unhandled relocation flags: {:?}", flags),
}; };
let target_symbol = match symbol_indices.get(symbol_index.0).copied() { let target_symbol = match symbol_indices.get(symbol_index.0).copied() {