This commit is contained in:
Folkert 2022-08-23 21:20:23 +02:00
parent daee025ff6
commit e609919f39
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -51,11 +51,7 @@ struct DynamicSymbol {
gnu_hash: Option<u32>, gnu_hash: Option<u32>,
} }
#[derive(Debug)] type Section = SectionHeader64<object::Endianness>;
struct Section {
in_index: usize,
section: SectionHeader64<object::Endianness>,
}
struct Sections { struct Sections {
hash: Section, hash: Section,
@ -93,11 +89,11 @@ impl Sections {
for (i, out_offset) in offsets.iter_mut().enumerate().take(5) { for (i, out_offset) in offsets.iter_mut().enumerate().take(5) {
// symtab, strtab and shstrtab is ignored because they are not ALLOC // symtab, strtab and shstrtab is ignored because they are not ALLOC
let in_section = match i { let in_section = match i {
0 => sections.hash.section, 0 => sections.hash,
1 => sections.gnu_hash.section, 1 => sections.gnu_hash,
2 => sections.dynsym.section, 2 => sections.dynsym,
3 => sections.dynstr.section, 3 => sections.dynstr,
4 => sections.dynamic.section, 4 => sections.dynamic,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -167,14 +163,10 @@ fn copy_file(in_data: &[u8], custom_names: &[String]) -> Result<Vec<u8>, Box<dyn
let in_dynsyms = in_sections.symbols(endian, in_data, elf::SHT_DYNSYM)?; let in_dynsyms = in_sections.symbols(endian, in_data, elf::SHT_DYNSYM)?;
let help = |name: &[u8]| { let help = |name: &[u8]| {
let (in_index, section) = in_sections *in_sections
.section_by_name(Endianness::Little, name) .section_by_name(Endianness::Little, name)
.unwrap(); .unwrap()
.1
Section {
in_index,
section: *section,
}
}; };
let sections = Sections { let sections = Sections {