+12
-6
src/ld_so/dso.rs
+12
-6
src/ld_so/dso.rs
···
836
836
(None, None)
837
837
};
838
838
839
-
let (s, t) = sym
839
+
let (s, t, tls_id) = sym
840
840
.as_ref()
841
-
.map(|(sym, obj)| (sym.as_ptr() as usize, obj.tls_offset))
842
-
.unwrap_or((0, 0));
841
+
.map(|(sym, obj)| (sym.as_ptr() as usize, obj.tls_offset, obj.tls_module_id))
842
+
//TODO: is self.tls_module_id the right fallback?
843
+
.unwrap_or((0, 0, self.tls_module_id));
843
844
844
845
let ptr = if self.pie {
845
846
(b + reloc.offset) as *mut u8
···
861
862
};
862
863
863
864
match reloc.kind {
864
-
RelocationKind::DTPMOD => set_usize(self.tls_module_id),
865
+
RelocationKind::DTPMOD => set_usize(tls_id),
865
866
//TODO: Subtract DTP_OFFSET, which is 0x800 on riscv64, 0 on x86?
866
867
RelocationKind::DTPOFF => {
867
868
if reloc.sym.0 > 0 {
···
872
873
} else {
873
874
set_usize(a);
874
875
}
875
-
},
876
+
}
876
877
RelocationKind::GOT => set_usize(s),
877
878
RelocationKind::OFFSET => set_usize((s + a).wrapping_sub(p)),
878
879
RelocationKind::RELATIVE => set_usize(b + a),
···
960
961
961
962
let resolved = resolve_sym(name, &[global_scope, self.scope()])
962
963
.map(|(sym, _, _)| sym.as_ptr() as usize)
963
-
.unwrap_or_else(|| panic!("unresolved symbol: {name} for soname {:?}", self.dynamic.soname));
964
+
.unwrap_or_else(|| {
965
+
panic!(
966
+
"unresolved symbol: {name} for soname {:?}",
967
+
self.dynamic.soname
968
+
)
969
+
});
964
970
965
971
unsafe {
966
972
*ptr = resolved + reloc.addend.unwrap_or(0);