| ... | @@ -4685,11 +4685,13 @@ fn allocateSpecialPhdrs(self: *Elf) void { | ... | @@ -4685,11 +4685,13 @@ fn allocateSpecialPhdrs(self: *Elf) void { |
| 4685 | } | 4685 | } |
| 4686 | | 4686 | |
| 4687 | // Allocate TLS phdr | 4687 | // 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 { |
| 4704 | | 4706 | |
| 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 | } |