authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-07-20 07:43:53-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-07-20 07:43:53-04:00
log542423915466c0e20b0947f745a1de276fbd8b03
tree1399f8c2a1d523788b85c28e4230729b7d1380e3
parent2e65244cae7e4365ecf3aa6857b84451272316a1

dev: add missing x86_64 backend checks


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

src/dev.zig-1
......@@ -23,7 +23,6 @@ pub const Env = enum {
2323 sema,
2424
2525 /// - sema
26 /// - jit command on x86_64-linux host
2726 /// - `zig build-* -fno-llvm -fno-lld -target x86_64-linux`
2827 @"x86_64-linux",
2928
src/link/Elf/Atom.zig+12
......@@ -1113,6 +1113,7 @@ const x86_64 = struct {
11131113 code: ?[]const u8,
11141114 it: *RelocsIterator,
11151115 ) !void {
1116 dev.check(.x86_64_backend);
11161117 const is_static = elf_file.base.isStatic();
11171118 const is_dyn_lib = elf_file.isEffectivelyDynLib();
11181119
......@@ -1235,6 +1236,7 @@ const x86_64 = struct {
12351236 code: []u8,
12361237 stream: anytype,
12371238 ) (error{ InvalidInstruction, CannotEncode } || RelocError)!void {
1239 dev.check(.x86_64_backend);
12381240 const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type());
12391241 const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow;
12401242
......@@ -1380,6 +1382,7 @@ const x86_64 = struct {
13801382 code: []u8,
13811383 stream: anytype,
13821384 ) !void {
1385 dev.check(.x86_64_backend);
13831386 _ = code;
13841387 _ = it;
13851388 const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type());
......@@ -1420,6 +1423,7 @@ const x86_64 = struct {
14201423 }
14211424
14221425 fn relaxGotpcrelx(code: []u8) !void {
1426 dev.check(.x86_64_backend);
14231427 const old_inst = disassemble(code) orelse return error.RelaxFailure;
14241428 const inst = switch (old_inst.encoding.mnemonic) {
14251429 .call => try Instruction.new(old_inst.prefix, .call, &.{
......@@ -1438,6 +1442,7 @@ const x86_64 = struct {
14381442 }
14391443
14401444 fn relaxRexGotpcrelx(code: []u8) !void {
1445 dev.check(.x86_64_backend);
14411446 const old_inst = disassemble(code) orelse return error.RelaxFailure;
14421447 switch (old_inst.encoding.mnemonic) {
14431448 .mov => {
......@@ -1456,6 +1461,7 @@ const x86_64 = struct {
14561461 elf_file: *Elf,
14571462 stream: anytype,
14581463 ) !void {
1464 dev.check(.x86_64_backend);
14591465 assert(rels.len == 2);
14601466 const writer = stream.writer();
14611467 const rel: elf.R_X86_64 = @enumFromInt(rels[1].r_type());
......@@ -1495,6 +1501,7 @@ const x86_64 = struct {
14951501 elf_file: *Elf,
14961502 stream: anytype,
14971503 ) !void {
1504 dev.check(.x86_64_backend);
14981505 assert(rels.len == 2);
14991506 const writer = stream.writer();
15001507 const rel: elf.R_X86_64 = @enumFromInt(rels[1].r_type());
......@@ -1543,6 +1550,7 @@ const x86_64 = struct {
15431550 }
15441551
15451552 fn canRelaxGotTpOff(code: []const u8) bool {
1553 dev.check(.x86_64_backend);
15461554 const old_inst = disassemble(code) orelse return false;
15471555 switch (old_inst.encoding.mnemonic) {
15481556 .mov => if (Instruction.new(old_inst.prefix, .mov, &.{
......@@ -1558,6 +1566,7 @@ const x86_64 = struct {
15581566 }
15591567
15601568 fn relaxGotTpOff(code: []u8) void {
1569 dev.check(.x86_64_backend);
15611570 const old_inst = disassemble(code) orelse unreachable;
15621571 switch (old_inst.encoding.mnemonic) {
15631572 .mov => {
......@@ -1574,6 +1583,7 @@ const x86_64 = struct {
15741583 }
15751584
15761585 fn relaxGotPcTlsDesc(code: []u8) !void {
1586 dev.check(.x86_64_backend);
15771587 const old_inst = disassemble(code) orelse return error.RelaxFailure;
15781588 switch (old_inst.encoding.mnemonic) {
15791589 .lea => {
......@@ -1596,6 +1606,7 @@ const x86_64 = struct {
15961606 elf_file: *Elf,
15971607 stream: anytype,
15981608 ) !void {
1609 dev.check(.x86_64_backend);
15991610 assert(rels.len == 2);
16001611 const writer = stream.writer();
16011612 const rel: elf.R_X86_64 = @enumFromInt(rels[1].r_type());
......@@ -2312,3 +2323,4 @@ const File = @import("file.zig").File;
23122323const Object = @import("Object.zig");
23132324const Symbol = @import("Symbol.zig");
23142325const Thunk = @import("thunks.zig").Thunk;
2326const dev = @import("../../dev.zig");
src/link/MachO/Atom.zig+3
......@@ -897,6 +897,7 @@ fn resolveRelocInner(
897897
898898const x86_64 = struct {
899899 fn relaxGotLoad(self: Atom, code: []u8, rel: Relocation, macho_file: *MachO) ResolveError!void {
900 dev.check(.x86_64_backend);
900901 const old_inst = disassemble(code) orelse return error.RelaxFail;
901902 switch (old_inst.encoding.mnemonic) {
902903 .mov => {
......@@ -920,6 +921,7 @@ const x86_64 = struct {
920921 }
921922
922923 fn relaxTlv(code: []u8) error{RelaxFail}!void {
924 dev.check(.x86_64_backend);
923925 const old_inst = disassemble(code) orelse return error.RelaxFail;
924926 switch (old_inst.encoding.mnemonic) {
925927 .mov => {
......@@ -1214,3 +1216,4 @@ const Relocation = @import("Relocation.zig");
12141216const Symbol = @import("Symbol.zig");
12151217const Thunk = @import("thunks.zig").Thunk;
12161218const UnwindInfo = @import("UnwindInfo.zig");
1219const dev = @import("../../dev.zig");