Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build/elf: include all defined symbols in the GNU hash #707

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading