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...@@ -1346,6 +1346,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
1346 }1346 }
1347 }1347 }
1348 try self.writeBaseRelocations();1348 try self.writeBaseRelocations();
1349 try self.writeImportTable();
13491350
1350 if (self.getEntryPoint()) |entry_sym_loc| {1351 if (self.getEntryPoint()) |entry_sym_loc| {
1351 self.entry_addr = self.getSymbol(entry_sym_loc).value;1352 self.entry_addr = self.getSymbol(entry_sym_loc).value;
...@@ -1484,6 +1485,22 @@ fn writeBaseRelocations(self: *Coff) !void {...@@ -1484,6 +1485,22 @@ fn writeBaseRelocations(self: *Coff) !void {
1484 };1485 };
1485}1486}
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
1487fn writeStrtab(self: *Coff) !void {1504fn writeStrtab(self: *Coff) !void {
1488 const allocated_size = self.allocatedSize(self.strtab_offset.?);1505 const allocated_size = self.allocatedSize(self.strtab_offset.?);
1489 const needed_size = @intCast(u32, self.strtab.len());1506 const needed_size = @intCast(u32, self.strtab.len());