| ... | ... | @@ -729,15 +729,19 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod |
| 729 | 729 | index += 2; |
| 730 | 730 | |
| 731 | 731 | // Characteristics |
| 732 | | var characteristics: u16 = std.coff.IMAGE_FILE_DEBUG_STRIPPED | std.coff.IMAGE_FILE_RELOCS_STRIPPED; // TODO Remove debug info stripped flag when necessary |
| 732 | var flags: std.coff.CoffHeaderFlags = .{ |
| 733 | // TODO Remove debug info stripped flag when necessary |
| 734 | .DEBUG_STRIPPED = 1, |
| 735 | .RELOCS_STRIPPED = 1, |
| 736 | }; |
| 733 | 737 | if (output_mode == .Exe) { |
| 734 | | characteristics |= std.coff.IMAGE_FILE_EXECUTABLE_IMAGE; |
| 738 | flags.EXECUTABLE_IMAGE = 1; |
| 735 | 739 | } |
| 736 | 740 | switch (self.ptr_width) { |
| 737 | | .p32 => characteristics |= std.coff.IMAGE_FILE_32BIT_MACHINE, |
| 738 | | .p64 => characteristics |= std.coff.IMAGE_FILE_LARGE_ADDRESS_AWARE, |
| 741 | .p32 => flags.@"32BIT_MACHINE" = 1, |
| 742 | .p64 => flags.LARGE_ADDRESS_AWARE = 1, |
| 739 | 743 | } |
| 740 | | mem.writeIntLittle(u16, hdr_data[index..][0..2], characteristics); |
| 744 | mem.writeIntLittle(u16, hdr_data[index..][0..2], @bitCast(u16, flags)); |
| 741 | 745 | index += 2; |
| 742 | 746 | |
| 743 | 747 | assert(index == 20); |
| ... | ... | @@ -877,7 +881,10 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod |
| 877 | 881 | mem.set(u8, hdr_data[index..][0..12], 0); |
| 878 | 882 | index += 12; |
| 879 | 883 | // Section flags |
| 880 | | mem.writeIntLittle(u32, hdr_data[index..][0..4], std.coff.IMAGE_SCN_CNT_INITIALIZED_DATA | std.coff.IMAGE_SCN_MEM_READ); |
| 884 | mem.writeIntLittle(u32, hdr_data[index..][0..4], @bitCast(u32, std.coff.SectionHeaderFlags{ |
| 885 | .CNT_INITIALIZED_DATA = 1, |
| 886 | .MEM_READ = 1, |
| 887 | })); |
| 881 | 888 | index += 4; |
| 882 | 889 | // Then, the .text section |
| 883 | 890 | hdr_data[index..][0..8].* = ".text\x00\x00\x00".*; |
| ... | ... | @@ -903,11 +910,12 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod |
| 903 | 910 | mem.set(u8, hdr_data[index..][0..12], 0); |
| 904 | 911 | index += 12; |
| 905 | 912 | // Section flags |
| 906 | | mem.writeIntLittle( |
| 907 | | u32, |
| 908 | | hdr_data[index..][0..4], |
| 909 | | std.coff.IMAGE_SCN_CNT_CODE | std.coff.IMAGE_SCN_MEM_EXECUTE | std.coff.IMAGE_SCN_MEM_READ | std.coff.IMAGE_SCN_MEM_WRITE, |
| 910 | | ); |
| 913 | mem.writeIntLittle(u32, hdr_data[index..][0..4], @bitCast(u32, std.coff.SectionHeaderFlags{ |
| 914 | .CNT_CODE = 1, |
| 915 | .MEM_EXECUTE = 1, |
| 916 | .MEM_READ = 1, |
| 917 | .MEM_WRITE = 1, |
| 918 | })); |
| 911 | 919 | index += 4; |
| 912 | 920 | |
| 913 | 921 | assert(index == optional_header_size + section_table_size); |