pub struct ElfPatcher<F> { /* private fields */ }Expand description
ELF patcher.
Supports modifying the interpreter and RPATH/RUNPATH.
Implementations§
Source§impl<F: ElfRead + ElfWrite + ElfSeek> ElfPatcher<F>
impl<F: ElfRead + ElfWrite + ElfSeek> ElfPatcher<F>
Sourcepub fn new(elf: Elf, file: F) -> Self
pub fn new(elf: Elf, file: F) -> Self
Create new patcher from Elf and file.
The file should be open for writing.
Sourcepub fn set_page_size(&mut self, value: u64)
pub fn set_page_size(&mut self, value: u64)
Change page size.
Page size is used during validation and to allocate space for new sections and segments.
Sourcepub fn into_inner(self) -> (Elf, F)
pub fn into_inner(self) -> (Elf, F)
Convert into underlying reperesentation.
Sourcepub fn finish(self) -> Result<F, Error>
pub fn finish(self) -> Result<F, Error>
Finish and write the current ELF to the file.
Before writing this method generates new program header, new section header and validates them.
Sourcepub fn remove_interpreter(&mut self) -> Result<(), Error>
pub fn remove_interpreter(&mut self) -> Result<(), Error>
Remove the interpreter.
Removes all .interp sections and INTERP segments.
Sourcepub fn set_interpreter(&mut self, interpreter: &CStr) -> Result<(), Error>
pub fn set_interpreter(&mut self, interpreter: &CStr) -> Result<(), Error>
Set the interpreter.
Adds or modifies .interp section and INTERP segment.
Sourcepub fn remove_dynamic_tag(&mut self, tag: DynamicTag) -> Result<(), Error>
pub fn remove_dynamic_tag(&mut self, tag: DynamicTag) -> Result<(), Error>
Remove all entries for the specified dynamic tag from the dynamic table.
Sourcepub fn read_dynamic_table(&mut self) -> Result<Option<DynamicTable>, Error>
pub fn read_dynamic_table(&mut self) -> Result<Option<DynamicTable>, Error>
Read dynamic table.
Sourcepub fn read_dynamic_string_table(
&mut self,
) -> Result<Option<StringTable>, Error>
pub fn read_dynamic_string_table( &mut self, ) -> Result<Option<StringTable>, Error>
Read dynamic string table.
Sourcepub fn set_library_search_path<'a>(
&mut self,
entry_kind: DynamicTag,
value: impl Into<DynamicValue<'a>>,
) -> Result<(), Error>
pub fn set_library_search_path<'a>( &mut self, entry_kind: DynamicTag, value: impl Into<DynamicValue<'a>>, ) -> Result<(), Error>
Set the value under the specified dynamic tag in the dynamic table.
Does nothing if the table is not present in the file.
Sourcepub fn get_section_names(&mut self) -> Result<&StringTable, Error>
pub fn get_section_names(&mut self) -> Result<&StringTable, Error>
Get string table that contains section names.