diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-11-11 13:58:06 -0500 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2025-11-11 14:11:32 -0500 |
| commit | 61a1cefeb30fab3aa82e0d47385ca4f2c4b36c1b (patch) | |
| tree | 5a53f185e35120eb85922978f68ecb34633b652e /src/codegen | |
| parent | 79a9f3a4180dfe395c816b86a2afc79edc302e65 (diff) | |
| download | zig-61a1cefeb30fab3aa82e0d47385ca4f2c4b36c1b.tar.gz zig-61a1cefeb30fab3aa82e0d47385ca4f2c4b36c1b.zip | |
Elf2: implement PLT
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/x86_64/Emit.zig | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/codegen/x86_64/Emit.zig b/src/codegen/x86_64/Emit.zig index d859ba3c92..206b3414e3 100644 --- a/src/codegen/x86_64/Emit.zig +++ b/src/codegen/x86_64/Emit.zig @@ -881,7 +881,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI end_offset - 4, @enumFromInt(reloc.target.index), reloc.off - 4, - .{ .X86_64 = .PC32 }, + .{ .X86_64 = .PLT32 }, ) else if (emit.bin_file.cast(.macho)) |macho_file| { const zo = macho_file.getZigObject().?; const atom = zo.symbols.items[emit.atom_index].getAtom(macho_file).?; @@ -916,7 +916,13 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI .r_info = @as(u64, reloc.target.index) << 32 | @intFromEnum(r_type), .r_addend = reloc.off - 4, }, zo); - } else return emit.fail("TODO implement {s} reloc for {s}", .{ + } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc( + @enumFromInt(emit.atom_index), + end_offset - 4, + @enumFromInt(reloc.target.index), + reloc.off - 4, + .{ .X86_64 = if (emit.pic) .TLSLD else unreachable }, + ) else return emit.fail("TODO implement {s} reloc for {s}", .{ @tagName(reloc.target.type), @tagName(emit.bin_file.tag), }), .tlv => if (emit.bin_file.cast(.elf)) |elf_file| { @@ -933,7 +939,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI end_offset - 4, @enumFromInt(reloc.target.index), reloc.off, - .{ .X86_64 = .TPOFF32 }, + .{ .X86_64 = if (emit.pic) .DTPOFF32 else .TPOFF32 }, ) else if (emit.bin_file.cast(.macho)) |macho_file| { const zo = macho_file.getZigObject().?; const atom = zo.symbols.items[emit.atom_index].getAtom(macho_file).?; |
