| ... | ... | @@ -2153,8 +2153,13 @@ fn allocateTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64, |
| 2153 | 2153 | // Is it enough that we could fit this new text block? |
| 2154 | 2154 | const sym = self.local_symbols.items[big_block.local_sym_index]; |
| 2155 | 2155 | const capacity = big_block.capacity(self.*); |
| 2156 | | const ideal_capacity = capacity * alloc_num / alloc_den; |
| 2157 | | const ideal_capacity_end_vaddr = sym.n_value + ideal_capacity; |
| 2156 | const ideal_capacity_end_vaddr: u64 = ideal_cap: { |
| 2157 | if (math.mul(u64, @divTrunc(capacity, alloc_den), alloc_num)) |cap| { |
| 2158 | break :ideal_cap math.add(u64, sym.n_value, cap) catch math.maxInt(u64); |
| 2159 | } else |_| { |
| 2160 | break :ideal_cap math.maxInt(u64); |
| 2161 | } |
| 2162 | }; |
| 2158 | 2163 | const capacity_end_vaddr = sym.n_value + capacity; |
| 2159 | 2164 | const new_start_vaddr_unaligned = capacity_end_vaddr - new_block_ideal_capacity; |
| 2160 | 2165 | const new_start_vaddr = mem.alignBackwardGeneric(u64, new_start_vaddr_unaligned, alignment); |