pub struct Rewriter<'data> { /* private fields */ }
Expand description
A rewriter for object and executable files.
This struct provides a way to read a file, modify it, and write it back.
Implementations§
Source§impl<'data> Rewriter<'data>
impl<'data> Rewriter<'data>
Sourcepub fn modify(&mut self, options: Options) -> Result<()>
pub fn modify(&mut self, options: Options) -> Result<()>
Modify the file according to the given options.
Sourcepub fn delete_symbols(&mut self, names: &HashSet<Vec<u8>>)
pub fn delete_symbols(&mut self, names: &HashSet<Vec<u8>>)
Delete symbols from the symbol table.
For ELF files, this deletes symbols from both the symbol table and the dynamic symbol table.
Sourcepub fn rename_symbols(&mut self, names: &HashMap<Vec<u8>, Vec<u8>>)
pub fn rename_symbols(&mut self, names: &HashMap<Vec<u8>, Vec<u8>>)
Rename symbols in the symbol table.
For ELF files, this renames symbols in both the symbol table and the dynamic symbol table.
The names
map is from old names to new names.
Sourcepub fn delete_sections(&mut self, names: &HashSet<Vec<u8>>)
pub fn delete_sections(&mut self, names: &HashSet<Vec<u8>>)
Delete sections from the file.
Source§impl<'data> Rewriter<'data>
impl<'data> Rewriter<'data>
Sourcepub fn elf_delete_symbols(&mut self, names: &HashSet<Vec<u8>>)
pub fn elf_delete_symbols(&mut self, names: &HashSet<Vec<u8>>)
Delete symbols from the symbol table.
Sourcepub fn elf_delete_dynamic_symbols(&mut self, names: &HashSet<Vec<u8>>)
pub fn elf_delete_dynamic_symbols(&mut self, names: &HashSet<Vec<u8>>)
Delete symbols from the dynamic symbol table.
Sourcepub fn elf_rename_symbols(&mut self, names: &HashMap<Vec<u8>, Vec<u8>>)
pub fn elf_rename_symbols(&mut self, names: &HashMap<Vec<u8>, Vec<u8>>)
Rename symbols in the symbol table.
The names
map is from old names to new names.
Sourcepub fn elf_rename_dynamic_symbols(&mut self, names: &HashMap<Vec<u8>, Vec<u8>>)
pub fn elf_rename_dynamic_symbols(&mut self, names: &HashMap<Vec<u8>, Vec<u8>>)
Rename symbols in the dynamic symbol table.
The names
map is from old names to new names.
Sourcepub fn elf_add_dynamic_debug(&mut self) -> Result<()>
pub fn elf_add_dynamic_debug(&mut self) -> Result<()>
Add a DT_DEBUG
entry to the dynamic section.
Sourcepub fn elf_runpath(&self) -> Option<&[u8]>
pub fn elf_runpath(&self) -> Option<&[u8]>
Find the first DT_RUNPATH
or DT_RPATH
entry in the dynamic section.
Sourcepub fn elf_delete_runpath(&mut self) -> Result<()>
pub fn elf_delete_runpath(&mut self) -> Result<()>
Delete any DT_RUNPATH
or DT_RPATH
entries in the dynamic section.
Sourcepub fn elf_set_runpath(&mut self, runpath: Vec<u8>) -> Result<()>
pub fn elf_set_runpath(&mut self, runpath: Vec<u8>) -> Result<()>
Set the path for any DT_RUNPATH
or DT_RPATH
entry in the dynamic section.
Sourcepub fn elf_add_runpath(&mut self, runpaths: &[Vec<u8>]) -> Result<()>
pub fn elf_add_runpath(&mut self, runpaths: &[Vec<u8>]) -> Result<()>
Add additional paths to any DT_RUNPATH
or DT_RPATH
entry in the dynamic section.
Sourcepub fn elf_use_runpath(&mut self) -> Result<()>
pub fn elf_use_runpath(&mut self) -> Result<()>
Change any DT_RPATH
entry in the dynamic section to DT_RUNPATH
.
Sourcepub fn elf_use_rpath(&mut self) -> Result<()>
pub fn elf_use_rpath(&mut self) -> Result<()>
Change any DT_RUNPATH
entry in the dynamic section to DT_RPATH
.
Sourcepub fn elf_needed(&self) -> impl Iterator<Item = &[u8]>
pub fn elf_needed(&self) -> impl Iterator<Item = &[u8]>
Find the DT_NEEDED
entries in the dynamic section.
Sourcepub fn elf_delete_needed(&mut self, names: &HashSet<Vec<u8>>) -> Result<()>
pub fn elf_delete_needed(&mut self, names: &HashSet<Vec<u8>>) -> Result<()>
Delete DT_NEEDED
entries from the dynamic section.
Sourcepub fn elf_replace_needed(
&mut self,
names: &HashMap<Vec<u8>, Vec<u8>>,
) -> Result<()>
pub fn elf_replace_needed( &mut self, names: &HashMap<Vec<u8>, Vec<u8>>, ) -> Result<()>
Replace DT_NEEDED
entries in the dynamic section.
Sourcepub fn elf_add_needed(&mut self, names: &[Vec<u8>]) -> Result<()>
pub fn elf_add_needed(&mut self, names: &[Vec<u8>]) -> Result<()>
Add DT_NEEDED
entries to the start of the dynamic section.
This does not add a DT_NEEDED
entry if the library is already listed.
Sourcepub fn elf_soname(&self) -> Option<&[u8]>
pub fn elf_soname(&self) -> Option<&[u8]>
Find the DT_SONAME
entry in the dynamic section.
Sourcepub fn elf_set_soname(&mut self, soname: Vec<u8>) -> Result<()>
pub fn elf_set_soname(&mut self, soname: Vec<u8>) -> Result<()>
Set the DT_SONAME
entry in the dynamic section.
Sourcepub fn elf_interpreter(&self) -> Option<&[u8]>
pub fn elf_interpreter(&self) -> Option<&[u8]>
Find the interpreter path in the PT_INTERP
segment.