mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 08:33:15 +00:00
codegen+elf: check if extern is a variable ref
This commit is contained in:
parent
45197ea7ad
commit
7b2cbcf0fe
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user