Struct elfbin::Builder

source ·
pub struct Builder<W: Write + Seek> { /* private fields */ }
Expand description

Represents an ELF file under construction.

Implementations§

Begin constructing a new ELF file with the given header information in the given writer.

The header information also serves to select which specific ELF variant the builder will generate, by choosing a class and an encoding.

Define a new symbol in the output file, using the contents of a given reader as the symbol contents.

add_symbol will read the given reader to completion and copy all of its data into the output file.

add_symbol doesn’t check if you define the same symbol name more than once, but doing so will create a confusing object file that may not be accepted by an ELF linker.

This function aligns the data to the word size of the destination ELF file. Use add_symbol_align instead if you need specific alignment.

Define a new symbol in the output file with a particular alignment, using the contents of a given reader as the symbol contents.

add_symbol_align will read the given reader to completion and copy all of its data into the output file.

add_symbol_align doesn’t check if you define the same symbol name more than once, but doing so will create a confusing object file that may not be accepted by an ELF linker.

Examples found in repository?
src/lib.rs (line 168)
163
164
165
166
167
168
169
    pub fn add_symbol<S: Into<String>, R: Read>(&mut self, name: S, src: R) -> Result<Symbol> {
        let align = match self.class {
            Class::ELF32 => 4,
            Class::ELF64 => 8,
        };
        self.add_symbol_align(name, align, src)
    }

Finalizes the ELF metadata in the underlying file and then returns that file.

If you don’t call close then the file will be left in a state where it contains any symbol data written previously but it lacks the necessary metadata for an ELF linker to find that data, and thus the object file will appear to have no symbols at all.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.