diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-03-27 18:23:25 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-03-28 12:28:48 +0200 |
| commit | 0dc210f950ff926fb8e57288a8ff257abc942b6d (patch) | |
| tree | 6bcef8b17ff3c4210ece46c8bce99b17ae307b70 /src/link.zig | |
| parent | d2040b2763ad2684dcacce9acd8f8511bf9db397 (diff) | |
| download | zig-0dc210f950ff926fb8e57288a8ff257abc942b6d.tar.gz zig-0dc210f950ff926fb8e57288a8ff257abc942b6d.zip | |
link: pass expected lib name as hint in getGlobalSymbol()
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/link.zig b/src/link.zig index ae6c02c08b..a7c3ac51bc 100644 --- a/src/link.zig +++ b/src/link.zig @@ -504,18 +504,20 @@ pub const File = struct { /// Called from within CodeGen to retrieve the symbol index of a global symbol. /// If no symbol exists yet with this name, a new undefined global symbol will /// be created. This symbol may get resolved once all relocatables are (re-)linked. - pub fn getGlobalSymbol(base: *File, name: []const u8) UpdateDeclError!u32 { + /// Optionally, it is possible to specify where to expect the symbol defined if it + /// is an import. + pub fn getGlobalSymbol(base: *File, name: []const u8, lib_name: ?[]const u8) UpdateDeclError!u32 { if (build_options.only_c) @compileError("unreachable"); - log.debug("getGlobalSymbol '{s}'", .{name}); + log.debug("getGlobalSymbol '{s}' (expected in '{?s}')", .{ name, lib_name }); switch (base.tag) { // zig fmt: off - .coff => return @fieldParentPtr(Coff, "base", base).getGlobalSymbol(name), + .coff => return @fieldParentPtr(Coff, "base", base).getGlobalSymbol(name, lib_name), .elf => unreachable, - .macho => return @fieldParentPtr(MachO, "base", base).getGlobalSymbol(name), + .macho => return @fieldParentPtr(MachO, "base", base).getGlobalSymbol(name, lib_name), .plan9 => unreachable, .spirv => unreachable, .c => unreachable, - .wasm => return @fieldParentPtr(Wasm, "base", base).getGlobalSymbol(name), + .wasm => return @fieldParentPtr(Wasm, "base", base).getGlobalSymbol(name, lib_name), .nvptx => unreachable, // zig fmt: on } |
