coff: treat vmaddr of 0 as unallocated when checking if resolvable

This commit is contained in:
Jakub Konka 2023-04-20 14:42:37 +02:00
parent bee35fe3f0
commit dd300d92e1
2 changed files with 3 additions and 2 deletions

View File

@ -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);

View File

@ -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;
}