Skip to content

Commit 3f10217

Browse files
committed
elf: fix a typo in setting atom name before it's been allocated
1 parent e0c475b commit 3f10217

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/link/Elf/ZigObject.zig

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -912,12 +912,13 @@ fn updateDeclCode(
912912
const sym = elf_file.symbol(sym_index);
913913
const esym = &self.local_esyms.items(.elf_sym)[sym.esym_index];
914914
const atom_ptr = sym.atom(elf_file).?;
915+
const name_offset = try self.strtab.insert(gpa, decl.fqn.toSlice(ip));
915916

916917
atom_ptr.alive = true;
917-
atom_ptr.name_offset = sym.name_offset;
918+
atom_ptr.name_offset = name_offset;
918919
atom_ptr.output_section_index = shdr_index;
919-
sym.name_offset = try self.strtab.insert(gpa, decl.fqn.toSlice(ip));
920-
esym.st_name = sym.name_offset;
920+
sym.name_offset = name_offset;
921+
esym.st_name = name_offset;
921922
esym.st_info |= stt_bits;
922923
esym.st_size = code.len;
923924

@@ -1009,15 +1010,17 @@ fn updateTlv(
10091010
const sym = elf_file.symbol(sym_index);
10101011
const esym = &self.local_esyms.items(.elf_sym)[sym.esym_index];
10111012
const atom_ptr = sym.atom(elf_file).?;
1013+
const name_offset = try self.strtab.insert(gpa, decl.fqn.toSlice(ip));
10121014

10131015
sym.value = 0;
1014-
atom_ptr.output_section_index = shndx;
1016+
sym.name_offset = name_offset;
10151017

1016-
sym.name_offset = try self.strtab.insert(gpa, decl.fqn.toSlice(ip));
1018+
atom_ptr.output_section_index = shndx;
10171019
atom_ptr.alive = true;
1018-
atom_ptr.name_offset = sym.name_offset;
1020+
atom_ptr.name_offset = name_offset;
1021+
10191022
esym.st_value = 0;
1020-
esym.st_name = sym.name_offset;
1023+
esym.st_name = name_offset;
10211024
esym.st_info = elf.STT_TLS;
10221025
esym.st_size = code.len;
10231026

0 commit comments

Comments
 (0)