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

Fix allocation of TLS masters if main image does not require TLS

parent 4818ad61
No related branches found
No related tags found
No related merge requests found
Pipeline #6681 failed
...@@ -220,7 +220,12 @@ impl Linker { ...@@ -220,7 +220,12 @@ impl Linker {
// Copy data // Copy data
let mut tls_offset = tls_primary; let mut tls_offset = tls_primary;
let mut tcb_masters = Vec::new(); let mut tcb_masters = Vec::new();
let mut tls_index = 0; // Insert main image master
tcb_masters.push(Master {
ptr: ptr::null_mut(),
len: 0,
offset: 0,
});
let mut tls_ranges = BTreeMap::new(); let mut tls_ranges = BTreeMap::new();
for (elf_name, elf) in elfs.iter() { for (elf_name, elf) in elfs.iter() {
let object = match self.objects.get(*elf_name) { let object = match self.objects.get(*elf_name) {
...@@ -299,12 +304,11 @@ impl Linker { ...@@ -299,12 +304,11 @@ impl Linker {
if *elf_name == primary { if *elf_name == primary {
tls_ranges.insert(elf_name, (0, tcb_master.range())); tls_ranges.insert(elf_name, (0, tcb_master.range()));
tcb_masters.insert(0, tcb_master); tcb_masters[0] = tcb_master;
} else { } else {
tcb_master.offset -= tls_offset; tcb_master.offset -= tls_offset;
tls_offset += vsize; tls_offset += vsize;
tls_index += 1; tls_ranges.insert(elf_name, (tcb_masters.len(), tcb_master.range()));
tls_ranges.insert(elf_name, (tls_index, tcb_master.range()));
tcb_masters.push(tcb_master); tcb_masters.push(tcb_master);
} }
} }
......
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