codegen+elf: check if extern is a variable ref

This commit is contained in:
Jakub Konka
2023-10-15 15:38:16 +02:00
parent 45197ea7ad
commit 7b2cbcf0fe
3 changed files with 5 additions and 5 deletions

View File

@@ -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);