@@ -168,7 +168,7 @@ pub fn parseNameOrOrdinal(allocator: Allocator, reader: *std.Io.Reader) !NameOrO
168168}
169169
170170pub const CoffOptions = struct {
171- target : std.coff.MachineType = .X64 ,
171+ target : std.coff.IMAGE.FILE.MACHINE = .AMD64 ,
172172 /// If true, zeroes will be written to all timestamp fields
173173 reproducible : bool = true ,
174174 /// If true, the MEM_WRITE flag will not be set in the .rsrc section header
@@ -210,19 +210,19 @@ pub fn writeCoff(allocator: Allocator, writer: *std.Io.Writer, resources: []cons
210210 const lengths = resource_tree .dataLengths ();
211211 const byte_size_of_relocation = 10 ;
212212 const relocations_len : u32 = @intCast (byte_size_of_relocation * resources .len );
213- const pointer_to_rsrc01_data = @sizeOf (std .coff .CoffHeader ) + (@sizeOf (std .coff .SectionHeader ) * 2 );
213+ const pointer_to_rsrc01_data = @sizeOf (std .coff .Header ) + (@sizeOf (std .coff .SectionHeader ) * 2 );
214214 const pointer_to_relocations = pointer_to_rsrc01_data + lengths .rsrc01 ;
215215 const pointer_to_rsrc02_data = pointer_to_relocations + relocations_len ;
216216 const pointer_to_symbol_table = pointer_to_rsrc02_data + lengths .rsrc02 ;
217217
218218 const timestamp : i64 = if (options .reproducible ) 0 else std .time .timestamp ();
219219 const size_of_optional_header = 0 ;
220- const machine_type : std.coff.MachineType = options .target ;
221- const flags = std.coff.CoffHeaderFlags {
222- .@"32BIT_MACHINE" = 1 ,
220+ const machine_type : std.coff.IMAGE.FILE.MACHINE = options .target ;
221+ const flags = std.coff.Header.Flags {
222+ .@"32BIT_MACHINE" = true ,
223223 };
224224 const number_of_symbols = 5 + @as (u32 , @intCast (resources .len )) + @intFromBool (options .define_external_symbol != null );
225- const coff_header = std.coff.CoffHeader {
225+ const coff_header = std.coff.Header {
226226 .machine = machine_type ,
227227 .number_of_sections = 2 ,
228228 .time_date_stamp = @as (u32 , @truncate (@as (u64 , @bitCast (timestamp )))),
@@ -245,9 +245,9 @@ pub fn writeCoff(allocator: Allocator, writer: *std.Io.Writer, resources: []cons
245245 .number_of_relocations = @intCast (resources .len ),
246246 .number_of_linenumbers = 0 ,
247247 .flags = .{
248- .CNT_INITIALIZED_DATA = 1 ,
249- .MEM_WRITE = @intFromBool ( ! options .read_only ) ,
250- .MEM_READ = 1 ,
248+ .CNT_INITIALIZED_DATA = true ,
249+ .MEM_WRITE = ! options .read_only ,
250+ .MEM_READ = true ,
251251 },
252252 };
253253 try writer .writeStruct (rsrc01_header , .little );
@@ -263,9 +263,9 @@ pub fn writeCoff(allocator: Allocator, writer: *std.Io.Writer, resources: []cons
263263 .number_of_relocations = 0 ,
264264 .number_of_linenumbers = 0 ,
265265 .flags = .{
266- .CNT_INITIALIZED_DATA = 1 ,
267- .MEM_WRITE = @intFromBool ( ! options .read_only ) ,
268- .MEM_READ = 1 ,
266+ .CNT_INITIALIZED_DATA = true ,
267+ .MEM_WRITE = ! options .read_only ,
268+ .MEM_READ = true ,
269269 },
270270 };
271271 try writer .writeStruct (rsrc02_header , .little );
@@ -1005,9 +1005,9 @@ pub const supported_targets = struct {
10051005 x86_64 ,
10061006 aarch64 ,
10071007
1008- pub fn toCoffMachineType (arch : Arch ) std.coff.MachineType {
1008+ pub fn toCoffMachineType (arch : Arch ) std.coff.IMAGE.FILE.MACHINE {
10091009 return switch (arch ) {
1010- .x64 , .amd64 , .x86_64 = > .X64 ,
1010+ .x64 , .amd64 , .x86_64 = > .AMD64 ,
10111011 .x86 , .i386 = > .I386 ,
10121012 .arm , .armnt = > .ARMNT ,
10131013 .arm64 , .aarch64 = > .ARM64 ,
@@ -1079,26 +1079,26 @@ pub const supported_targets = struct {
10791079 };
10801080
10811081 // https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#type-indicators
1082- pub fn rvaRelocationTypeIndicator (target : std.coff.MachineType ) ? u16 {
1082+ pub fn rvaRelocationTypeIndicator (target : std.coff.IMAGE.FILE.MACHINE ) ? u16 {
10831083 return switch (target ) {
1084- .X64 = > 0x3 , // IMAGE_REL_AMD64_ADDR32NB
1085- .I386 = > 0x7 , // IMAGE_REL_I386_DIR32NB
1086- .ARMNT = > 0x2 , // IMAGE_REL_ARM_ADDR32NB
1087- .ARM64 , .ARM64EC , .ARM64X = > 0x2 , // IMAGE_REL_ARM64_ADDR32NB
1088- .IA64 = > 0x10 , // IMAGE_REL_IA64_DIR32NB
1084+ .AMD64 = > @intFromEnum ( std . coff . IMAGE . REL . AMD64 . ADDR32NB ),
1085+ .I386 = > @intFromEnum ( std . coff . IMAGE . REL . I386 . DIR32NB ),
1086+ .ARMNT = > @intFromEnum ( std . coff . IMAGE . REL . ARM . ADDR32NB ),
1087+ .ARM64 , .ARM64EC , .ARM64X = > @intFromEnum ( std . coff . IMAGE . REL . ARM64 . ADDR32NB ),
1088+ .IA64 = > @intFromEnum ( std . coff . IMAGE . REL . IA64 . DIR32NB ),
10891089 .EBC = > 0x1 , // This is what cvtres.exe writes for this target, unsure where it comes from
10901090 else = > null ,
10911091 };
10921092 }
10931093
1094- pub fn isSupported (target : std.coff.MachineType ) bool {
1094+ pub fn isSupported (target : std.coff.IMAGE.FILE.MACHINE ) bool {
10951095 return rvaRelocationTypeIndicator (target ) != null ;
10961096 }
10971097
10981098 comptime {
10991099 // Enforce two things:
11001100 // 1. Arch enum field names are all lowercase (necessary for how fromStringIgnoreCase is implemented)
1101- // 2. All enum fields in Arch have an associated RVA relocation type when converted to a coff.MachineType
1101+ // 2. All enum fields in Arch have an associated RVA relocation type when converted to a coff.IMAGE.FILE.MACHINE
11021102 for (@typeInfo (Arch ).@"enum" .fields ) | enum_field | {
11031103 const all_lower = all_lower : for (enum_field .name ) | c | {
11041104 if (std .ascii .isUpper (c )) break :all_lower false ;
0 commit comments