From 0fb137cc9368f17cbeab9d24f61bc52b0bbe1c38 Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 23 Aug 2022 15:13:45 +0200 Subject: [PATCH] hardcode the dynamic section content --- crates/linker/src/generate_dylib.rs | 73 ++++++++++------------------- 1 file changed, 25 insertions(+), 48 deletions(-) diff --git a/crates/linker/src/generate_dylib.rs b/crates/linker/src/generate_dylib.rs index b42962ec1c..50d53c5d98 100644 --- a/crates/linker/src/generate_dylib.rs +++ b/crates/linker/src/generate_dylib.rs @@ -115,8 +115,6 @@ impl Sections { let hash_addr = in_section.sh_addr(endian); // here we fake a bigger hash table than the input file has - // let hash = in_hash.as_ref().unwrap(); - // writer.reserve_hash(hash.bucket_count.get(endian), hash_chain_count); let reserved_before = writer.reserved_len(); writer.reserve_hash(3, hash_chain_count); let reserved_after = writer.reserved_len(); @@ -134,15 +132,8 @@ impl Sections { writer.reserve_until(offset); let gnu_hash_addr = in_section.sh_addr(endian); - // let hash = in_gnu_hash.as_ref().unwrap(); let reserved_before = writer.reserved_len(); - writer.reserve_gnu_hash( - // hash.bloom_count.get(endian), - // hash.bucket_count.get(endian), - 1, - 1, - gnu_hash_symbol_count, - ); + writer.reserve_gnu_hash(1, 1, gnu_hash_symbol_count); let reserved_after = writer.reserved_len(); extra_offset += { @@ -255,9 +246,6 @@ fn copy_file(in_data: &[u8], custom_names: &[String]) -> Result, Box Result, Box { - index = writer.reserve_null_section_index(); - } elf::SHT_STRTAB => { if i == in_syms.string_section().0 { index = writer.reserve_strtab_section_index(); @@ -292,21 +277,12 @@ fn copy_file(in_data: &[u8], custom_names: &[String]) -> Result, Box { - assert!(in_dynamic.is_none()); - in_dynamic = in_section.dynamic(endian, in_data)?; - debug_assert!(in_dynamic.is_some()); index = writer.reserve_dynamic_section_index(); } elf::SHT_HASH => { - assert!(in_hash.is_none()); - in_hash = in_section.hash_header(endian, in_data)?; - debug_assert!(in_hash.is_some()); index = writer.reserve_hash_section_index(); } elf::SHT_GNU_HASH => { - assert!(in_gnu_hash.is_none()); - in_gnu_hash = in_section.gnu_hash_header(endian, in_data)?; - debug_assert!(in_gnu_hash.is_some()); index = writer.reserve_gnu_hash_section_index(); } other => { @@ -317,27 +293,29 @@ fn copy_file(in_data: &[u8], custom_names: &[String]) -> Result, Box Result, Box