authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-21 22:25:25+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-21 22:25:25+01:00
log7aeba3a3d12323c2593da5742665865b33818451
tree3d624a41e43612cb89d9f88e9fa0482a5ff22acb
parent887709ed5cac0275c09e6d2aa2faf729c5b5603d

elf+aarch64: implement some resolveRelocNonAlloc logic


1 files changed, 31 insertions(+), 2 deletions(-)

src/link/Elf/Atom.zig+31-2
......@@ -949,6 +949,10 @@ pub fn resolveRelocsNonAlloc(self: Atom, elf_file: *Elf, code: []u8, undefs: any
949949 error.RelocFailure => has_reloc_errors = true,
950950 else => |e| return e,
951951 },
952 .aarch64 => aarch64.resolveRelocNonAlloc(self, elf_file, rel, target, args, &it, code, &stream) catch |err| switch (err) {
953 error.RelocFailure => has_reloc_errors = true,
954 else => |e| return e,
955 },
952956 else => return error.UnsupportedCpuArch,
953957 }
954958 }
......@@ -1629,8 +1633,6 @@ const aarch64 = struct {
16291633
16301634 const r_type: elf.R_AARCH64 = @enumFromInt(rel.r_type());
16311635 const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow;
1632
1633 try stream.seekTo(r_offset);
16341636 const cwriter = stream.writer();
16351637
16361638 const P, const A, const S, const GOT, const G, const TP, const DTP, const ZIG_GOT = args;
......@@ -1724,6 +1726,33 @@ const aarch64 = struct {
17241726 }
17251727 }
17261728
1729 fn resolveRelocNonAlloc(
1730 atom: Atom,
1731 elf_file: *Elf,
1732 rel: elf.Elf64_Rela,
1733 target: *const Symbol,
1734 args: ResolveArgs,
1735 it: *RelocsIterator,
1736 code: []u8,
1737 stream: anytype,
1738 ) !void {
1739 _ = it;
1740 _ = code;
1741 _ = target;
1742
1743 const r_type: elf.R_AARCH64 = @enumFromInt(rel.r_type());
1744 const cwriter = stream.writer();
1745
1746 _, const A, const S, _, _, _, _, _ = args;
1747
1748 switch (r_type) {
1749 .NONE => unreachable,
1750 .ABS32 => try cwriter.writeInt(i32, @as(i32, @intCast(S + A)), .little),
1751 .ABS64 => try cwriter.writeInt(i64, S + A, .little),
1752 else => try atom.reportUnhandledRelocError(rel, elf_file),
1753 }
1754 }
1755
17271756 const aarch64_util = @import("../aarch64.zig");
17281757};
17291758