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 {...@@ -468,6 +468,7 @@ pub const Target = struct {
468 /// TODO Get rid of this one.468 /// TODO Get rid of this one.
469 unknown,469 unknown,
470 coff,470 coff,
471 pe,
471 elf,472 elf,
472 macho,473 macho,
473 wasm,474 wasm,
src-self-hosted/link.zig+1-1
...@@ -68,7 +68,7 @@ pub const File = struct {...@@ -68,7 +68,7 @@ pub const File = struct {
68 pub fn openPath(allocator: *Allocator, dir: fs.Dir, sub_path: []const u8, options: Options) !*File {68 pub fn openPath(allocator: *Allocator, dir: fs.Dir, sub_path: []const u8, options: Options) !*File {
69 switch (options.object_format) {69 switch (options.object_format) {
70 .unknown => unreachable,70 .unknown => unreachable,
71 .coff => return Coff.openPath(allocator, dir, sub_path, options),71 .coff, .pe => return Coff.openPath(allocator, dir, sub_path, options),
72 .elf => return Elf.openPath(allocator, dir, sub_path, options),72 .elf => return Elf.openPath(allocator, dir, sub_path, options),
73 .macho => return MachO.openPath(allocator, dir, sub_path, options),73 .macho => return MachO.openPath(allocator, dir, sub_path, options),
74 .wasm => return Wasm.openPath(allocator, dir, sub_path, options),74 .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 {...@@ -316,31 +316,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {
316 var code_buffer = std.ArrayList(u8).init(self.base.allocator);316 var code_buffer = std.ArrayList(u8).init(self.base.allocator);
317 defer code_buffer.deinit();317 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
334 const typed_value = decl.typed_value.most_recent.typed_value;319 const typed_value = decl.typed_value.most_recent.typed_value;
335 const res = try codegen.generateSymbol(320 const res = try codegen.generateSymbol(&self.base, decl.src(), typed_value, &code_buffer, .none);
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 );
344321
345 const code = switch (res) {322 const code = switch (res) {
346 .externally_managed => |x| x,323 .externally_managed => |x| x,
src-self-hosted/main.zig+3-6
...@@ -153,8 +153,8 @@ const usage_build_generic =...@@ -153,8 +153,8 @@ const usage_build_generic =
153 \\ elf Executable and Linking Format153 \\ elf Executable and Linking Format
154 \\ c Compile to C source code154 \\ c Compile to C source code
155 \\ wasm WebAssembly155 \\ wasm WebAssembly
156 \\ pe Portable Executable (Windows)
156 \\ coff (planned) Common Object File Format (Windows)157 \\ coff (planned) Common Object File Format (Windows)
157 \\ pe (planned) Portable Executable (Windows)
158 \\ macho (planned) macOS relocatables158 \\ macho (planned) macOS relocatables
159 \\ hex (planned) Intel IHEX159 \\ hex (planned) Intel IHEX
160 \\ raw (planned) Dump machine code directly160 \\ raw (planned) Dump machine code directly
...@@ -451,7 +451,7 @@ fn buildOutputType(...@@ -451,7 +451,7 @@ fn buildOutputType(
451 } else if (mem.eql(u8, ofmt, "coff")) {451 } else if (mem.eql(u8, ofmt, "coff")) {
452 break :blk .coff;452 break :blk .coff;
453 } else if (mem.eql(u8, ofmt, "pe")) {453 } else if (mem.eql(u8, ofmt, "pe")) {
454 break :blk .coff;454 break :blk .pe;
455 } else if (mem.eql(u8, ofmt, "macho")) {455 } else if (mem.eql(u8, ofmt, "macho")) {
456 break :blk .macho;456 break :blk .macho;
457 } else if (mem.eql(u8, ofmt, "wasm")) {457 } else if (mem.eql(u8, ofmt, "wasm")) {
...@@ -524,10 +524,7 @@ fn buildOutputType(...@@ -524,10 +524,7 @@ fn buildOutputType(
524 try stderr.print("\nUnable to parse command: {}\n", .{@errorName(err)});524 try stderr.print("\nUnable to parse command: {}\n", .{@errorName(err)});
525 continue;525 continue;
526 }) |line| {526 }) |line| {
527 const actual_line = if (line[line.len - 1] == '\r')527 const actual_line = mem.trimRight(u8, line, "\r\n ");
528 line[0 .. line.len - 1]
529 else
530 line;
531528
532 if (mem.eql(u8, actual_line, "update")) {529 if (mem.eql(u8, actual_line, "update")) {
533 if (output_mode == .Exe) {530 if (output_mode == .Exe) {