fix(dso): sysv hash table

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2026-07-15 22:55:39 +10:00
parent 260bccbd3c
commit ee98a2b09c
2 changed files with 22 additions and 7 deletions
Generated
+5 -5
View File
@@ -321,7 +321,7 @@ dependencies = [
[[package]]
name = "object"
version = "0.36.7"
source = "git+https://gitlab.redox-os.org/andypython/object?branch=new#52a2cdfeab282fc8d27dcf8ec0e839b7ff4c35d8"
source = "git+https://gitlab.redox-os.org/andypython/object?branch=new#da781336d847df0deb897ed1162785f6c2057c56"
dependencies = [
"memchr",
]
@@ -615,9 +615,9 @@ checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649"
[[package]]
name = "spin"
version = "0.9.8"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
dependencies = [
"lock_api",
]
@@ -630,9 +630,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "syn"
version = "2.0.118"
version = "2.0.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
dependencies = [
"proc-macro2",
"quote",
+17 -2
View File
@@ -50,6 +50,7 @@ mod shim {
pub type FileHeader = elf::FileHeader32<NativeEndian>;
pub type ProgramHeader = elf::ProgramHeader32<NativeEndian>;
pub type GnuHashHeader = elf::GnuHashHeader<NativeEndian>;
pub type SysVHashHeader = elf::HashHeader<NativeEndian>;
pub type ElfFile<'a> = ElfFile32<'a, NativeEndian>;
}
@@ -63,6 +64,7 @@ mod shim {
pub type FileHeader = elf::FileHeader64<NativeEndian>;
pub type ProgramHeader = elf::ProgramHeader64<NativeEndian>;
pub type GnuHashHeader = elf::GnuHashHeader<NativeEndian>;
pub type SysVHashHeader = elf::HashHeader<NativeEndian>;
pub type ElfFile<'a> = ElfFile64<'a, NativeEndian>;
}
@@ -827,8 +829,21 @@ impl DSO {
// XXX: Both GNU_HASH and HASH may be present, we give priority
// to GNU_HASH as it is significantly faster.
elf::DT_HASH if hash_table.is_none() => {
// FIXME: BEFORE MR FIX THIS
// todo!();
let header = unsafe { ptr.cast::<SysVHashHeader>().as_ref() }.unwrap();
let bucket_count = header.bucket_count.get(NativeEndian) as usize;
let chain_count = header.chain_count.get(NativeEndian) as usize;
let mut ptr = unsafe {
ptr.byte_add(size_of::<SysVHashHeader>())
.cast::<U32<NativeEndian>>()
};
let buckets = unsafe { slice::from_raw_parts(ptr, bucket_count) };
unsafe { ptr = ptr.add(bucket_count) };
let chains = unsafe { slice::from_raw_parts(ptr, chain_count) };
let table = SysVHashTable { buckets, chains };
hash_table = Some(HashTable::Sysv(table));
}
elf::DT_PLTGOT => {