authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-04-16 20:40:55+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-04-20 23:36:41+02:00
logb5a781d19d3de1a50cbefe0df6f42a6ac8a05299
tree524d95190b9417131b8a8132ce03e92f725d12db
parent65492b3d5276d7a57f696fdc4da4d47f36909715

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


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

src/link/Elf.zig+3-2
...@@ -5104,8 +5104,9 @@ pub fn sectionSymbolOutputSymtabIndex(self: Elf, shndx: u32) u32 {...@@ -5104,8 +5104,9 @@ pub fn sectionSymbolOutputSymtabIndex(self: Elf, shndx: u32) u32 {
5104 if (self.eh_frame_section_index) |index| {5104 if (self.eh_frame_section_index) |index| {
5105 if (index == shndx) return @intCast(self.output_sections.keys().len + 1);5105 if (index == shndx) return @intCast(self.output_sections.keys().len + 1);
5106 }5106 }
5107 for (self.merge_sections.items, 1..) |msec, index| {5107 const base: usize = if (self.eh_frame_section_index == null) 0 else 1;
5108 if (msec.output_section_index == shndx) return @intCast(self.output_sections.keys().len + 1 + index);5108 for (self.merge_sections.items, 0..) |msec, index| {
5109 if (msec.output_section_index == shndx) return @intCast(self.output_sections.keys().len + 1 + index + base);
5109 }5110 }
5110 return @intCast(self.output_sections.getIndex(shndx).? + 1);5111 return @intCast(self.output_sections.getIndex(shndx).? + 1);
5111}5112}