aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-08-31 21:49:51 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-09-07 22:42:55 +0200
commit0ebeb58d91b23acbd2ad3a168af19459af63a8f6 (patch)
tree674c15724d120db9575addc242f7690e14c6d069 /src/link
parent1ab149c5fc474e73cb52872e11cbd2b916961ede (diff)
downloadzig-0ebeb58d91b23acbd2ad3a168af19459af63a8f6.tar.gz
zig-0ebeb58d91b23acbd2ad3a168af19459af63a8f6.zip
coff: populate import address table dir
Diffstat (limited to 'src/link')
-rw-r--r--src/link/Coff.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index a690c7cf63..b57307c862 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -1346,6 +1346,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
}
}
try self.writeBaseRelocations();
+ try self.writeImportTable();
if (self.getEntryPoint()) |entry_sym_loc| {
self.entry_addr = self.getSymbol(entry_sym_loc).value;
@@ -1484,6 +1485,22 @@ fn writeBaseRelocations(self: *Coff) !void {
};
}
+fn writeImportTable(self: *Coff) !void {
+ const gpa = self.base.allocator;
+ _ = gpa;
+
+ const section = self.sections.get(self.idata_section_index.?);
+ const iat_rva = section.header.virtual_address;
+ const iat_size = blk: {
+ const last_atom = section.last_atom.?;
+ break :blk last_atom.getSymbol(self).value + last_atom.size - iat_rva;
+ };
+ self.data_directories[@enumToInt(coff.DirectoryEntry.IAT)] = .{
+ .virtual_address = iat_rva,
+ .size = iat_size,
+ };
+}
+
fn writeStrtab(self: *Coff) !void {
const allocated_size = self.allocatedSize(self.strtab_offset.?);
const needed_size = @intCast(u32, self.strtab.len());