diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-10-29 18:01:10 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2025-10-29 18:06:17 -0400 |
| commit | 7542c3260f93e92fd8da7e5329bc80fd601964e9 (patch) | |
| tree | 1df5785b192e3098ca2823fc068c55757d2a7f78 /src/codegen | |
| parent | 6f0476e41d2f9b040a9883b288171c6a50c29ed5 (diff) | |
| download | zig-7542c3260f93e92fd8da7e5329bc80fd601964e9.tar.gz zig-7542c3260f93e92fd8da7e5329bc80fd601964e9.zip | |
Elf2: load relocations from input objects
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/x86_64/Emit.zig | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/codegen/x86_64/Emit.zig b/src/codegen/x86_64/Emit.zig index 3f4ef1b999..0aac146bc0 100644 --- a/src/codegen/x86_64/Emit.zig +++ b/src/codegen/x86_64/Emit.zig @@ -217,9 +217,7 @@ pub fn emitMir(emit: *Emit) Error!void { }, emit.lower.target), reloc_info), .mov => try emit.encodeInst(try .new(.none, .mov, &.{ lowered_inst.ops[0], - .{ .mem = .initSib(lowered_inst.ops[reloc.op_index].mem.sib.ptr_size, .{ - .base = .{ .reg = .ds }, - }) }, + .{ .mem = .initSib(lowered_inst.ops[reloc.op_index].mem.sib.ptr_size, .{}) }, }, emit.lower.target), reloc_info), else => unreachable, } else if (reloc.target.is_extern) switch (lowered_inst.encoding.mnemonic) { @@ -720,7 +718,7 @@ pub fn emitMir(emit: *Emit) Error!void { for (emit.table_relocs.items) |table_reloc| try atom.addReloc(gpa, .{ .r_offset = table_reloc.source_offset, - .r_info = @as(u64, emit.atom_index) << 32 | @intFromEnum(std.elf.R_X86_64.@"32"), + .r_info = @as(u64, emit.atom_index) << 32 | @intFromEnum(std.elf.R_X86_64.@"32S"), .r_addend = @as(i64, table_offset) + table_reloc.target_offset, }, zo); for (emit.lower.mir.table) |entry| { @@ -738,7 +736,7 @@ pub fn emitMir(emit: *Emit) Error!void { table_reloc.source_offset, @enumFromInt(emit.atom_index), @as(i64, table_offset) + table_reloc.target_offset, - .{ .X86_64 = .@"32" }, + .{ .X86_64 = .@"32S" }, ); for (emit.lower.mir.table) |entry| { try elf.addReloc( @@ -824,7 +822,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI const zo = elf_file.zigObjectPtr().?; const atom = zo.symbol(emit.atom_index).atom(elf_file).?; const r_type: std.elf.R_X86_64 = if (!emit.pic) - .@"32" + .@"32S" else if (reloc.target.is_extern and !reloc.target.force_pcrel_direct) .GOTPCREL else @@ -855,7 +853,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI end_offset - 4, @enumFromInt(reloc.target.index), reloc.off, - .{ .X86_64 = .@"32" }, + .{ .X86_64 = .@"32S" }, ) else if (emit.bin_file.cast(.coff2)) |coff| try coff.addReloc( @enumFromInt(emit.atom_index), end_offset - 4, |
