authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-22 18:54:00+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:42+01:00
logf2dce0c33794f363d1b7448ee110ca2ae4bbafac
tree26eb5778923d5dd9682d53fb574b8d6951b902e7
parent82628dd151c15241cffd17884ed5124808dc4ed2

macho: exclude symbols from empty sections when parsing unwind info


1 files changed, 3 insertions(+), 1 deletions(-)

src/link/MachO/Object.zig+3-1
...@@ -156,10 +156,12 @@ pub fn parse(self: *Object, macho_file: *MachO) !void {...@@ -156,10 +156,12 @@ pub fn parse(self: *Object, macho_file: *MachO) !void {
156 try self.initSymbolStabs(nlists.items, macho_file);156 try self.initSymbolStabs(nlists.items, macho_file);
157 try self.initRelocs(macho_file);157 try self.initRelocs(macho_file);
158158
159 // Parse DWARF __TEXT,__eh_frame section
159 if (self.eh_frame_sect_index) |index| {160 if (self.eh_frame_sect_index) |index| {
160 try self.initEhFrameRecords(index, macho_file);161 try self.initEhFrameRecords(index, macho_file);
161 }162 }
162163
164 // Parse Apple's __LD,__compact_unwind section
163 if (self.compact_unwind_sect_index) |index| {165 if (self.compact_unwind_sect_index) |index| {
164 try self.initUnwindRecords(index, macho_file);166 try self.initUnwindRecords(index, macho_file);
165 }167 }
...@@ -841,7 +843,7 @@ fn parseUnwindRecords(self: *Object, macho_file: *MachO) !void {...@@ -841,7 +843,7 @@ fn parseUnwindRecords(self: *Object, macho_file: *MachO) !void {
841 if (nlist.stab()) continue;843 if (nlist.stab()) continue;
842 if (!nlist.sect()) continue;844 if (!nlist.sect()) continue;
843 const sect = self.sections.items(.header)[nlist.n_sect - 1];845 const sect = self.sections.items(.header)[nlist.n_sect - 1];
844 if (sect.isCode()) {846 if (sect.isCode() and sect.size > 0) {
845 try superposition.ensureUnusedCapacity(1);847 try superposition.ensureUnusedCapacity(1);
846 const gop = superposition.getOrPutAssumeCapacity(nlist.n_value);848 const gop = superposition.getOrPutAssumeCapacity(nlist.n_value);
847 if (gop.found_existing) {849 if (gop.found_existing) {