commit dfa69e3c308fe7a5cb8b78c494312e1d280afa18 (tree)
parent 555b66c25567ab23402e3792bdbe81b7a4e98803
Author: Jakub Konka <kubkon@jakubkonka.com>
Date: Wed, 7 Jul 2021 12:10:19 +0200
zld: dealloc TextBlock if omitted
Diffstat:
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig
@@ -512,10 +512,10 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
const relocs = mem.bytesAsSlice(macho.relocation_info, raw_relocs);
// Is there any padding between symbols within the section?
- const is_padded = self.header.?.flags & macho.MH_SUBSECTIONS_VIA_SYMBOLS != 0;
+ const is_splittable = self.header.?.flags & macho.MH_SUBSECTIONS_VIA_SYMBOLS != 0;
next: {
- if (is_padded) blocks: {
+ if (is_splittable) blocks: {
const filtered_nlists = NlistWithIndex.filterInSection(
sorted_nlists.items,
sect_id + 1,
@@ -540,6 +540,8 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
if (reg.file) |file| {
if (file != self) {
log.warn("deduping definition of {s} in {s}", .{ sym.name, self.name.? });
+ block.deinit(self.allocator);
+ self.allocator.destroy(block);
continue;
}
}
diff --git a/src/link/MachO/Zld.zig b/src/link/MachO/Zld.zig
@@ -147,7 +147,7 @@ pub const TextBlock = struct {
}
block.relocs.deinit();
block.references.deinit();
- allocator.free(code);
+ allocator.free(block.code);
}
pub fn print_this(self: *const TextBlock, zld: *Zld) void {