| ... | @@ -1603,6 +1603,17 @@ fn resolveSymbols(self: *Zld) !void { | ... | @@ -1603,6 +1603,17 @@ fn resolveSymbols(self: *Zld) !void { |
| 1603 | block.size = size; | 1603 | block.size = size; |
| 1604 | block.alignment = alignment; | 1604 | block.alignment = alignment; |
| 1605 | | 1605 | |
| | 1606 | // Update target section's metadata |
| | 1607 | // TODO should we update segment's size here too? |
| | 1608 | // How does it tie with incremental space allocs? |
| | 1609 | const tseg = &self.load_commands.items[match.seg].Segment; |
| | 1610 | const tsect = &tseg.sections.items[match.sect]; |
| | 1611 | const new_alignment = math.max(tsect.@"align", block.alignment); |
| | 1612 | const new_alignment_pow_2 = try math.powi(u32, 2, new_alignment); |
| | 1613 | const new_size = mem.alignForwardGeneric(u64, tsect.size + block.size, new_alignment_pow_2); |
| | 1614 | tsect.size = new_size; |
| | 1615 | tsect.@"align" = new_alignment; |
| | 1616 | |
| 1606 | if (self.blocks.getPtr(match)) |last| { | 1617 | if (self.blocks.getPtr(match)) |last| { |
| 1607 | last.*.next = block; | 1618 | last.*.next = block; |
| 1608 | block.prev = last.*; | 1619 | block.prev = last.*; |