aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/link/Coff.zig29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index a01b9cf7c3..6536fbd1ac 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -204,15 +204,18 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option
index += 2;
// Characteristics
- var characteristics: u16 = std.coff.IMAGE_FILE_DEBUG_STRIPPED | std.coff.IMAGE_FILE_RELOCS_STRIPPED; // TODO Remove debug info stripped flag when necessary
+ var characteristics: std.coff.CoffHeaderFlags = .{
+ .DEBUG_STRIPPED = 1, // TODO remove debug info stripped flag when necessary
+ .RELOCS_STRIPPED = 1,
+ };
if (options.output_mode == .Exe) {
- characteristics |= std.coff.IMAGE_FILE_EXECUTABLE_IMAGE;
+ characteristics.EXECUTABLE_IMAGE = 1;
}
switch (self.ptr_width) {
- .p32 => characteristics |= std.coff.IMAGE_FILE_32BIT_MACHINE,
- .p64 => characteristics |= std.coff.IMAGE_FILE_LARGE_ADDRESS_AWARE,
+ .p32 => characteristics.@"32BIT_MACHINE" = 1,
+ .p64 => characteristics.LARGE_ADDRESS_AWARE = 1,
}
- mem.writeIntLittle(u16, hdr_data[index..][0..2], characteristics);
+ mem.writeIntLittle(u16, hdr_data[index..][0..2], @bitCast(u16, characteristics));
index += 2;
assert(index == 20);
@@ -352,7 +355,10 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option
mem.set(u8, hdr_data[index..][0..12], 0);
index += 12;
// Section flags
- mem.writeIntLittle(u32, hdr_data[index..][0..4], std.coff.IMAGE_SCN_CNT_INITIALIZED_DATA | std.coff.IMAGE_SCN_MEM_READ);
+ mem.writeIntLittle(u32, hdr_data[index..][0..4], @bitCast(u32, std.coff.SectionHeaderFlags{
+ .CNT_INITIALIZED_DATA = 1,
+ .MEM_READ = 1,
+ }));
index += 4;
// Then, the .text section
hdr_data[index..][0..8].* = ".text\x00\x00\x00".*;
@@ -378,11 +384,12 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option
mem.set(u8, hdr_data[index..][0..12], 0);
index += 12;
// Section flags
- mem.writeIntLittle(
- u32,
- hdr_data[index..][0..4],
- std.coff.IMAGE_SCN_CNT_CODE | std.coff.IMAGE_SCN_MEM_EXECUTE | std.coff.IMAGE_SCN_MEM_READ | std.coff.IMAGE_SCN_MEM_WRITE,
- );
+ mem.writeIntLittle(u32, hdr_data[index..][0..4], @bitCast(u32, std.coff.SectionHeaderFlags{
+ .CNT_CODE = 1,
+ .MEM_EXECUTE = 1,
+ .MEM_READ = 1,
+ .MEM_WRITE = 1,
+ }));
index += 4;
assert(index == optional_header_size + section_table_size);