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...@@ -312,6 +312,8 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype
312312
313 if (rel.r_type() == elf.R_X86_64_NONE) continue;313 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
315 const symbol_index = switch (file_ptr) {317 const symbol_index = switch (file_ptr) {
316 .zig_module => |x| x.symbol(rel.r_sym()),318 .zig_module => |x| x.symbol(rel.r_sym()),
317 .object => |x| x.symbols.items[rel.r_sym()],319 .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...@@ -393,7 +395,7 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype
393 elf.R_X86_64_GOTTPOFF => {395 elf.R_X86_64_GOTTPOFF => {
394 const should_relax = blk: {396 const should_relax = blk: {
395 // if (!elf_file.options.relax or is_shared or symbol.flags.import) break :blk false;397 // 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;
397 break :blk true;399 break :blk true;
398 };400 };
399 if (!should_relax) {401 if (!should_relax) {
...@@ -409,7 +411,7 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype...@@ -409,7 +411,7 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, code: ?[]const u8, undefs: anytype
409 try err.addNote(elf_file, "in {}:{s} at offset 0x{x}", .{411 try err.addNote(elf_file, "in {}:{s} at offset 0x{x}", .{
410 self.file(elf_file).?.fmtPath(),412 self.file(elf_file).?.fmtPath(),
411 self.name(elf_file),413 self.name(elf_file),
412 rel.r_offset,414 r_offset,
413 });415 });
414 },416 },
415 }417 }
...@@ -569,7 +571,7 @@ pub fn resolveRelocs(self: Atom, elf_file: *Elf, code: []u8) !void {...@@ -569,7 +571,7 @@ pub fn resolveRelocs(self: Atom, elf_file: *Elf, code: []u8) !void {
569 // const S_ = @as(i64, @intCast(target.gotTpAddress(elf_file)));571 // const S_ = @as(i64, @intCast(target.gotTpAddress(elf_file)));
570 // try cwriter.writeIntLittle(i32, @as(i32, @intCast(S_ + A - P)));572 // try cwriter.writeIntLittle(i32, @as(i32, @intCast(S_ + A - P)));
571 } else {573 } else {
572 x86_64.relaxGotTpOff(code[rel.r_offset - 3 ..]) catch unreachable;574 x86_64.relaxGotTpOff(code[r_offset - 3 ..]) catch unreachable;
573 try cwriter.writeIntLittle(i32, @as(i32, @intCast(S - TP)));575 try cwriter.writeIntLittle(i32, @as(i32, @intCast(S - TP)));
574 }576 }
575 },577 },