| ... | ... | @@ -750,8 +750,6 @@ pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) RelocError!voi |
| 750 | 750 | const S = target.address(.{}, elf_file); |
| 751 | 751 | // Address of the global offset table. |
| 752 | 752 | const GOT = elf_file.gotAddress(); |
| 753 | | // Address of the zig jump table entry if any. |
| 754 | | const ZJT = target.zigJumpTableAddress(elf_file); |
| 755 | 753 | // Relative offset to the start of the global offset table. |
| 756 | 754 | const G = target.gotAddress(elf_file) - GOT; |
| 757 | 755 | // // Address of the thread pointer. |
| ... | ... | @@ -759,19 +757,18 @@ pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) RelocError!voi |
| 759 | 757 | // Address of the dynamic thread pointer. |
| 760 | 758 | const DTP = elf_file.dtpAddress(); |
| 761 | 759 | |
| 762 | | relocs_log.debug(" {s}: {x}: [{x} => {x}] GOT({x}) ZJT({x}) ({s})", .{ |
| 760 | relocs_log.debug(" {s}: {x}: [{x} => {x}] GOT({x}) ({s})", .{ |
| 763 | 761 | relocation.fmtRelocType(rel.r_type(), cpu_arch), |
| 764 | 762 | r_offset, |
| 765 | 763 | P, |
| 766 | 764 | S + A, |
| 767 | 765 | G + GOT + A, |
| 768 | | ZJT + A, |
| 769 | 766 | target.name(elf_file), |
| 770 | 767 | }); |
| 771 | 768 | |
| 772 | 769 | try stream.seekTo(r_offset); |
| 773 | 770 | |
| 774 | | const args = ResolveArgs{ P, A, S, GOT, G, TP, DTP, ZJT }; |
| 771 | const args = ResolveArgs{ P, A, S, GOT, G, TP, DTP }; |
| 775 | 772 | |
| 776 | 773 | switch (cpu_arch) { |
| 777 | 774 | .x86_64 => x86_64.resolveRelocAlloc(self, elf_file, rel, target, args, &it, code, &stream) catch |err| switch (err) { |
| ... | ... | @@ -956,7 +953,7 @@ pub fn resolveRelocsNonAlloc(self: Atom, elf_file: *Elf, code: []u8, undefs: any |
| 956 | 953 | // Address of the dynamic thread pointer. |
| 957 | 954 | const DTP = elf_file.dtpAddress(); |
| 958 | 955 | |
| 959 | | const args = ResolveArgs{ P, A, S, GOT, 0, 0, DTP, 0 }; |
| 956 | const args = ResolveArgs{ P, A, S, GOT, 0, 0, DTP }; |
| 960 | 957 | |
| 961 | 958 | relocs_log.debug(" {}: {x}: [{x} => {x}] ({s})", .{ |
| 962 | 959 | relocation.fmtRelocType(rel.r_type(), cpu_arch), |
| ... | ... | @@ -1200,7 +1197,7 @@ const x86_64 = struct { |
| 1200 | 1197 | |
| 1201 | 1198 | const cwriter = stream.writer(); |
| 1202 | 1199 | |
| 1203 | | const P, const A, const S, const GOT, const G, const TP, const DTP, const ZJT = args; |
| 1200 | const P, const A, const S, const GOT, const G, const TP, const DTP = args; |
| 1204 | 1201 | |
| 1205 | 1202 | switch (r_type) { |
| 1206 | 1203 | .NONE => unreachable, |
| ... | ... | @@ -1215,10 +1212,7 @@ const x86_64 = struct { |
| 1215 | 1212 | ); |
| 1216 | 1213 | }, |
| 1217 | 1214 | |
| 1218 | | .PLT32 => { |
| 1219 | | const S_ = if (target.flags.zig_jump_table) ZJT else S; |
| 1220 | | try cwriter.writeInt(i32, @as(i32, @intCast(S_ + A - P)), .little); |
| 1221 | | }, |
| 1215 | .PLT32 => try cwriter.writeInt(i32, @as(i32, @intCast(S + A - P)), .little), |
| 1222 | 1216 | .PC32 => try cwriter.writeInt(i32, @as(i32, @intCast(S + A - P)), .little), |
| 1223 | 1217 | |
| 1224 | 1218 | .GOTPCREL => try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A - P)), .little), |
| ... | ... | @@ -1243,10 +1237,7 @@ const x86_64 = struct { |
| 1243 | 1237 | try cwriter.writeInt(i32, @as(i32, @intCast(G + GOT + A - P)), .little); |
| 1244 | 1238 | }, |
| 1245 | 1239 | |
| 1246 | | .@"32" => { |
| 1247 | | const S_ = if (target.flags.zig_jump_table) ZJT else S; |
| 1248 | | try cwriter.writeInt(u32, @as(u32, @truncate(@as(u64, @intCast(S_ + A)))), .little); |
| 1249 | | }, |
| 1240 | .@"32" => try cwriter.writeInt(u32, @as(u32, @truncate(@as(u64, @intCast(S + A)))), .little), |
| 1250 | 1241 | .@"32S" => try cwriter.writeInt(i32, @as(i32, @truncate(S + A)), .little), |
| 1251 | 1242 | |
| 1252 | 1243 | .TPOFF32 => try cwriter.writeInt(i32, @as(i32, @truncate(S + A - TP)), .little), |
| ... | ... | @@ -1345,7 +1336,7 @@ const x86_64 = struct { |
| 1345 | 1336 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); |
| 1346 | 1337 | const cwriter = stream.writer(); |
| 1347 | 1338 | |
| 1348 | | _, const A, const S, const GOT, _, _, const DTP, _ = args; |
| 1339 | _, const A, const S, const GOT, _, _, const DTP = args; |
| 1349 | 1340 | |
| 1350 | 1341 | switch (r_type) { |
| 1351 | 1342 | .NONE => unreachable, |
| ... | ... | @@ -1728,9 +1719,8 @@ const aarch64 = struct { |
| 1728 | 1719 | const code = code_buffer[r_offset..][0..4]; |
| 1729 | 1720 | const file_ptr = atom.file(elf_file).?; |
| 1730 | 1721 | |
| 1731 | | const P, const A, const S, const GOT, const G, const TP, const DTP, const ZJT = args; |
| 1722 | const P, const A, const S, const GOT, const G, const TP, const DTP = args; |
| 1732 | 1723 | _ = DTP; |
| 1733 | | _ = ZJT; |
| 1734 | 1724 | |
| 1735 | 1725 | switch (r_type) { |
| 1736 | 1726 | .NONE => unreachable, |
| ... | ... | @@ -1932,7 +1922,7 @@ const aarch64 = struct { |
| 1932 | 1922 | const r_type: elf.R_AARCH64 = @enumFromInt(rel.r_type()); |
| 1933 | 1923 | const cwriter = stream.writer(); |
| 1934 | 1924 | |
| 1935 | | _, const A, const S, _, _, _, _, _ = args; |
| 1925 | _, const A, const S, _, _, _, _ = args; |
| 1936 | 1926 | |
| 1937 | 1927 | switch (r_type) { |
| 1938 | 1928 | .NONE => unreachable, |
| ... | ... | @@ -2012,10 +2002,9 @@ const riscv = struct { |
| 2012 | 2002 | const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow; |
| 2013 | 2003 | const cwriter = stream.writer(); |
| 2014 | 2004 | |
| 2015 | | const P, const A, const S, const GOT, const G, const TP, const DTP, const ZJT = args; |
| 2005 | const P, const A, const S, const GOT, const G, const TP, const DTP = args; |
| 2016 | 2006 | _ = TP; |
| 2017 | 2007 | _ = DTP; |
| 2018 | | _ = ZJT; |
| 2019 | 2008 | |
| 2020 | 2009 | switch (r_type) { |
| 2021 | 2010 | .NONE => unreachable, |
| ... | ... | @@ -2167,7 +2156,7 @@ const riscv = struct { |
| 2167 | 2156 | const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow; |
| 2168 | 2157 | const cwriter = stream.writer(); |
| 2169 | 2158 | |
| 2170 | | _, const A, const S, const GOT, _, _, const DTP, _ = args; |
| 2159 | _, const A, const S, const GOT, _, _, const DTP = args; |
| 2171 | 2160 | _ = GOT; |
| 2172 | 2161 | _ = DTP; |
| 2173 | 2162 | |
| ... | ... | @@ -2203,7 +2192,7 @@ const riscv = struct { |
| 2203 | 2192 | const riscv_util = @import("../riscv.zig"); |
| 2204 | 2193 | }; |
| 2205 | 2194 | |
| 2206 | | const ResolveArgs = struct { i64, i64, i64, i64, i64, i64, i64, i64 }; |
| 2195 | const ResolveArgs = struct { i64, i64, i64, i64, i64, i64, i64 }; |
| 2207 | 2196 | |
| 2208 | 2197 | const RelocError = error{ |
| 2209 | 2198 | Overflow, |