| ... | ... | @@ -1346,6 +1346,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod |
| 1346 | 1346 | } |
| 1347 | 1347 | } |
| 1348 | 1348 | try self.writeBaseRelocations(); |
| 1349 | try self.writeImportTable(); |
| 1349 | 1350 | |
| 1350 | 1351 | if (self.getEntryPoint()) |entry_sym_loc| { |
| 1351 | 1352 | self.entry_addr = self.getSymbol(entry_sym_loc).value; |
| ... | ... | @@ -1484,6 +1485,22 @@ fn writeBaseRelocations(self: *Coff) !void { |
| 1484 | 1485 | }; |
| 1485 | 1486 | } |
| 1486 | 1487 | |
| 1488 | fn writeImportTable(self: *Coff) !void { |
| 1489 | const gpa = self.base.allocator; |
| 1490 | _ = gpa; |
| 1491 | |
| 1492 | const section = self.sections.get(self.idata_section_index.?); |
| 1493 | const iat_rva = section.header.virtual_address; |
| 1494 | const iat_size = blk: { |
| 1495 | const last_atom = section.last_atom.?; |
| 1496 | break :blk last_atom.getSymbol(self).value + last_atom.size - iat_rva; |
| 1497 | }; |
| 1498 | self.data_directories[@enumToInt(coff.DirectoryEntry.IAT)] = .{ |
| 1499 | .virtual_address = iat_rva, |
| 1500 | .size = iat_size, |
| 1501 | }; |
| 1502 | } |
| 1503 | |
| 1487 | 1504 | fn writeStrtab(self: *Coff) !void { |
| 1488 | 1505 | const allocated_size = self.allocatedSize(self.strtab_offset.?); |
| 1489 | 1506 | const needed_size = @intCast(u32, self.strtab.len()); |