diff --git a/src/common/symbol.rs b/src/common/symbol.rs index e7e3d34..afa5420 100644 --- a/src/common/symbol.rs +++ b/src/common/symbol.rs @@ -50,7 +50,13 @@ impl Symbols { R: Relocatable, { self.value_index.map_or(Ok(&[]), |v| { - object.symbol_value(self.indexes[v].symbol_index) + let si = self.indexes[v]; + // can this be compile time checked?? + if si.object_index != object.object_index() { + Err(Error::InvalidObjectIndex) + } else { + object.symbol_value(si.symbol_index) + } }) } diff --git a/src/formats/elf/object.rs b/src/formats/elf/object.rs index 7839b89..7dc391c 100644 --- a/src/formats/elf/object.rs +++ b/src/formats/elf/object.rs @@ -224,7 +224,7 @@ impl Relocatable for ElfObject { .ok_or(Error::InvalidSectionIndex)?; let sh_offset: usize = shdr.sh_offset as usize; - Ok(sh_offset) + Ok(sh_offset + s64.st_value as usize) } fn symbol_needs_resolving(&self, index: usize) -> bool {