| ... | ... | @@ -68,7 +68,8 @@ pub const Cie = struct { |
| 68 | 68 | |
| 69 | 69 | pub fn getPersonality(cie: Cie, macho_file: *MachO) ?*Symbol { |
| 70 | 70 | const personality = cie.personality orelse return null; |
| 71 | | return macho_file.getSymbol(personality.index); |
| 71 | const object = cie.getObject(macho_file); |
| 72 | return object.getSymbolRef(personality.index, macho_file).getSymbol(macho_file); |
| 72 | 73 | } |
| 73 | 74 | |
| 74 | 75 | pub fn eql(cie: Cie, other: Cie, macho_file: *MachO) bool { |
| ... | ... | @@ -223,11 +224,11 @@ pub const Fde = struct { |
| 223 | 224 | } |
| 224 | 225 | |
| 225 | 226 | pub fn getAtom(fde: Fde, macho_file: *MachO) *Atom { |
| 226 | | return macho_file.getAtom(fde.atom).?; |
| 227 | return fde.getObject(macho_file).getAtom(fde.atom).?; |
| 227 | 228 | } |
| 228 | 229 | |
| 229 | 230 | pub fn getLsdaAtom(fde: Fde, macho_file: *MachO) ?*Atom { |
| 230 | | return macho_file.getAtom(fde.lsda); |
| 231 | return fde.getObject(macho_file).getAtom(fde.lsda); |
| 231 | 232 | } |
| 232 | 233 | |
| 233 | 234 | pub fn format( |
| ... | ... | @@ -448,7 +449,7 @@ pub fn write(macho_file: *MachO, buffer: []u8) void { |
| 448 | 449 | } |
| 449 | 450 | } |
| 450 | 451 | |
| 451 | | pub fn writeRelocs(macho_file: *MachO, code: []u8, relocs: *std.ArrayList(macho.relocation_info)) error{Overflow}!void { |
| 452 | pub fn writeRelocs(macho_file: *MachO, code: []u8, relocs: []macho.relocation_info) error{Overflow}!void { |
| 452 | 453 | const tracy = trace(@src()); |
| 453 | 454 | defer tracy.end(); |
| 454 | 455 | |
| ... | ... | @@ -459,6 +460,7 @@ pub fn writeRelocs(macho_file: *MachO, code: []u8, relocs: *std.ArrayList(macho. |
| 459 | 460 | else => 0, |
| 460 | 461 | }; |
| 461 | 462 | |
| 463 | var i: usize = 0; |
| 462 | 464 | for (macho_file.objects.items) |index| { |
| 463 | 465 | const object = macho_file.getFile(index).?.object; |
| 464 | 466 | for (object.cies.items) |cie| { |
| ... | ... | @@ -469,7 +471,7 @@ pub fn writeRelocs(macho_file: *MachO, code: []u8, relocs: *std.ArrayList(macho. |
| 469 | 471 | if (cie.getPersonality(macho_file)) |sym| { |
| 470 | 472 | const r_address = math.cast(i32, cie.out_offset + cie.personality.?.offset) orelse return error.Overflow; |
| 471 | 473 | const r_symbolnum = math.cast(u24, sym.getOutputSymtabIndex(macho_file).?) orelse return error.Overflow; |
| 472 | | relocs.appendAssumeCapacity(.{ |
| 474 | relocs[i] = .{ |
| 473 | 475 | .r_address = r_address, |
| 474 | 476 | .r_symbolnum = r_symbolnum, |
| 475 | 477 | .r_length = 2, |
| ... | ... | @@ -480,7 +482,8 @@ pub fn writeRelocs(macho_file: *MachO, code: []u8, relocs: *std.ArrayList(macho. |
| 480 | 482 | .x86_64 => @intFromEnum(macho.reloc_type_x86_64.X86_64_RELOC_GOT), |
| 481 | 483 | else => unreachable, |
| 482 | 484 | }, |
| 483 | | }); |
| 485 | }; |
| 486 | i += 1; |
| 484 | 487 | } |
| 485 | 488 | } |
| 486 | 489 | } |
| ... | ... | @@ -531,6 +534,8 @@ pub fn writeRelocs(macho_file: *MachO, code: []u8, relocs: *std.ArrayList(macho. |
| 531 | 534 | } |
| 532 | 535 | } |
| 533 | 536 | } |
| 537 | |
| 538 | assert(relocs.len == i); |
| 534 | 539 | } |
| 535 | 540 | |
| 536 | 541 | pub const EH_PE = struct { |