From 42e0850d78e63fcc602dd0e167ac90dfb3cfec02 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sun, 27 Aug 2023 07:31:29 +0200 Subject: macho: save indexes to all sections of interest --- src/link/MachO/Object.zig | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/link/MachO/Object.zig') diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig index 5042fe9849..3ab62ec191 100644 --- a/src/link/MachO/Object.zig +++ b/src/link/MachO/Object.zig @@ -687,8 +687,8 @@ fn parseEhFrameSection(self: *Object, zld: *Zld, object_id: u32) !void { const gpa = zld.gpa; - if (zld.getSectionByName("__TEXT", "__eh_frame") == null) { - _ = try MachO.initSection(gpa, zld, "__TEXT", "__eh_frame", .{}); + if (zld.eh_frame_section_index == null) { + zld.eh_frame_section_index = try MachO.initSection(gpa, zld, "__TEXT", "__eh_frame", .{}); } const cpu_arch = zld.options.target.cpu.arch; @@ -788,8 +788,14 @@ fn parseUnwindInfo(self: *Object, zld: *Zld, object_id: u32) !void { // approach. However, we will only synthesise DWARF records and nothing more. For this reason, // we still create the output `__TEXT,__unwind_info` section. if (self.hasEhFrameRecords()) { - if (zld.getSectionByName("__TEXT", "__unwind_info") == null) { - _ = try MachO.initSection(gpa, zld, "__TEXT", "__unwind_info", .{}); + if (zld.unwind_info_section_index == null) { + zld.unwind_info_section_index = try MachO.initSection( + gpa, + zld, + "__TEXT", + "__unwind_info", + .{}, + ); } } return; @@ -797,8 +803,8 @@ fn parseUnwindInfo(self: *Object, zld: *Zld, object_id: u32) !void { log.debug("parsing unwind info in {s}", .{self.name}); - if (zld.getSectionByName("__TEXT", "__unwind_info") == null) { - _ = try MachO.initSection(gpa, zld, "__TEXT", "__unwind_info", .{}); + if (zld.unwind_info_section_index == null) { + zld.unwind_info_section_index = try MachO.initSection(gpa, zld, "__TEXT", "__unwind_info", .{}); } const unwind_records = self.getUnwindRecords(); -- cgit v1.2.3