From dd300d92e1c0812520ceffff4bc49529268efbff Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 20 Apr 2023 14:42:37 +0200 Subject: [PATCH] coff: treat vmaddr of 0 as unallocated when checking if resolvable --- src/link/Coff.zig | 2 +- src/link/Coff/Relocation.zig | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/link/Coff.zig b/src/link/Coff.zig index b6def9564e..50b98c2433 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -492,8 +492,8 @@ fn growSection(self: *Coff, sect_id: u32, needed_size: u32) !void { const sect_vm_capacity = self.allocatedVirtualSize(header.virtual_address); if (needed_size > sect_vm_capacity) { - try self.growSectionVirtualMemory(sect_id, needed_size); self.markRelocsDirtyByAddress(header.virtual_address + needed_size); + try self.growSectionVirtualMemory(sect_id, needed_size); } header.virtual_size = @max(header.virtual_size, needed_size); diff --git a/src/link/Coff/Relocation.zig b/src/link/Coff/Relocation.zig index 815f2cc7ee..4449691ac0 100644 --- a/src/link/Coff/Relocation.zig +++ b/src/link/Coff/Relocation.zig @@ -73,7 +73,8 @@ pub fn getTargetAddress(self: Relocation, coff_file: *const Coff) ?u32 { /// Returns true if and only if the reloc is dirty AND the target address is available. pub fn isResolvable(self: Relocation, coff_file: *Coff) bool { - _ = self.getTargetAddress(coff_file) orelse return false; + const addr = self.getTargetAddress(coff_file) orelse return false; + if (addr == 0) return false; return self.dirty; }