authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-07-07 12:10:19+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-07-15 18:49:47+02:00
logdfa69e3c308fe7a5cb8b78c494312e1d280afa18
treed3ef395d68341ae0d11529670f585e88b714f5bb
parent555b66c25567ab23402e3792bdbe81b7a4e98803

zld: dealloc TextBlock if omitted


2 files changed, 5 insertions(+), 3 deletions(-)

src/link/MachO/Object.zig+4-2
......@@ -512,10 +512,10 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
512512 const relocs = mem.bytesAsSlice(macho.relocation_info, raw_relocs);
513513
514514 // Is there any padding between symbols within the section?
515 const is_padded = self.header.?.flags & macho.MH_SUBSECTIONS_VIA_SYMBOLS != 0;
515 const is_splittable = self.header.?.flags & macho.MH_SUBSECTIONS_VIA_SYMBOLS != 0;
516516
517517 next: {
518 if (is_padded) blocks: {
518 if (is_splittable) blocks: {
519519 const filtered_nlists = NlistWithIndex.filterInSection(
520520 sorted_nlists.items,
521521 sect_id + 1,
......@@ -540,6 +540,8 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
540540 if (reg.file) |file| {
541541 if (file != self) {
542542 log.warn("deduping definition of {s} in {s}", .{ sym.name, self.name.? });
543 block.deinit(self.allocator);
544 self.allocator.destroy(block);
543545 continue;
544546 }
545547 }
src/link/MachO/Zld.zig+1-1
......@@ -147,7 +147,7 @@ pub const TextBlock = struct {
147147 }
148148 block.relocs.deinit();
149149 block.references.deinit();
150 allocator.free(code);
150 allocator.free(block.code);
151151 }
152152
153153 pub fn print_this(self: *const TextBlock, zld: *Zld) void {