zig

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

commit 7b2cbcf0fe6dcaea7ee108c13422f6d00ed4bc8e (tree)
parent 45197ea7adfa34806b549263c06b988b5e35d48c
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Sun, 15 Oct 2023 15:38:16 +0200

codegen+elf: check if extern is a variable ref

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

diff --git a/src/codegen.zig b/src/codegen.zig @@ -892,9 +892,12 @@ fn genDeclRef( if (bin_file.cast(link.File.Elf)) |elf_file| { if (is_extern) { - const variable = decl.getOwnedVariable(mod).?; const name = mod.intern_pool.stringToSlice(decl.name); - const lib_name = mod.intern_pool.stringToSliceUnwrap(variable.lib_name); + // TODO audit this + const lib_name = if (decl.getOwnedVariable(mod)) |ov| + mod.intern_pool.stringToSliceUnwrap(ov.lib_name) + else + null; return GenResult.mcv(.{ .load_actual_got = try elf_file.getGlobalSymbol(name, lib_name) }); } const sym_index = try elf_file.getOrCreateMetadataForDecl(decl_index); diff --git a/src/link/Elf.zig b/src/link/Elf.zig @@ -4597,7 +4597,6 @@ fn allocateAllocSections(self: *Elf) error{OutOfMemory}!void { for (slice, 0..) |*shdr, ii| { if (shdr.sh_type == elf.SHT_NOBITS) continue; off = alignment.@"align"(cover.start + ii, shdr.sh_addralign, off); - // off = mem.alignForward(u64, off, shdr.sh_addralign); shdr.sh_offset = off; off += shdr.sh_size; try self.phdr_to_shdr_table.putNoClobber(gpa, @intCast(ii + cover.start), phndx); diff --git a/src/link/Elf/Object.zig b/src/link/Elf/Object.zig @@ -214,8 +214,6 @@ fn initOutputSection(self: Object, elf_file: *Elf, shdr: ElfShdr) error{OutOfMem break :blk prefix; } } - if (std.mem.eql(u8, name, ".tcommon")) break :blk ".tbss"; - if (std.mem.eql(u8, name, ".common")) break :blk ".bss"; break :blk name; }; const @"type" = switch (shdr.sh_type) {