| ... | @@ -588,6 +588,8 @@ fn resolveRelocInner( | ... | @@ -588,6 +588,8 @@ fn resolveRelocInner( |
| 588 | const G: i64 = @intCast(rel.getGotTargetAddress(macho_file)); | 588 | const G: i64 = @intCast(rel.getGotTargetAddress(macho_file)); |
| 589 | const TLS = @as(i64, @intCast(macho_file.getTlsAddress())); | 589 | const TLS = @as(i64, @intCast(macho_file.getTlsAddress())); |
| 590 | const SUB = if (subtractor) |sub| @as(i64, @intCast(sub.getTargetAddress(macho_file))) else 0; | 590 | const SUB = if (subtractor) |sub| @as(i64, @intCast(sub.getTargetAddress(macho_file))) else 0; |
| | 591 | // Address of the __got_zig table entry if any. |
| | 592 | const ZIG_GOT = @as(i64, @intCast(rel.getZigGotTargetAddress(macho_file))); |
| 591 | | 593 | |
| 592 | switch (rel.tag) { | 594 | switch (rel.tag) { |
| 593 | .local => relocs_log.debug(" {x}<+{d}>: {s}: [=> {x}] atom({d})", .{ | 595 | .local => relocs_log.debug(" {x}<+{d}>: {s}: [=> {x}] atom({d})", .{ |
| ... | @@ -597,12 +599,13 @@ fn resolveRelocInner( | ... | @@ -597,12 +599,13 @@ fn resolveRelocInner( |
| 597 | S + A - SUB, | 599 | S + A - SUB, |
| 598 | rel.getTargetAtom(macho_file).atom_index, | 600 | rel.getTargetAtom(macho_file).atom_index, |
| 599 | }), | 601 | }), |
| 600 | .@"extern" => relocs_log.debug(" {x}<+{d}>: {s}: [=> {x}] G({x}) ({s})", .{ | 602 | .@"extern" => relocs_log.debug(" {x}<+{d}>: {s}: [=> {x}] G({x}) ZG({x}) ({s})", .{ |
| 601 | P, | 603 | P, |
| 602 | rel_offset, | 604 | rel_offset, |
| 603 | @tagName(rel.type), | 605 | @tagName(rel.type), |
| 604 | S + A - SUB, | 606 | S + A - SUB, |
| 605 | G + A, | 607 | G + A, |
| | 608 | ZIG_GOT + A, |
| 606 | rel.getTargetSymbol(macho_file).getName(macho_file), | 609 | rel.getTargetSymbol(macho_file).getName(macho_file), |
| 607 | }), | 610 | }), |
| 608 | } | 611 | } |
| ... | @@ -696,7 +699,14 @@ fn resolveRelocInner( | ... | @@ -696,7 +699,14 @@ fn resolveRelocInner( |
| 696 | }, | 699 | }, |
| 697 | | 700 | |
| 698 | .zig_got_load => { | 701 | .zig_got_load => { |
| 699 | @panic("TODO resolve __got_zig indirection reloc"); | 702 | assert(rel.tag == .@"extern"); |
| | 703 | assert(rel.meta.length == 2); |
| | 704 | assert(rel.meta.pcrel); |
| | 705 | switch (cpu_arch) { |
| | 706 | .x86_64 => try writer.writeInt(i32, @intCast(ZIG_GOT + A - P), .little), |
| | 707 | .aarch64 => @panic("TODO resolve __got_zig indirection reloc"), |
| | 708 | else => unreachable, |
| | 709 | } |
| 700 | }, | 710 | }, |
| 701 | | 711 | |
| 702 | .tlv => { | 712 | .tlv => { |