| ... | @@ -504,8 +504,11 @@ fn loadOFile(gpa: Allocator, io: Io, o_file_name: []const u8) !OFile { | ... | @@ -504,8 +504,11 @@ fn loadOFile(gpa: Allocator, io: Io, o_file_name: []const u8) !OFile { |
| 504 | | 504 | |
| 505 | if (!std.mem.eql(u8, "__DWARF", sect.segName())) continue; | 505 | if (!std.mem.eql(u8, "__DWARF", sect.segName())) continue; |
| 506 | | 506 | |
| 507 | const section_index: usize = inline for (@typeInfo(Dwarf.Section.Id).@"enum".field_names, 0..) |section_name, i| { | 507 | const section_index: usize = inline for (@typeInfo(Dwarf.Section.Id).@"enum".field_names, 0..) |field_name, i| { |
| 508 | if (mem.eql(u8, "__" ++ section_name, sect.sectName())) break i; | 508 | const section_name_long = "__" ++ field_name; |
| | 509 | // Some dwarf section names don't fit in the `sectname` buffer, so they are truncated. |
| | 510 | const section_name_trunc = section_name_long[0..@min(section_name_long.len, sect.sectname.len)]; |
| | 511 | if (mem.eql(u8, section_name_trunc, sect.sectName())) break i; |
| 509 | } else continue; | 512 | } else continue; |
| 510 | | 513 | |
| 511 | if (mapped_ofile.len < sect.offset + sect.size) return error.InvalidMachO; | 514 | if (mapped_ofile.len < sect.offset + sect.size) return error.InvalidMachO; |