diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-03-12 00:07:07 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-03-12 13:16:11 +0100 |
| commit | faa4bdb0175ee142834be320326063ae99dac1e4 (patch) | |
| tree | e81281d52055a3671aab168d31dc4d46bc7c2cf1 /src/link/Elf | |
| parent | b1bd3825f84edc7a8f1195b0c842fbbf8346c1cb (diff) | |
| download | zig-faa4bdb0175ee142834be320326063ae99dac1e4.tar.gz zig-faa4bdb0175ee142834be320326063ae99dac1e4.zip | |
elf+aarch64: fix off-by-one in converging on groups interleaved with thunks
Diffstat (limited to 'src/link/Elf')
| -rw-r--r-- | src/link/Elf/thunks.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/link/Elf/thunks.zig b/src/link/Elf/thunks.zig index 586cbed236..119529b512 100644 --- a/src/link/Elf/thunks.zig +++ b/src/link/Elf/thunks.zig @@ -1,6 +1,7 @@ pub fn createThunks(shndx: u32, elf_file: *Elf) !void { const gpa = elf_file.base.comp.gpa; const cpu_arch = elf_file.getTarget().cpu.arch; + const max_distance = maxAllowedDistance(cpu_arch); const shdr = &elf_file.shdrs.items[shndx]; const atoms = elf_file.output_sections.get(shndx).?.items; assert(atoms.len > 0); @@ -17,12 +18,11 @@ pub fn createThunks(shndx: u32, elf_file: *Elf) !void { start_atom.value = try advance(shdr, start_atom.size, start_atom.alignment); i += 1; - while (i < atoms.len and - shdr.sh_size - start_atom.value < maxAllowedDistance(cpu_arch)) : (i += 1) - { + while (i < atoms.len) : (i += 1) { const atom_index = atoms[i]; const atom = elf_file.atom(atom_index).?; assert(atom.flags.alive); + if (atom.alignment.forward(shdr.sh_size) - start_atom.value >= max_distance) break; atom.value = try advance(shdr, atom.size, atom.alignment); } |
