| ... | ... | @@ -1678,7 +1678,11 @@ pub fn allocateAtom(self: *MachO, atom: *TextBlock, match: MatchingSection) !u64 |
| 1678 | 1678 | if (expand_section) { |
| 1679 | 1679 | const needed_size = @intCast(u32, (vaddr + atom.size) - sect.addr); |
| 1680 | 1680 | try self.growSection(match, needed_size); |
| 1681 | sect.size = needed_size; |
| 1682 | self.load_commands_dirty = true; |
| 1681 | 1683 | } |
| 1684 | sect.@"align" = math.max(sect.@"align", atom.alignment); |
| 1685 | |
| 1682 | 1686 | const n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1); |
| 1683 | 1687 | sym.n_value = vaddr; |
| 1684 | 1688 | sym.n_sect = n_sect; |
| ... | ... | @@ -3899,15 +3903,13 @@ fn growSection(self: *MachO, match: MatchingSection, new_size: u32) !void { |
| 3899 | 3903 | }, @intCast(i64, offset_amt)); |
| 3900 | 3904 | } |
| 3901 | 3905 | } |
| 3902 | | |
| 3903 | | sect.size = new_size; |
| 3904 | | self.load_commands_dirty = true; |
| 3905 | 3906 | } |
| 3906 | 3907 | |
| 3907 | 3908 | fn allocatedSize(self: MachO, segment_id: u16, start: u64) u64 { |
| 3908 | 3909 | const seg = self.load_commands.items[segment_id].Segment; |
| 3909 | 3910 | assert(start >= seg.inner.fileoff); |
| 3910 | 3911 | var min_pos: u64 = seg.inner.fileoff + seg.inner.filesize; |
| 3912 | if (start > min_pos) return 0; |
| 3911 | 3913 | for (seg.sections.items) |section| { |
| 3912 | 3914 | if (section.offset <= start) continue; |
| 3913 | 3915 | if (section.offset < min_pos) min_pos = section.offset; |
| ... | ... | @@ -4003,7 +4005,11 @@ fn allocateTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64, |
| 4003 | 4005 | const needed_size = @intCast(u32, (vaddr + new_block_size) - text_section.addr); |
| 4004 | 4006 | try self.growSection(match, needed_size); |
| 4005 | 4007 | _ = try self.blocks.put(self.base.allocator, match, text_block); |
| 4008 | text_section.size = needed_size; |
| 4009 | self.load_commands_dirty = true; |
| 4006 | 4010 | } |
| 4011 | const align_pow = @intCast(u32, math.log2(alignment)); |
| 4012 | text_section.@"align" = math.max(text_section.@"align", align_pow); |
| 4007 | 4013 | text_block.size = new_block_size; |
| 4008 | 4014 | |
| 4009 | 4015 | if (text_block.prev) |prev| { |