turns out the symtab/strtab are important

This commit is contained in:
Folkert 2022-11-30 13:20:51 +01:00
parent 0e74cc14cc
commit 2d8ba79034
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -18,8 +18,8 @@ pub fn create_dylib_elf64(custom_names: &[String]) -> object::read::Result<Vec<u
writer.reserve_shstrtab_section_index(),
];
// we need this later, but must allocate it here
let soname = writer.add_dynamic_string(b"libapp.so");
let out_dynamic = [(elf::DT_SONAME, 1, Some(soname)), (elf::DT_NULL, 0, None)];
// Assign dynamic symbol indices.
let out_dynsyms: Vec<_> = custom_names
@ -65,6 +65,13 @@ pub fn create_dylib_elf64(custom_names: &[String]) -> object::read::Result<Vec<u
let dynstr_address = writer.reserved_len();
writer.reserve_dynstr();
let out_dynamic = [
(elf::DT_SONAME, 1, Some(soname)),
(elf::DT_SYMTAB, dynsym_address as u64, None),
(elf::DT_STRTAB, dynstr_address as u64, None),
(elf::DT_NULL, 0, None),
];
// aligned to the next multiple of 8
let dynamic_address = next_multiple_of(writer.reserved_len(), 8);
writer.reserve_dynamic(out_dynamic.len());