Skip to content

Commit

Permalink
build/elf: include all defined symbols in the GNU hash (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc authored Jul 21, 2024
1 parent decc31d commit e514574
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 12 additions & 12 deletions crates/rewrite/testfiles/elf/libbase.so.noop
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/build/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down

0 comments on commit e514574

Please sign in to comment.