authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-28 21:42:09+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-28 21:42:09+02:00
log04a7051c4bf26ea9a5ffd2e5b618726e8ec06837
treee4997c91baa55cb8d818a04823891f694bf7ee33
parentcdd4dbfe32b198c7dd2fcd63e9f65778e40e43af

elf: fix 32bit build


1 files changed, 5 insertions(+), 3 deletions(-)

src/link/Elf/Atom.zig+5-3
......@@ -312,6 +312,8 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype
312312
313313 if (rel.r_type() == elf.R_X86_64_NONE) continue;
314314
315 const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow;
316
315317 const symbol_index = switch (file_ptr) {
316318 .zig_module => |x| x.symbol(rel.r_sym()),
317319 .object => |x| x.symbols.items[rel.r_sym()],
......@@ -393,7 +395,7 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype
393395 elf.R_X86_64_GOTTPOFF => {
394396 const should_relax = blk: {
395397 // if (!elf_file.options.relax or is_shared or symbol.flags.import) break :blk false;
396 if (!x86_64.canRelaxGotTpOff(code.?[rel.r_offset - 3 ..])) break :blk false;
398 if (!x86_64.canRelaxGotTpOff(code.?[r_offset - 3 ..])) break :blk false;
397399 break :blk true;
398400 };
399401 if (!should_relax) {
......@@ -409,7 +411,7 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype
409411 try err.addNote(elf_file, "in {}:{s} at offset 0x{x}", .{
410412 self.file(elf_file).?.fmtPath(),
411413 self.name(elf_file),
412 rel.r_offset,
414 r_offset,
413415 });
414416 },
415417 }
......@@ -569,7 +571,7 @@ pub fn resolveRelocs(self: Atom, elf_file: *Elf, code: []u8) !void {
569571 // const S_ = @as(i64, @intCast(target.gotTpAddress(elf_file)));
570572 // try cwriter.writeIntLittle(i32, @as(i32, @intCast(S_ + A - P)));
571573 } else {
572 x86_64.relaxGotTpOff(code[rel.r_offset - 3 ..]) catch unreachable;
574 x86_64.relaxGotTpOff(code[r_offset - 3 ..]) catch unreachable;
573575 try cwriter.writeIntLittle(i32, @as(i32, @intCast(S - TP)));
574576 }
575577 },