-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const Coff = @This(); | ||
|
||
const std = @import("std"); | ||
const assert = std.debug.assert; | ||
const coff = std.coff; | ||
const fs = std.fs; | ||
const log = std.log.scoped(.coff); | ||
const mem = std.mem; | ||
|
||
const Allocator = mem.Allocator; | ||
const Zld = @import("Zld.zig"); | ||
|
||
pub const base_tag = Zld.Tag.coff; | ||
|
||
base: Zld, | ||
|
||
pub fn openPath(allocator: *Allocator, options: Zld.Options) !*Coff { | ||
const file = try options.emit.directory.createFile(options.emit.sub_path, .{ | ||
.truncate = true, | ||
.read = true, | ||
.mode = if (std.Target.current.os.tag == .windows) 0 else 0o777, | ||
}); | ||
errdefer file.close(); | ||
|
||
const self = try createEmpty(allocator, options); | ||
errdefer allocator.destroy(self); | ||
|
||
self.base.file = file; | ||
|
||
return self; | ||
} | ||
|
||
fn createEmpty(gpa: *Allocator, options: Zld.Options) !*Coff { | ||
const self = try gpa.create(Coff); | ||
|
||
self.* = .{ | ||
.base = .{ | ||
.tag = .coff, | ||
.options = options, | ||
.allocator = gpa, | ||
.file = undefined, | ||
}, | ||
}; | ||
|
||
return self; | ||
} | ||
|
||
pub fn deinit(self: *Coff) void { | ||
_ = self; | ||
} | ||
|
||
pub fn closeFiles(self: Coff) void { | ||
_ = self; | ||
} | ||
|
||
pub fn flush(self: *Coff) !void { | ||
_ = self; | ||
return error.TODOFlushInCoffLinker; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters