fix(ld.so): set tls module id to 0 if no tls

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2024-12-05 23:33:41 +11:00
parent e34ecc31a1
commit 32077ee341
2 changed files with 10 additions and 1 deletions
+5 -1
View File
@@ -100,7 +100,11 @@ impl DSO {
dependencies: elf.libraries.iter().map(|s| s.to_string()).collect(),
init_array: init_array,
fini_array: fini_array,
tls_module_id: tls_module_id,
tls_module_id: if tcb_master.is_some() {
tls_module_id
} else {
0
},
tls_offset: tls_offset,
};
return Ok((dso, tcb_master));
+5
View File
@@ -201,6 +201,11 @@ impl Linker {
tcb.setup_dtv(tcb_masters.len());
for obj in new_objects.iter() {
if obj.tls_module_id == 0 {
// No TLS for this object.
continue;
}
if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
// Below the TP
tcb.dtv_mut().unwrap()[obj.tls_module_id - 1] =