Skip to content
Snippets Groups Projects
Verified Commit 47baf499 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Fix TLS offsets

parent cb9e779c
No related branches found
No related tags found
No related merge requests found
...@@ -316,6 +316,12 @@ impl Linker { ...@@ -316,6 +316,12 @@ impl Linker {
mmap_data.copy_from_slice(obj_data); mmap_data.copy_from_slice(obj_data);
}, },
program_header::PT_TLS => { program_header::PT_TLS => {
let valign = if ph.p_align > 0 {
((ph.p_memsz + (ph.p_align - 1))/ph.p_align) * ph.p_align
} else {
ph.p_memsz
} as usize;
let obj_data = { let obj_data = {
let range = ph.file_range(); let range = ph.file_range();
match object.get(range.clone()) { match object.get(range.clone()) {
...@@ -328,11 +334,12 @@ impl Linker { ...@@ -328,11 +334,12 @@ impl Linker {
let tls_data = { let tls_data = {
let (index, start) = if *elf_name == primary { let (index, start) = if *elf_name == primary {
(0, tls.len() - tls_primary) (0, tls.len() - valign)
} else { } else {
tls_offset += obj_data.len(); let start = tls.len() - (tls_offset + valign);
tls_offset += vsize;
tls_index += 1; tls_index += 1;
(tls_index, tls.len() - tls_offset) (tls_index, start)
}; };
let range = start..start + obj_data.len(); let range = start..start + obj_data.len();
match tls.get_mut(range.clone()) { match tls.get_mut(range.clone()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment