zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit b5a781d19d3de1a50cbefe0df6f42a6ac8a05299 (tree)
parent 65492b3d5276d7a57f696fdc4da4d47f36909715
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Tue, 16 Apr 2024 20:40:55 +0200

link/elf: fix generating invalid section symbol index for merged sections

Diffstat:
Msrc/link/Elf.zig | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/link/Elf.zig b/src/link/Elf.zig @@ -5104,8 +5104,9 @@ pub fn sectionSymbolOutputSymtabIndex(self: Elf, shndx: u32) u32 { if (self.eh_frame_section_index) |index| { if (index == shndx) return @intCast(self.output_sections.keys().len + 1); } - for (self.merge_sections.items, 1..) |msec, index| { - if (msec.output_section_index == shndx) return @intCast(self.output_sections.keys().len + 1 + index); + const base: usize = if (self.eh_frame_section_index == null) 0 else 1; + for (self.merge_sections.items, 0..) |msec, index| { + if (msec.output_section_index == shndx) return @intCast(self.output_sections.keys().len + 1 + index + base); } return @intCast(self.output_sections.getIndex(shndx).? + 1); }