Do TLS alignment in reliable way

This commit is contained in:
Jeremy Soller
2025-11-13 12:07:06 -07:00
parent afb8f46020
commit 74e3ad1c2c
2 changed files with 6 additions and 6 deletions
+4 -5
View File
@@ -549,10 +549,6 @@ impl DSO {
// Copy data
let mut dynamic = None;
for ph in elf.elf_program_headers() {
let voff = ph.p_vaddr(endian) % ph.p_align(endian);
let vsize = ((ph.p_memsz(endian) + voff) as usize)
.next_multiple_of(ph.p_align(endian) as usize);
match ph.p_type(endian) {
elf::PT_LOAD => {
if skip_load_segment_copy {
@@ -583,6 +579,9 @@ impl DSO {
}
}
};
let voff = ph.p_vaddr(endian) % ph.p_align(endian);
let vsize = ((ph.p_memsz(endian) + voff) as usize)
.next_multiple_of(ph.p_align(endian) as usize);
trace!(
" copy {:#x}, {:#x}: {:#x}, {:#x}",
ph.p_vaddr(endian) - voff,
@@ -603,7 +602,7 @@ impl DSO {
tcb_master = Some(Master {
ptr,
len: ph.p_filesz(endian) as usize,
offset: tls_offset + vsize,
offset: tls_offset + ph.p_memsz(endian) as usize,
});
trace!(" tcb master {:x?}", tcb_master);
}
+2 -1
View File
@@ -793,7 +793,8 @@ impl Linker {
dlopened,
self.next_object_id,
self.next_tls_module_id,
self.tls_size,
// Ensure TLS is aligned to 16 bytes for SSE
self.tls_size.next_multiple_of(16),
)
.map_err(|err| {
if debug {