authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-08-31 21:49:51+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-09-07 22:42:55+02:00
log0ebeb58d91b23acbd2ad3a168af19459af63a8f6
tree674c15724d120db9575addc242f7690e14c6d069
parent1ab149c5fc474e73cb52872e11cbd2b916961ede

coff: populate import address table dir


1 files changed, 17 insertions(+), 0 deletions(-)

src/link/Coff.zig+17
......@@ -1346,6 +1346,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
13461346 }
13471347 }
13481348 try self.writeBaseRelocations();
1349 try self.writeImportTable();
13491350
13501351 if (self.getEntryPoint()) |entry_sym_loc| {
13511352 self.entry_addr = self.getSymbol(entry_sym_loc).value;
......@@ -1484,6 +1485,22 @@ fn writeBaseRelocations(self: *Coff) !void {
14841485 };
14851486}
14861487
1488fn 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
14871504fn writeStrtab(self: *Coff) !void {
14881505 const allocated_size = self.allocatedSize(self.strtab_offset.?);
14891506 const needed_size = @intCast(u32, self.strtab.len());