authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-09-04 05:22:26+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-09-04 05:22:26+03:00
loge9807418e7e58f3cb85d5d3a6d114d5084e305bd
tree81e328a6dc92b35d12d4ab012e99a0ef1f8e4a31
parente9b137f23a9b38c6b808452ef216e4e18d3070ed

Added .pe ObjectFormat

MachO linker no longer collects unused dwarf debug information

4 files changed, 6 insertions(+), 31 deletions(-)

lib/std/target.zig+1
......@@ -468,6 +468,7 @@ pub const Target = struct {
468468 /// TODO Get rid of this one.
469469 unknown,
470470 coff,
471 pe,
471472 elf,
472473 macho,
473474 wasm,
src-self-hosted/link.zig+1-1
......@@ -68,7 +68,7 @@ pub const File = struct {
6868 pub fn openPath(allocator: *Allocator, dir: fs.Dir, sub_path: []const u8, options: Options) !*File {
6969 switch (options.object_format) {
7070 .unknown => unreachable,
71 .coff => return Coff.openPath(allocator, dir, sub_path, options),
71 .coff, .pe => return Coff.openPath(allocator, dir, sub_path, options),
7272 .elf => return Elf.openPath(allocator, dir, sub_path, options),
7373 .macho => return MachO.openPath(allocator, dir, sub_path, options),
7474 .wasm => return Wasm.openPath(allocator, dir, sub_path, options),
src-self-hosted/link/MachO.zig+1-24
......@@ -316,31 +316,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {
316316 var code_buffer = std.ArrayList(u8).init(self.base.allocator);
317317 defer code_buffer.deinit();
318318
319 var dbg_line_buffer = std.ArrayList(u8).init(self.base.allocator);
320 defer dbg_line_buffer.deinit();
321
322 var dbg_info_buffer = std.ArrayList(u8).init(self.base.allocator);
323 defer dbg_info_buffer.deinit();
324
325 var dbg_info_type_relocs: File.DbgInfoTypeRelocsTable = .{};
326 defer {
327 var it = dbg_info_type_relocs.iterator();
328 while (it.next()) |entry| {
329 entry.value.relocs.deinit(self.base.allocator);
330 }
331 dbg_info_type_relocs.deinit(self.base.allocator);
332 }
333
334319 const typed_value = decl.typed_value.most_recent.typed_value;
335 const res = try codegen.generateSymbol(
336 &self.base,
337 decl.src(),
338 typed_value,
339 &code_buffer,
340 &dbg_line_buffer,
341 &dbg_info_buffer,
342 &dbg_info_type_relocs,
343 );
320 const res = try codegen.generateSymbol(&self.base, decl.src(), typed_value, &code_buffer, .none);
344321
345322 const code = switch (res) {
346323 .externally_managed => |x| x,
src-self-hosted/main.zig+3-6
......@@ -153,8 +153,8 @@ const usage_build_generic =
153153 \\ elf Executable and Linking Format
154154 \\ c Compile to C source code
155155 \\ wasm WebAssembly
156 \\ pe Portable Executable (Windows)
156157 \\ coff (planned) Common Object File Format (Windows)
157 \\ pe (planned) Portable Executable (Windows)
158158 \\ macho (planned) macOS relocatables
159159 \\ hex (planned) Intel IHEX
160160 \\ raw (planned) Dump machine code directly
......@@ -451,7 +451,7 @@ fn buildOutputType(
451451 } else if (mem.eql(u8, ofmt, "coff")) {
452452 break :blk .coff;
453453 } else if (mem.eql(u8, ofmt, "pe")) {
454 break :blk .coff;
454 break :blk .pe;
455455 } else if (mem.eql(u8, ofmt, "macho")) {
456456 break :blk .macho;
457457 } else if (mem.eql(u8, ofmt, "wasm")) {
......@@ -524,10 +524,7 @@ fn buildOutputType(
524524 try stderr.print("\nUnable to parse command: {}\n", .{@errorName(err)});
525525 continue;
526526 }) |line| {
527 const actual_line = if (line[line.len - 1] == '\r')
528 line[0 .. line.len - 1]
529 else
530 line;
527 const actual_line = mem.trimRight(u8, line, "\r\n ");
531528
532529 if (mem.eql(u8, actual_line, "update")) {
533530 if (output_mode == .Exe) {