mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
macho: fix calculating file offset for atom when allocating
This commit is contained in:
parent
17066cc12e
commit
9dbad2d188
@ -1929,7 +1929,19 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64
|
||||
|
||||
const expand_section = atom_placement == null or atom_placement.?.next == null;
|
||||
if (expand_section) {
|
||||
const max_size = seg.allocatedSize(vaddr - pagezero_vmsize);
|
||||
const sect_offset: u64 = blk: {
|
||||
if (self.data_segment_cmd_index.? == match.seg) {
|
||||
if (self.bss_section_index) |idx| {
|
||||
if (idx == match.sect) break :blk self.bss_file_offset.?;
|
||||
}
|
||||
if (self.tlv_bss_section_index) |idx| {
|
||||
if (idx == match.sect) break :blk self.tlv_bss_file_offset.?;
|
||||
}
|
||||
}
|
||||
break :blk sect.offset;
|
||||
};
|
||||
const file_offset = sect_offset + vaddr - sect.addr;
|
||||
const max_size = seg.allocatedSize(file_offset);
|
||||
log.debug(" (atom size 0x{x}, max available size 0x{x})", .{ atom.size, max_size });
|
||||
assert(atom.size <= max_size); // TODO must expand the section
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user