Skip to content

Commit 1fa11e0

Browse files
committed
Coff: delete
1 parent e1f3fc6 commit 1fa11e0

File tree

9 files changed

+85
-3294
lines changed

9 files changed

+85
-3294
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ set(ZIG_STAGE2_SOURCES
561561
src/libs/libunwind.zig
562562
src/link.zig
563563
src/link/C.zig
564-
src/link/Coff.zig
565564
src/link/Dwarf.zig
566565
src/link/Elf.zig
567566
src/link/Elf/Archive.zig

src/Compilation.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3226,7 +3226,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
32263226
.root_dir = comp.dirs.local_cache,
32273227
.sub_path = try fs.path.join(arena, &.{ o_sub_path, comp.emit_bin.? }),
32283228
};
3229-
const result: link.File.OpenError!void = switch (need_writable_dance) {
3229+
const result: (link.File.OpenError || error{HotSwapUnavailableOnHostOperatingSystem})!void = switch (need_writable_dance) {
32303230
.no => {},
32313231
.lf_only => lf.makeWritable(),
32323232
.lf_and_debug => res: {

src/Compilation/Config.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,6 @@ pub fn resolve(options: Options) ResolveError!Config {
438438

439439
if (options.use_new_linker) |x| break :b x;
440440

441-
if (target.ofmt == .coff) break :b true;
442-
443441
break :b options.incremental;
444442
};
445443

src/codegen.zig

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -978,21 +978,6 @@ pub fn genNavRef(
978978
},
979979
.link_once => unreachable,
980980
}
981-
} else if (lf.cast(.coff)) |coff_file| {
982-
// TODO audit this
983-
switch (linkage) {
984-
.internal => {
985-
const atom_index = try coff_file.getOrCreateAtomForNav(nav_index);
986-
const sym_index = coff_file.getAtom(atom_index).getSymbolIndex().?;
987-
return .{ .sym_index = sym_index };
988-
},
989-
.strong, .weak => {
990-
const global_index = try coff_file.getGlobalSymbol(nav.name.toSlice(ip), lib_name.toSlice(ip));
991-
try coff_file.need_got_table.put(zcu.gpa, global_index, {}); // needs GOT
992-
return .{ .sym_index = global_index };
993-
},
994-
.link_once => unreachable,
995-
}
996981
} else if (lf.cast(.coff2)) |coff| {
997982
return .{ .sym_index = @intFromEnum(try coff.navSymbol(zcu, nav_index)) };
998983
} else {

src/codegen/aarch64/Mir.zig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ pub fn emit(
135135
else if (lf.cast(.macho)) |mf|
136136
mf.getZigObject().?.getOrCreateMetadataForLazySymbol(mf, pt, lazy_reloc.symbol) catch |err|
137137
return zcu.codegenFail(func.owner_nav, "{s} creating lazy symbol", .{@errorName(err)})
138-
else if (lf.cast(.coff)) |cf|
139-
if (cf.getOrCreateAtomForLazySymbol(pt, lazy_reloc.symbol)) |atom|
140-
cf.getAtom(atom).getSymbolIndex().?
141-
else |err|
142-
return zcu.codegenFail(func.owner_nav, "{s} creating lazy symbol", .{@errorName(err)})
143138
else
144139
return zcu.codegenFail(func.owner_nav, "external symbols unimplemented for {s}", .{@tagName(lf.tag)}),
145140
mir.body[lazy_reloc.reloc.label],
@@ -154,8 +149,6 @@ pub fn emit(
154149
try ef.getGlobalSymbol(std.mem.span(global_reloc.name), null)
155150
else if (lf.cast(.macho)) |mf|
156151
try mf.getGlobalSymbol(std.mem.span(global_reloc.name), null)
157-
else if (lf.cast(.coff)) |cf|
158-
try cf.getGlobalSymbol(std.mem.span(global_reloc.name), "compiler_rt")
159152
else
160153
return zcu.codegenFail(func.owner_nav, "external symbols unimplemented for {s}", .{@tagName(lf.tag)}),
161154
mir.body[global_reloc.reloc.label],

src/codegen/x86_64/Emit.zig

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ pub fn emitMir(emit: *Emit) Error!void {
170170
else if (emit.bin_file.cast(.macho)) |macho_file|
171171
macho_file.getZigObject().?.getOrCreateMetadataForLazySymbol(macho_file, emit.pt, lazy_sym) catch |err|
172172
return emit.fail("{s} creating lazy symbol", .{@errorName(err)})
173-
else if (emit.bin_file.cast(.coff)) |coff_file|
174-
if (coff_file.getOrCreateAtomForLazySymbol(emit.pt, lazy_sym)) |atom|
175-
coff_file.getAtom(atom).getSymbolIndex().?
176-
else |err|
177-
return emit.fail("{s} creating lazy symbol", .{@errorName(err)})
178173
else if (emit.bin_file.cast(.coff2)) |elf|
179174
@intFromEnum(try elf.lazySymbol(lazy_sym))
180175
else
@@ -190,8 +185,6 @@ pub fn emitMir(emit: *Emit) Error!void {
190185
.type = .FUNC,
191186
})) else if (emit.bin_file.cast(.macho)) |macho_file|
192187
try macho_file.getGlobalSymbol(extern_func.toSlice(&emit.lower.mir).?, null)
193-
else if (emit.bin_file.cast(.coff)) |coff_file|
194-
try coff_file.getGlobalSymbol(extern_func.toSlice(&emit.lower.mir).?, "compiler_rt")
195188
else if (emit.bin_file.cast(.coff2)) |coff| @intFromEnum(try coff.globalSymbol(
196189
extern_func.toSlice(&emit.lower.mir).?,
197190
switch (comp.compiler_rt_strat) {
@@ -211,9 +204,7 @@ pub fn emitMir(emit: *Emit) Error!void {
211204
switch (lowered_inst.encoding.mnemonic) {
212205
.call => {
213206
reloc.target.type = .branch;
214-
if (emit.bin_file.cast(.coff)) |_| try emit.encodeInst(try .new(.none, .call, &.{
215-
.{ .mem = .initRip(.ptr, 0) },
216-
}, emit.lower.target), reloc_info) else try emit.encodeInst(lowered_inst, reloc_info);
207+
try emit.encodeInst(lowered_inst, reloc_info);
217208
continue :lowered_inst;
218209
},
219210
else => {},
@@ -290,37 +281,6 @@ pub fn emitMir(emit: *Emit) Error!void {
290281
}, emit.lower.target), reloc_info),
291282
else => unreachable,
292283
}
293-
} else if (emit.bin_file.cast(.coff)) |_| {
294-
if (reloc.target.is_extern) switch (lowered_inst.encoding.mnemonic) {
295-
.lea => try emit.encodeInst(try .new(.none, .mov, &.{
296-
lowered_inst.ops[0],
297-
.{ .mem = .initRip(.ptr, 0) },
298-
}, emit.lower.target), reloc_info),
299-
.mov => {
300-
const dst_reg = lowered_inst.ops[0].reg.to64();
301-
try emit.encodeInst(try .new(.none, .mov, &.{
302-
.{ .reg = dst_reg },
303-
.{ .mem = .initRip(.ptr, 0) },
304-
}, emit.lower.target), reloc_info);
305-
try emit.encodeInst(try .new(.none, .mov, &.{
306-
lowered_inst.ops[0],
307-
.{ .mem = .initSib(lowered_inst.ops[reloc.op_index].mem.sib.ptr_size, .{ .base = .{
308-
.reg = dst_reg,
309-
} }) },
310-
}, emit.lower.target), &.{});
311-
},
312-
else => unreachable,
313-
} else switch (lowered_inst.encoding.mnemonic) {
314-
.lea => try emit.encodeInst(try .new(.none, .lea, &.{
315-
lowered_inst.ops[0],
316-
.{ .mem = .initRip(.none, 0) },
317-
}, emit.lower.target), reloc_info),
318-
.mov => try emit.encodeInst(try .new(.none, .mov, &.{
319-
lowered_inst.ops[0],
320-
.{ .mem = .initRip(lowered_inst.ops[reloc.op_index].mem.sib.ptr_size, 0) },
321-
}, emit.lower.target), reloc_info),
322-
else => unreachable,
323-
}
324284
} else if (emit.bin_file.cast(.coff2)) |_| {
325285
switch (lowered_inst.encoding.mnemonic) {
326286
.lea => try emit.encodeInst(try .new(.none, .lea, &.{
@@ -820,22 +780,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
820780
@enumFromInt(reloc.target.index),
821781
reloc.off,
822782
.{ .X86_64 = .@"32" },
823-
) else if (emit.bin_file.cast(.coff)) |coff_file| {
824-
const atom_index = coff_file.getAtomIndexForSymbol(
825-
.{ .sym_index = emit.atom_index, .file = null },
826-
).?;
827-
try coff_file.addRelocation(atom_index, .{
828-
.type = if (reloc.target.is_extern) .got else .direct,
829-
.target = if (reloc.target.is_extern)
830-
coff_file.getGlobalByIndex(reloc.target.index)
831-
else
832-
.{ .sym_index = reloc.target.index, .file = null },
833-
.offset = end_offset - 4,
834-
.addend = @intCast(reloc.off),
835-
.pcrel = true,
836-
.length = 2,
837-
});
838-
} else if (emit.bin_file.cast(.coff2)) |coff| try coff.addReloc(
783+
) else if (emit.bin_file.cast(.coff2)) |coff| try coff.addReloc(
839784
@enumFromInt(emit.atom_index),
840785
end_offset - 4,
841786
@enumFromInt(reloc.target.index),
@@ -873,21 +818,6 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
873818
.symbolnum = @intCast(reloc.target.index),
874819
},
875820
});
876-
} else if (emit.bin_file.cast(.coff)) |coff_file| {
877-
const atom_index = coff_file.getAtomIndexForSymbol(
878-
.{ .sym_index = emit.atom_index, .file = null },
879-
).?;
880-
try coff_file.addRelocation(atom_index, .{
881-
.type = if (reloc.target.is_extern) .import else .got,
882-
.target = if (reloc.target.is_extern)
883-
coff_file.getGlobalByIndex(reloc.target.index)
884-
else
885-
.{ .sym_index = reloc.target.index, .file = null },
886-
.offset = end_offset - 4,
887-
.addend = @intCast(reloc.off),
888-
.pcrel = true,
889-
.length = 2,
890-
});
891821
} else if (emit.bin_file.cast(.coff2)) |coff| try coff.addReloc(
892822
@enumFromInt(emit.atom_index),
893823
end_offset - 4,

src/link.zig

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -574,16 +574,13 @@ pub const File = struct {
574574
const gpa = comp.gpa;
575575
switch (base.tag) {
576576
.lld => assert(base.file == null),
577-
.coff, .elf, .macho, .wasm, .goff, .xcoff => {
577+
.elf, .macho, .wasm, .goff, .xcoff => {
578578
if (base.file != null) return;
579579
dev.checkAny(&.{ .coff_linker, .elf_linker, .macho_linker, .plan9_linker, .wasm_linker, .goff_linker, .xcoff_linker });
580580
const emit = base.emit;
581581
if (base.child_pid) |pid| {
582582
if (builtin.os.tag == .windows) {
583-
const coff_file = base.cast(.coff).?;
584-
coff_file.ptraceAttach(pid) catch |err| {
585-
log.warn("attaching failed with error: {s}", .{@errorName(err)});
586-
};
583+
return error.HotSwapUnavailableOnHostOperatingSystem;
587584
} else {
588585
// If we try to open the output file in write mode while it is running,
589586
// it will return ETXTBSY. So instead, we copy the file, atomically rename it
@@ -671,7 +668,7 @@ pub const File = struct {
671668
}
672669
}
673670
},
674-
.coff, .macho, .wasm, .goff, .xcoff => if (base.file) |f| {
671+
.macho, .wasm, .goff, .xcoff => if (base.file) |f| {
675672
dev.checkAny(&.{ .coff_linker, .macho_linker, .plan9_linker, .wasm_linker, .goff_linker, .xcoff_linker });
676673
f.close();
677674
base.file = null;
@@ -684,10 +681,6 @@ pub const File = struct {
684681
log.warn("detaching failed with error: {s}", .{@errorName(err)});
685682
};
686683
},
687-
.windows => {
688-
const coff_file = base.cast(.coff).?;
689-
coff_file.ptraceDetach(pid);
690-
},
691684
else => return error.HotSwapUnavailableOnHostOperatingSystem,
692685
}
693686
}
@@ -1157,7 +1150,6 @@ pub const File = struct {
11571150
}
11581151

11591152
pub const Tag = enum {
1160-
coff,
11611153
coff2,
11621154
elf,
11631155
elf2,
@@ -1172,7 +1164,6 @@ pub const File = struct {
11721164

11731165
pub fn Type(comptime tag: Tag) type {
11741166
return switch (tag) {
1175-
.coff => Coff,
11761167
.coff2 => Coff2,
11771168
.elf => Elf,
11781169
.elf2 => Elf2,
@@ -1189,7 +1180,7 @@ pub const File = struct {
11891180

11901181
fn fromObjectFormat(ofmt: std.Target.ObjectFormat, use_new_linker: bool) Tag {
11911182
return switch (ofmt) {
1192-
.coff => if (use_new_linker) .coff2 else .coff,
1183+
.coff => .coff2,
11931184
.elf => if (use_new_linker) .elf2 else .elf,
11941185
.macho => .macho,
11951186
.wasm => .wasm,
@@ -1274,7 +1265,6 @@ pub const File = struct {
12741265

12751266
pub const Lld = @import("link/Lld.zig");
12761267
pub const C = @import("link/C.zig");
1277-
pub const Coff = @import("link/Coff.zig");
12781268
pub const Coff2 = @import("link/Coff2.zig");
12791269
pub const Elf = @import("link/Elf.zig");
12801270
pub const Elf2 = @import("link/Elf2.zig");

0 commit comments

Comments
 (0)