authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-15 15:38:16+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-16 19:33:06+02:00
log7b2cbcf0fe6dcaea7ee108c13422f6d00ed4bc8e
tree1926dba17efdbd327ac737551b68f8e649c5f06d
parent45197ea7adfa34806b549263c06b988b5e35d48c

codegen+elf: check if extern is a variable ref


3 files changed, 5 insertions(+), 5 deletions(-)

src/codegen.zig+5-2
......@@ -892,9 +892,12 @@ fn genDeclRef(
892892
893893 if (bin_file.cast(link.File.Elf)) |elf_file| {
894894 if (is_extern) {
895 const variable = decl.getOwnedVariable(mod).?;
896895 const name = mod.intern_pool.stringToSlice(decl.name);
897 const lib_name = mod.intern_pool.stringToSliceUnwrap(variable.lib_name);
896 // TODO audit this
897 const lib_name = if (decl.getOwnedVariable(mod)) |ov|
898 mod.intern_pool.stringToSliceUnwrap(ov.lib_name)
899 else
900 null;
898901 return GenResult.mcv(.{ .load_actual_got = try elf_file.getGlobalSymbol(name, lib_name) });
899902 }
900903 const sym_index = try elf_file.getOrCreateMetadataForDecl(decl_index);
src/link/Elf.zig-1
......@@ -4597,7 +4597,6 @@ fn allocateAllocSections(self: *Elf) error{OutOfMemory}!void {
45974597 for (slice, 0..) |*shdr, ii| {
45984598 if (shdr.sh_type == elf.SHT_NOBITS) continue;
45994599 off = alignment.@"align"(cover.start + ii, shdr.sh_addralign, off);
4600 // off = mem.alignForward(u64, off, shdr.sh_addralign);
46014600 shdr.sh_offset = off;
46024601 off += shdr.sh_size;
46034602 try self.phdr_to_shdr_table.putNoClobber(gpa, @intCast(ii + cover.start), phndx);
src/link/Elf/Object.zig-2
......@@ -214,8 +214,6 @@ fn initOutputSection(self: Object, elf_file: *Elf, shdr: ElfShdr) error{OutOfMem
214214 break :blk prefix;
215215 }
216216 }
217 if (std.mem.eql(u8, name, ".tcommon")) break :blk ".tbss";
218 if (std.mem.eql(u8, name, ".common")) break :blk ".bss";
219217 break :blk name;
220218 };
221219 const @"type" = switch (shdr.sh_type) {