Object file support for s390x (#2872)
Add support for s390x binary format object files. In particular, add support for s390x ELF relocation types (currently only S390xPCRel32Dbl).
This commit is contained in:
@@ -60,6 +60,8 @@ pub enum Reloc {
|
||||
Arm64Call,
|
||||
/// RISC-V call target
|
||||
RiscvCall,
|
||||
/// s390x PC-relative 4-byte offset
|
||||
S390xPCRel32Dbl,
|
||||
|
||||
/// Elf x86_64 32 bit signed PC relative offset to two GOT entries for GD symbol.
|
||||
ElfX86_64TlsGd,
|
||||
@@ -75,6 +77,7 @@ impl fmt::Display for Reloc {
|
||||
match *self {
|
||||
Self::Abs4 => write!(f, "Abs4"),
|
||||
Self::Abs8 => write!(f, "Abs8"),
|
||||
Self::S390xPCRel32Dbl => write!(f, "PCRel32Dbl"),
|
||||
Self::X86PCRel4 => write!(f, "PCRel4"),
|
||||
Self::X86PCRelRodata4 => write!(f, "PCRelRodata4"),
|
||||
Self::X86CallPCRel4 => write!(f, "CallPCRel4"),
|
||||
|
||||
@@ -72,6 +72,15 @@ impl CompiledBlob {
|
||||
write_unaligned(at as *mut i32, pcrel)
|
||||
};
|
||||
}
|
||||
Reloc::S390xPCRel32Dbl => {
|
||||
let base = get_address(name);
|
||||
let what = unsafe { base.offset(isize::try_from(addend).unwrap()) };
|
||||
let pcrel = i32::try_from(((what as isize) - (at as isize)) >> 1).unwrap();
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))]
|
||||
unsafe {
|
||||
write_unaligned(at as *mut i32, pcrel)
|
||||
};
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,11 @@ cfg_if! {
|
||||
cs.set_skipdata(true).map_err(map_caperr)?;
|
||||
cs
|
||||
}
|
||||
Architecture::S390x {..} => Capstone::new()
|
||||
.sysz()
|
||||
.mode(arch::sysz::ArchMode::Default)
|
||||
.build()
|
||||
.map_err(map_caperr)?,
|
||||
_ => anyhow::bail!("Unknown ISA"),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user