macho: exclude symbols from empty sections when parsing unwind info

This commit is contained in:
Jakub Konka 2024-01-22 18:54:00 +01:00
parent 82628dd151
commit f2dce0c337

View File

@ -156,10 +156,12 @@ pub fn parse(self: *Object, macho_file: *MachO) !void {
try self.initSymbolStabs(nlists.items, macho_file);
try self.initRelocs(macho_file);
// Parse DWARF __TEXT,__eh_frame section
if (self.eh_frame_sect_index) |index| {
try self.initEhFrameRecords(index, macho_file);
}
// Parse Apple's __LD,__compact_unwind section
if (self.compact_unwind_sect_index) |index| {
try self.initUnwindRecords(index, macho_file);
}
@ -841,7 +843,7 @@ fn parseUnwindRecords(self: *Object, macho_file: *MachO) !void {
if (nlist.stab()) continue;
if (!nlist.sect()) continue;
const sect = self.sections.items(.header)[nlist.n_sect - 1];
if (sect.isCode()) {
if (sect.isCode() and sect.size > 0) {
try superposition.ensureUnusedCapacity(1);
const gop = superposition.getOrPutAssumeCapacity(nlist.n_value);
if (gop.found_existing) {