#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ArchKind {
X86_64,
AArch64,
RiscV64,
RiscV32,
LoongArch64,
X86,
Arm,
}
impl ArchKind {
#[inline]
pub const fn native() -> Self {
<NativeArch as crate::relocation::RelocationArch>::KIND
}
}
impl core::fmt::Display for ArchKind {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::X86_64 => f.write_str("x86_64"),
Self::AArch64 => f.write_str("aarch64"),
Self::RiscV64 => f.write_str("riscv64"),
Self::RiscV32 => f.write_str("riscv32"),
Self::LoongArch64 => f.write_str("loongarch64"),
Self::X86 => f.write_str("x86"),
Self::Arm => f.write_str("arm"),
}
}
}
pub mod aarch64;
pub mod arm;
pub mod loongarch64;
pub mod riscv32;
pub mod riscv64;
pub mod x86;
pub mod x86_64;
#[cfg(not(target_arch = "x86_64"))]
impl crate::relocation::EmulatedArch for x86_64::relocation::X86_64Arch {}
#[cfg(not(target_arch = "aarch64"))]
impl crate::relocation::EmulatedArch for aarch64::relocation::AArch64Arch {}
#[cfg(not(target_arch = "riscv64"))]
impl crate::relocation::EmulatedArch for riscv64::relocation::RiscV64Arch {}
#[cfg(not(target_arch = "riscv32"))]
impl crate::relocation::EmulatedArch for riscv32::relocation::RiscV32Arch {}
#[cfg(not(target_arch = "loongarch64"))]
impl crate::relocation::EmulatedArch for loongarch64::relocation::LoongArch64Arch {}
#[cfg(not(target_arch = "x86"))]
impl crate::relocation::EmulatedArch for x86::relocation::X86Arch {}
#[cfg(not(target_arch = "arm"))]
impl crate::relocation::EmulatedArch for arm::relocation::ArmArch {}
cfg_if::cfg_if! {
if #[cfg(target_arch = "x86_64")]{
pub use x86_64::*;
pub use x86_64::relocation::X86_64Arch as NativeArch;
}else if #[cfg(target_arch = "riscv64")]{
pub use riscv64::*;
pub use riscv64::relocation::RiscV64Arch as NativeArch;
}else if #[cfg(target_arch = "riscv32")]{
pub use riscv32::*;
pub use riscv32::relocation::RiscV32Arch as NativeArch;
}else if #[cfg(target_arch="aarch64")]{
pub use aarch64::*;
pub use aarch64::relocation::AArch64Arch as NativeArch;
}else if #[cfg(target_arch="loongarch64")]{
pub use loongarch64::*;
pub use loongarch64::relocation::LoongArch64Arch as NativeArch;
}else if #[cfg(target_arch = "x86")]{
pub use x86::*;
pub use x86::relocation::X86Arch as NativeArch;
}else if #[cfg(target_arch = "arm")]{
pub use arm::*;
pub use arm::relocation::ArmArch as NativeArch;
}
}
#[cfg(feature = "object")]
pub(crate) mod object;
#[cfg(feature = "lazy-binding")]
#[inline]
pub(crate) fn prepare_lazy_bind(got: *mut usize, dylib: crate::relocation::RelocAddr) {
unsafe {
got.add(DYLIB_OFFSET).write(dylib.into_inner());
got.add(RESOLVE_FUNCTION_OFFSET)
.write(dl_runtime_resolve as *const () as usize);
}
}