[][src]Struct crt0stack::Builder

pub struct Builder<'a, T> { /* fields omitted */ }

Builder for the initial stack of a Linux ELF binary

Examples

use crt0stack::{Builder, Entry};

let mut stack = [1u8; 512];
let stack = stack.as_mut();

let mut builder = Builder::new(stack);

builder.push("/init").unwrap();
let mut builder = builder.done().unwrap();

builder.push("HOME=/root").unwrap();
let mut builder = builder.done().unwrap();

let auxv = [
    Entry::Gid(1000),
    Entry::Uid(1000),
    Entry::Platform("x86_64"),
    Entry::ExecFilename("/init"),
];
auxv.iter().for_each(|e| builder.push(e).unwrap());

let handle = builder.done().unwrap();

Implementations

impl<'a> Builder<'a, Arg>[src]

pub fn new(stack: &'a mut [u8]) -> Self[src]

Create a new Builder for the stack

Needs a sufficiently large byte slice.

pub fn push(&mut self, arg: &str) -> Result<(), OutOfSpace>[src]

Push a new argv argument

pub fn done(self) -> Result<Builder<'a, Env>, OutOfSpace>[src]

Advance the Builder to the next step

impl<'a> Builder<'a, Env>[src]

pub fn push(&mut self, env: &str) -> Result<(), OutOfSpace>[src]

Add a new environment variable string

pub fn done(self) -> Result<Builder<'a, Aux>, OutOfSpace>[src]

Advance the Build to the next step

impl<'a> Builder<'a, Aux>[src]

pub fn push(&mut self, entry: &Entry<'_>) -> Result<(), OutOfSpace>[src]

Add a new Entry

pub fn done(self) -> Result<Handle<'a>, OutOfSpace>[src]

Finish the Builder and get the Handle

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Builder<'a, T> where
    T: RefUnwindSafe

impl<'a, T> Send for Builder<'a, T> where
    T: Send

impl<'a, T> Sync for Builder<'a, T> where
    T: Sync

impl<'a, T> Unpin for Builder<'a, T> where
    T: Unpin

impl<'a, T> !UnwindSafe for Builder<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.