diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-03-27 20:45:32 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-03-28 12:28:49 +0200 |
| commit | 2a5c4ea8f08d212b10d4dc8748fbaf5beddecbb6 (patch) | |
| tree | fafe0f1d4c7e5cd9f8022921dc9b023e33ed79c5 /src/link | |
| parent | 0dc210f950ff926fb8e57288a8ff257abc942b6d (diff) | |
| download | zig-2a5c4ea8f08d212b10d4dc8748fbaf5beddecbb6.tar.gz zig-2a5c4ea8f08d212b10d4dc8748fbaf5beddecbb6.zip | |
coff: repurpose value field of import Symbol for lib_name offset
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Coff.zig | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 8d2a4ad16e..a87996001e 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -64,6 +64,8 @@ globals_free_list: std.ArrayListUnmanaged(u32) = .{}, strtab: StringTable(.strtab) = .{}, strtab_offset: ?u32 = null, +temp_strtab: StringTable(.temp_strtab) = .{}, + got_entries: std.ArrayListUnmanaged(Entry) = .{}, got_entries_free_list: std.ArrayListUnmanaged(u32) = .{}, got_entries_table: std.AutoHashMapUnmanaged(SymbolWithLoc, u32) = .{}, @@ -309,6 +311,7 @@ pub fn deinit(self: *Coff) void { self.locals_free_list.deinit(gpa); self.globals_free_list.deinit(gpa); self.strtab.deinit(gpa); + self.temp_strtab.deinit(gpa); self.got_entries.deinit(gpa); self.got_entries_free_list.deinit(gpa); self.got_entries_table.deinit(gpa); @@ -358,6 +361,8 @@ fn populateMissingMetadata(self: *Coff) !void { try self.strtab.buffer.ensureUnusedCapacity(gpa, @sizeOf(u32)); self.strtab.buffer.appendNTimesAssumeCapacity(0, @sizeOf(u32)); + try self.temp_strtab.buffer.append(gpa, 0); + // Index 0 is always a null symbol. try self.locals.append(gpa, .{ .name = [_]u8{0} ** 8, @@ -1526,8 +1531,7 @@ pub fn getDeclVAddr(self: *Coff, decl_index: Module.Decl.Index, reloc_info: link return 0; } -pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name: ?[]const u8) !u32 { - _ = lib_name; +pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name_name: ?[]const u8) !u32 { const gop = try self.getOrPutGlobalPtr(name); const global_index = self.getGlobalIndex(name).?; @@ -1544,6 +1548,12 @@ pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name: ?[]const u8) !u3 try self.setSymbolName(sym, name); sym.storage_class = .EXTERNAL; + if (lib_name_name) |lib_name| { + // We repurpose the 'value' of the Symbol struct to store an offset into + // temporary string table where we will store the library name hint. + sym.value = try self.temp_strtab.insert(gpa, lib_name); + } + try self.unresolved.putNoClobber(gpa, global_index, true); return global_index; |
