diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-04-19 16:38:44 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-04-21 22:44:27 +0200 |
| commit | fa40267b04e29fa8e36e73cb54eb68d58d26fa8d (patch) | |
| tree | c6f77455c305e37e13d66eda48da736c93b4c9d6 /src/link/MachO/thunks.zig | |
| parent | c55e821df6d6adca449720e052f40463eef8174b (diff) | |
| download | zig-fa40267b04e29fa8e36e73cb54eb68d58d26fa8d.tar.gz zig-fa40267b04e29fa8e36e73cb54eb68d58d26fa8d.zip | |
macho: do not allocate atoms for stub entries
Diffstat (limited to 'src/link/MachO/thunks.zig')
| -rw-r--r-- | src/link/MachO/thunks.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/link/MachO/thunks.zig b/src/link/MachO/thunks.zig index afea08750c..48d1faac6b 100644 --- a/src/link/MachO/thunks.zig +++ b/src/link/MachO/thunks.zig @@ -17,6 +17,7 @@ const aarch64 = @import("../../arch/aarch64/bits.zig"); const Allocator = mem.Allocator; const Atom = @import("ZldAtom.zig"); const AtomIndex = @import("zld.zig").AtomIndex; +const Relocation = @import("Relocation.zig"); const SymbolWithLoc = @import("zld.zig").SymbolWithLoc; const Zld = @import("zld.zig").Zld; @@ -317,7 +318,7 @@ fn isReachable( const source_addr = source_sym.n_value + @intCast(u32, rel.r_address - base_offset); const is_via_got = Atom.relocRequiresGot(zld, rel); const target_addr = Atom.getRelocTargetAddress(zld, target, is_via_got, false) catch unreachable; - _ = Atom.calcPcRelativeDisplacementArm64(source_addr, target_addr) catch + _ = Relocation.calcPcRelativeDisplacementArm64(source_addr, target_addr) catch return false; return true; @@ -364,9 +365,9 @@ pub fn writeThunkCode(zld: *Zld, atom_index: AtomIndex, writer: anytype) !void { if (atom_index == target_atom_index) break zld.getSymbol(target).n_value; } else unreachable; - const pages = Atom.calcNumberOfPages(source_addr, target_addr); + const pages = Relocation.calcNumberOfPages(source_addr, target_addr); try writer.writeIntLittle(u32, aarch64.Instruction.adrp(.x16, pages).toU32()); - const off = try Atom.calcPageOffset(target_addr, .arithmetic); + const off = try Relocation.calcPageOffset(target_addr, .arithmetic); try writer.writeIntLittle(u32, aarch64.Instruction.add(.x16, .x16, off, false).toU32()); try writer.writeIntLittle(u32, aarch64.Instruction.br(.x16).toU32()); } |
