use crate::elf;
use crate::macros::define_str_enum;
define_str_enum! {
Arch,
(Aarch64, "aarch64"),
(Arc, "arc"),
(Arm, "arm"),
(Armeb, "armeb"),
(I386, "i386"),
(Loongarch64, "loongarch64"),
(Mips, "mips"),
(Mips64, "mips64"),
(Mips64el, "mips64el"),
(Mipsel, "mipsel"),
(Powerpc, "powerpc"),
(Powerpc64, "powerpc64"),
(Riscv64, "riscv64"),
(X86_64, "x86_64"),
(All, "all"),
(Noarch, "noarch"),
}
impl From<Option<elf::Target>> for Arch {
fn from(target: Option<elf::Target>) -> Self {
use elf::macros::*;
match target {
target!(Arc) => Self::Arc,
target!(Loongarch, LittleEndian, Elf64) => Self::Loongarch64,
target!(X86_64) => Self::X86_64,
target!(I386) => Self::I386,
target!(Aarch64) => Self::Aarch64,
target!(Arm, BigEndian) => Self::Armeb,
target!(Arm, LittleEndian) => Self::Arm,
target!(Mips, LittleEndian, Elf32) => Self::Mipsel,
target!(Mips, BigEndian, Elf32) => Self::Mips,
target!(Mips, LittleEndian, Elf64) => Self::Mips64el,
target!(Mips, BigEndian, Elf64) => Self::Mips64,
target!(Ppc, BigEndian) => Self::Powerpc,
target!(Ppc64, BigEndian) => Self::Powerpc64,
Some(other) => {
log::warn!("No architecture mapping for ELF target \"{}\"", other);
Self::Noarch
}
None => Self::Noarch,
}
}
}