| ... | @@ -64,6 +64,8 @@ globals_free_list: std.ArrayListUnmanaged(u32) = .{}, | ... | @@ -64,6 +64,8 @@ globals_free_list: std.ArrayListUnmanaged(u32) = .{}, |
| 64 | strtab: StringTable(.strtab) = .{}, | 64 | strtab: StringTable(.strtab) = .{}, |
| 65 | strtab_offset: ?u32 = null, | 65 | strtab_offset: ?u32 = null, |
| 66 | | 66 | |
| | 67 | temp_strtab: StringTable(.temp_strtab) = .{}, |
| | 68 | |
| 67 | got_entries: std.ArrayListUnmanaged(Entry) = .{}, | 69 | got_entries: std.ArrayListUnmanaged(Entry) = .{}, |
| 68 | got_entries_free_list: std.ArrayListUnmanaged(u32) = .{}, | 70 | got_entries_free_list: std.ArrayListUnmanaged(u32) = .{}, |
| 69 | got_entries_table: std.AutoHashMapUnmanaged(SymbolWithLoc, u32) = .{}, | 71 | got_entries_table: std.AutoHashMapUnmanaged(SymbolWithLoc, u32) = .{}, |
| ... | @@ -309,6 +311,7 @@ pub fn deinit(self: *Coff) void { | ... | @@ -309,6 +311,7 @@ pub fn deinit(self: *Coff) void { |
| 309 | self.locals_free_list.deinit(gpa); | 311 | self.locals_free_list.deinit(gpa); |
| 310 | self.globals_free_list.deinit(gpa); | 312 | self.globals_free_list.deinit(gpa); |
| 311 | self.strtab.deinit(gpa); | 313 | self.strtab.deinit(gpa); |
| | 314 | self.temp_strtab.deinit(gpa); |
| 312 | self.got_entries.deinit(gpa); | 315 | self.got_entries.deinit(gpa); |
| 313 | self.got_entries_free_list.deinit(gpa); | 316 | self.got_entries_free_list.deinit(gpa); |
| 314 | self.got_entries_table.deinit(gpa); | 317 | self.got_entries_table.deinit(gpa); |
| ... | @@ -358,6 +361,8 @@ fn populateMissingMetadata(self: *Coff) !void { | ... | @@ -358,6 +361,8 @@ fn populateMissingMetadata(self: *Coff) !void { |
| 358 | try self.strtab.buffer.ensureUnusedCapacity(gpa, @sizeOf(u32)); | 361 | try self.strtab.buffer.ensureUnusedCapacity(gpa, @sizeOf(u32)); |
| 359 | self.strtab.buffer.appendNTimesAssumeCapacity(0, @sizeOf(u32)); | 362 | self.strtab.buffer.appendNTimesAssumeCapacity(0, @sizeOf(u32)); |
| 360 | | 363 | |
| | 364 | try self.temp_strtab.buffer.append(gpa, 0); |
| | 365 | |
| 361 | // Index 0 is always a null symbol. | 366 | // Index 0 is always a null symbol. |
| 362 | try self.locals.append(gpa, .{ | 367 | try self.locals.append(gpa, .{ |
| 363 | .name = [_]u8{0} ** 8, | 368 | .name = [_]u8{0} ** 8, |
| ... | @@ -1526,8 +1531,7 @@ pub fn getDeclVAddr(self: *Coff, decl_index: Module.Decl.Index, reloc_info: link | ... | @@ -1526,8 +1531,7 @@ pub fn getDeclVAddr(self: *Coff, decl_index: Module.Decl.Index, reloc_info: link |
| 1526 | return 0; | 1531 | return 0; |
| 1527 | } | 1532 | } |
| 1528 | | 1533 | |
| 1529 | pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name: ?[]const u8) !u32 { | 1534 | pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name_name: ?[]const u8) !u32 { |
| 1530 | _ = lib_name; | | |
| 1531 | const gop = try self.getOrPutGlobalPtr(name); | 1535 | const gop = try self.getOrPutGlobalPtr(name); |
| 1532 | const global_index = self.getGlobalIndex(name).?; | 1536 | const global_index = self.getGlobalIndex(name).?; |
| 1533 | | 1537 | |
| ... | @@ -1544,6 +1548,12 @@ pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name: ?[]const u8) !u3 | ... | @@ -1544,6 +1548,12 @@ pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name: ?[]const u8) !u3 |
| 1544 | try self.setSymbolName(sym, name); | 1548 | try self.setSymbolName(sym, name); |
| 1545 | sym.storage_class = .EXTERNAL; | 1549 | sym.storage_class = .EXTERNAL; |
| 1546 | | 1550 | |
| | 1551 | if (lib_name_name) |lib_name| { |
| | 1552 | // We repurpose the 'value' of the Symbol struct to store an offset into |
| | 1553 | // temporary string table where we will store the library name hint. |
| | 1554 | sym.value = try self.temp_strtab.insert(gpa, lib_name); |
| | 1555 | } |
| | 1556 | |
| 1547 | try self.unresolved.putNoClobber(gpa, global_index, true); | 1557 | try self.unresolved.putNoClobber(gpa, global_index, true); |
| 1548 | | 1558 | |
| 1549 | return global_index; | 1559 | return global_index; |