diff --git a/crates/rewrite/testfiles/elf/libbase.so.noop b/crates/rewrite/testfiles/elf/libbase.so.noop index bf66c185..e30977ba 100644 --- a/crates/rewrite/testfiles/elf/libbase.so.noop +++ b/crates/rewrite/testfiles/elf/libbase.so.noop @@ -331,14 +331,14 @@ SectionHeader { SHF_ALLOC (0x2) Address: 0x2F0 Offset: 0x2F0 - Size: 0x24 + Size: 0x28 Link: 4 Info: 0 AddressAlign: 0x8 EntrySize: 0x0 GnuHash { BucketCount: 2 - SymbolBase: 7 + SymbolBase: 6 BloomCount: 1 BloomShift: 6 } @@ -424,25 +424,25 @@ SectionHeader { } Symbol { Index: 6 - Name: "libbase.so" + Name: "main" Version: "libbase.so" - Value: 0x0 - Size: 0x0 - Type: STT_OBJECT (0x1) + Value: 0x1119 + Size: 0x23 + Type: STT_FUNC (0x2) Bind: STB_GLOBAL (0x1) Other: STV_DEFAULT (0x0) - SectionIndex: SHN_ABS (0xFFF1) + SectionIndex: 15 } Symbol { Index: 7 - Name: "main" + Name: "libbase.so" Version: "libbase.so" - Value: 0x1119 - Size: 0x23 - Type: STT_FUNC (0x2) + Value: 0x0 + Size: 0x0 + Type: STT_OBJECT (0x1) Bind: STB_GLOBAL (0x1) Other: STV_DEFAULT (0x0) - SectionIndex: 15 + SectionIndex: SHN_ABS (0xFFF1) } } SectionHeader { diff --git a/src/build/elf.rs b/src/build/elf.rs index 9e31778b..3441d903 100644 --- a/src/build/elf.rs +++ b/src/build/elf.rs @@ -907,7 +907,9 @@ impl<'data> Builder<'data> { if hash_id.is_some() { hash = Some(elf::hash(&symbol.name)); } - if gnu_hash_id.is_some() && symbol.section.is_some() { + if gnu_hash_id.is_some() + && (symbol.section.is_some() || symbol.st_shndx != elf::SHN_UNDEF) + { gnu_hash = Some(elf::gnu_hash(&symbol.name)); } }