zld: dealloc TextBlock if omitted

This commit is contained in:
Jakub Konka 2021-07-07 12:10:19 +02:00
parent 555b66c255
commit dfa69e3c30
2 changed files with 5 additions and 3 deletions

View File

@ -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;
}
}

View File

@ -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 {