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:
+5
-1
@@ -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));
|
||||
|
||||
@@ -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] =
|
||||
|
||||
Reference in New Issue
Block a user