use core::fmt;
#[cfg(feature = "enable-serde")]
use serde_derive::{Deserialize, Serialize};
pub type CodeOffset = u32;
pub type Addend = i64;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub enum Reloc {
Abs4,
Abs8,
X86PCRel4,
X86CallPCRel4,
X86CallPLTRel4,
X86GOTPCRel4,
X86SecRel,
Arm32Call,
Arm64Call,
S390xPCRel32Dbl,
S390xPLTRel32Dbl,
ElfX86_64TlsGd,
MachOX86_64Tlv,
MachOAarch64TlsAdrPage21,
MachOAarch64TlsAdrPageOff12,
Aarch64TlsDescAdrPage21,
Aarch64TlsDescLd64Lo12,
Aarch64TlsDescAddLo12,
Aarch64TlsDescCall,
Aarch64AdrGotPage21,
Aarch64AdrPrelPgHi21,
Aarch64AddAbsLo12Nc,
Aarch64Ld64GotLo12Nc,
RiscvCallPlt,
RiscvTlsGdHi20,
RiscvPCRelLo12I,
RiscvGotHi20,
RiscvPCRelHi20,
S390xTlsGd64,
S390xTlsGdCall,
PulleyPcRel,
PulleyCallIndirectHost,
}
impl fmt::Display for Reloc {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Self::Abs4 => write!(f, "Abs4"),
Self::Abs8 => write!(f, "Abs8"),
Self::S390xPCRel32Dbl => write!(f, "PCRel32Dbl"),
Self::S390xPLTRel32Dbl => write!(f, "PLTRel32Dbl"),
Self::X86PCRel4 => write!(f, "PCRel4"),
Self::X86CallPCRel4 => write!(f, "CallPCRel4"),
Self::X86CallPLTRel4 => write!(f, "CallPLTRel4"),
Self::X86GOTPCRel4 => write!(f, "GOTPCRel4"),
Self::X86SecRel => write!(f, "SecRel"),
Self::Arm32Call | Self::Arm64Call => write!(f, "Call"),
Self::RiscvCallPlt => write!(f, "RiscvCallPlt"),
Self::RiscvTlsGdHi20 => write!(f, "RiscvTlsGdHi20"),
Self::RiscvGotHi20 => write!(f, "RiscvGotHi20"),
Self::RiscvPCRelHi20 => write!(f, "RiscvPCRelHi20"),
Self::RiscvPCRelLo12I => write!(f, "RiscvPCRelLo12I"),
Self::ElfX86_64TlsGd => write!(f, "ElfX86_64TlsGd"),
Self::MachOX86_64Tlv => write!(f, "MachOX86_64Tlv"),
Self::MachOAarch64TlsAdrPage21 => write!(f, "MachOAarch64TlsAdrPage21"),
Self::MachOAarch64TlsAdrPageOff12 => write!(f, "MachOAarch64TlsAdrPageOff12"),
Self::Aarch64TlsDescAdrPage21 => write!(f, "Aarch64TlsDescAdrPage21"),
Self::Aarch64TlsDescLd64Lo12 => write!(f, "Aarch64TlsDescLd64Lo12"),
Self::Aarch64TlsDescAddLo12 => write!(f, "Aarch64TlsDescAddLo12"),
Self::Aarch64TlsDescCall => write!(f, "Aarch64TlsDescCall"),
Self::Aarch64AdrGotPage21 => write!(f, "Aarch64AdrGotPage21"),
Self::Aarch64Ld64GotLo12Nc => write!(f, "Aarch64AdrGotLo12Nc"),
Self::Aarch64AdrPrelPgHi21 => write!(f, "Aarch64AdrPrelPgHi21"),
Self::Aarch64AddAbsLo12Nc => write!(f, "Aarch64AddAbsLo12Nc"),
Self::S390xTlsGd64 => write!(f, "TlsGd64"),
Self::S390xTlsGdCall => write!(f, "TlsGdCall"),
Self::PulleyPcRel => write!(f, "PulleyPcRel"),
Self::PulleyCallIndirectHost => write!(f, "PulleyCallIndirectHost"),
}
}
}
#[derive(Debug, PartialEq)]
pub struct CodeInfo {
pub total_size: CodeOffset,
}