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 {...@@ -512,10 +512,10 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
512 const relocs = mem.bytesAsSlice(macho.relocation_info, raw_relocs);512 const relocs = mem.bytesAsSlice(macho.relocation_info, raw_relocs);
513513
514 // Is there any padding between symbols within the section?514 // 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
517 next: {517 next: {
518 if (is_padded) blocks: {518 if (is_splittable) blocks: {
519 const filtered_nlists = NlistWithIndex.filterInSection(519 const filtered_nlists = NlistWithIndex.filterInSection(
520 sorted_nlists.items,520 sorted_nlists.items,
521 sect_id + 1,521 sect_id + 1,
...@@ -540,6 +540,8 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {...@@ -540,6 +540,8 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
540 if (reg.file) |file| {540 if (reg.file) |file| {
541 if (file != self) {541 if (file != self) {
542 log.warn("deduping definition of {s} in {s}", .{ sym.name, self.name.? });542 log.warn("deduping definition of {s} in {s}", .{ sym.name, self.name.? });
543 block.deinit(self.allocator);
544 self.allocator.destroy(block);
543 continue;545 continue;
544 }546 }
545 }547 }
src/link/MachO/Zld.zig+1-1
...@@ -147,7 +147,7 @@ pub const TextBlock = struct {...@@ -147,7 +147,7 @@ pub const TextBlock = struct {
147 }147 }
148 block.relocs.deinit();148 block.relocs.deinit();
149 block.references.deinit();149 block.references.deinit();
150 allocator.free(code);150 allocator.free(block.code);
151 }151 }
152152
153 pub fn print_this(self: *const TextBlock, zld: *Zld) void {153 pub fn print_this(self: *const TextBlock, zld: *Zld) void {