Skip to content

Commit

Permalink
elf: do not relocs_log when scanning relocs
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Sep 20, 2024
1 parent b3d3a67 commit 341255b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Elf/Atom.zig
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ const x86_64 = struct {
.GOTTPOFF => {
const should_relax = blk: {
if (!elf_file.options.relax or is_shared or symbol.flags.import) break :blk false;
relaxGotTpOff(code[rel.r_offset - 3 ..]) catch break :blk false;
relaxGotTpOff(code[rel.r_offset - 3 ..], false) catch break :blk false;
break :blk true;
};
if (!should_relax) {
Expand Down Expand Up @@ -984,7 +984,7 @@ const x86_64 = struct {
const S_ = target.getGotTpAddress(elf_file);
try cwriter.writeInt(i32, @as(i32, @intCast(S_ + A - P)), .little);
} else {
try relaxGotTpOff(code[rel.r_offset - 3 ..]);
try relaxGotTpOff(code[rel.r_offset - 3 ..], true);
try cwriter.writeInt(i32, @as(i32, @intCast(S - TP)), .little);
}
},
Expand Down Expand Up @@ -1228,7 +1228,7 @@ const x86_64 = struct {
}
}

fn relaxGotTpOff(code: []u8) !void {
fn relaxGotTpOff(code: []u8, comptime should_log: bool) !void {
const old_inst = disassemble(code) orelse return error.RelaxFail;
switch (old_inst.encoding.mnemonic) {
.mov => {
Expand All @@ -1237,7 +1237,7 @@ const x86_64 = struct {
// TODO: hack to force imm32s in the assembler
.{ .imm = Immediate.s(-129) },
});
relocs_log.debug(" relaxing {} => {}", .{ old_inst.encoding, inst.encoding });
if (should_log) relocs_log.debug(" relaxing {} => {}", .{ old_inst.encoding, inst.encoding });
encode(&.{inst}, code) catch return error.RelaxFail;
},
else => return error.RelaxFail,
Expand Down

0 comments on commit 341255b

Please sign in to comment.