pub enum Arch {
X86_64,
Arm,
Riscv32,
Riscv64,
Wasm32,
Wasm64,
Unknown,
}
Expand description
Enum which specifies the architecture
Variants§
Implementations§
Source§impl Arch
impl Arch
Sourcepub fn host() -> Arch
pub fn host() -> Arch
Returns the native architecture
Examples found in repository?
examples/simple.rs (line 34)
3pub fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let mut obj = ObjectBuilder::new("test.o");
5
6 obj.decls(vec![
7 ("callme", Decl::Function(Scope::Import)),
8 ("call", Decl::Function(Scope::Export)),
9 ("data", Decl::Data(Scope::Export)),
10 ]);
11
12 obj.define(
13 "call",
14 vec![
15 0xF3, 0x0F, 0x1E, 0xFA, // endbr64
16 0x55, // push rbp
17 0x48, 0x89, 0xE5, // mov rbp, rsp
18 0xE8, 0x00, 0x00, 0x00, 0x00, // call callme
19 0x5D, // pop rbp
20 0xC3, // ret
21 ],
22 );
23
24 obj.define("data",
25 b"Hello World".into()
26 );
27
28 obj.link(Link {
29 from: "call".into(),
30 to: "callme".into(),
31 at: 9,
32 });
33
34 obj.write(BinFormat::host(), Arch::host(), Endian::host())?;
35
36 Ok(())
37}
Trait Implementations§
Source§impl Ord for Arch
impl Ord for Arch
Source§impl PartialOrd for Arch
impl PartialOrd for Arch
impl Copy for Arch
impl Eq for Arch
impl StructuralPartialEq for Arch
Auto Trait Implementations§
impl Freeze for Arch
impl RefUnwindSafe for Arch
impl Send for Arch
impl Sync for Arch
impl Unpin for Arch
impl UnwindSafe for Arch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.