aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/thunks.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-01-20 18:26:21 +0100
committerJakub Konka <kubkon@jakubkonka.com>2023-01-20 18:43:16 +0100
commit835a60a34fe2bc3d35e4524caee455a4743a5022 (patch)
tree41e1c40e393397096209ee670304d2e7a510ec19 /src/link/MachO/thunks.zig
parent74b72a766de96c7c70fc8a02d3e2ee3cd353f225 (diff)
downloadzig-835a60a34fe2bc3d35e4524caee455a4743a5022.tar.gz
zig-835a60a34fe2bc3d35e4524caee455a4743a5022.zip
zld: parse, synthesise and emit unwind records
Diffstat (limited to 'src/link/MachO/thunks.zig')
-rw-r--r--src/link/MachO/thunks.zig9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/link/MachO/thunks.zig b/src/link/MachO/thunks.zig
index db85884c31..f12fb80668 100644
--- a/src/link/MachO/thunks.zig
+++ b/src/link/MachO/thunks.zig
@@ -68,7 +68,7 @@ pub const Thunk = struct {
}
};
-pub fn createThunks(zld: *Zld, sect_id: u8, reverse_lookups: [][]u32) !void {
+pub fn createThunks(zld: *Zld, sect_id: u8) !void {
const header = &zld.sections.items(.header)[sect_id];
if (header.size == 0) return;
@@ -140,7 +140,6 @@ pub fn createThunks(zld: *Zld, sect_id: u8, reverse_lookups: [][]u32) !void {
try scanRelocs(
zld,
atom_index,
- reverse_lookups[atom.getFile().?],
allocated,
thunk_index,
group_end,
@@ -214,7 +213,6 @@ fn allocateThunk(
fn scanRelocs(
zld: *Zld,
atom_index: AtomIndex,
- reverse_lookup: []u32,
allocated: std.AutoHashMap(AtomIndex, void),
thunk_index: ThunkIndex,
group_end: AtomIndex,
@@ -231,7 +229,7 @@ fn scanRelocs(
for (relocs) |rel| {
if (!relocNeedsThunk(rel)) continue;
- const target = Atom.parseRelocTarget(zld, atom_index, rel, reverse_lookup);
+ const target = Atom.parseRelocTarget(zld, atom_index, rel);
if (isReachable(zld, atom_index, rel, base_offset, target, allocated)) continue;
log.debug("{x}: source = {s}@{x}, target = {s}@{x} unreachable", .{
@@ -308,7 +306,8 @@ fn isReachable(
if (!allocated.contains(target_atom_index)) return false;
const source_addr = source_sym.n_value + @intCast(u32, rel.r_address - base_offset);
- const target_addr = Atom.getRelocTargetAddress(zld, rel, target, false) catch unreachable;
+ 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
return false;