authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-11 13:27:36+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-16 19:33:05+02:00
log2aa6099ad9dc5c45994101c94888deeab4ec2a06
tree2fcb83181aeeb57c35019ef847d132b723255fe2
parent8be71906d914563ea3e3e154ab948b4d78a1dcd3

elf: assume only one TLS segment for now


1 files changed, 5 insertions(+), 2 deletions(-)

src/link/Elf.zig+5-2
...@@ -4685,11 +4685,13 @@ fn allocateSpecialPhdrs(self: *Elf) void {...@@ -4685,11 +4685,13 @@ fn allocateSpecialPhdrs(self: *Elf) void {
4685 }4685 }
46864686
4687 // Allocate TLS phdr4687 // Allocate TLS phdr
4688 // We assume TLS sections are laid out contiguously and that there is
4689 // a single TLS segment.
4688 if (self.phdr_tls_index) |index| {4690 if (self.phdr_tls_index) |index| {
4689 const slice = self.shdrs.items;4691 const slice = self.shdrs.items;
4690 const phdr = &self.phdrs.items[index];4692 const phdr = &self.phdrs.items[index];
4691 var shndx: u16 = 0;4693 var shndx: u16 = 0;
4692 outer: while (shndx < slice.len) {4694 while (shndx < slice.len) {
4693 const shdr = slice[shndx];4695 const shdr = slice[shndx];
4694 if (shdr.sh_flags & elf.SHF_TLS == 0) {4696 if (shdr.sh_flags & elf.SHF_TLS == 0) {
4695 shndx += 1;4697 shndx += 1;
...@@ -4704,7 +4706,8 @@ fn allocateSpecialPhdrs(self: *Elf) void {...@@ -4704,7 +4706,8 @@ fn allocateSpecialPhdrs(self: *Elf) void {
47044706
4705 while (shndx < slice.len) : (shndx += 1) {4707 while (shndx < slice.len) : (shndx += 1) {
4706 const next = slice[shndx];4708 const next = slice[shndx];
4707 if (next.sh_flags & elf.SHF_TLS == 0) continue :outer;4709 // if (next.sh_flags & elf.SHF_TLS == 0) continue :outer; // TODO uncomment if we permit more TLS segments
4710 if (next.sh_flags & elf.SHF_TLS == 0) break;
4708 self.addShdrToPhdr(shndx, index);4711 self.addShdrToPhdr(shndx, index);
4709 }4712 }
4710 }4713 }