| author | |
| committer | |
| log | ac9ca7d30c03f3111b6bb0a0bacade97d1f6f6df |
| tree | 7aca7bd412b8ed9e823c74332e174e4bc1fad980 |
| parent | 65affb1c225a034058fb2cbe32c289019b463ebf |
| signature |
This does the same thing as std.Target.Cpu.Arch.toCoffMachine(). Just use that.2 files changed, 1 insertions(+), 18 deletions(-)
lib/std/coff.zig-17| ... | @@ -1061,23 +1061,6 @@ pub const MachineType = enum(u16) { | ... | @@ -1061,23 +1061,6 @@ pub const MachineType = enum(u16) { |
| 1061 | 1061 | ||
| 1062 | _, | 1062 | _, |
| 1063 | 1063 | ||
| 1064 | pub fn fromTargetCpuArch(arch: std.Target.Cpu.Arch) MachineType { | ||
| 1065 | return switch (arch) { | ||
| 1066 | .arm => .ARM, | ||
| 1067 | .powerpc => .POWERPC, | ||
| 1068 | .riscv32 => .RISCV32, | ||
| 1069 | .thumb => .Thumb, | ||
| 1070 | .x86 => .I386, | ||
| 1071 | .aarch64 => .ARM64, | ||
| 1072 | .riscv64 => .RISCV64, | ||
| 1073 | .x86_64 => .X64, | ||
| 1074 | .loongarch32 => .LOONGARCH32, | ||
| 1075 | .loongarch64 => .LOONGARCH64, | ||
| 1076 | // there's cases we don't (yet) handle | ||
| 1077 | else => unreachable, | ||
| 1078 | }; | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | pub fn toTargetCpuArch(machine_type: MachineType) ?std.Target.Cpu.Arch { | 1064 | pub fn toTargetCpuArch(machine_type: MachineType) ?std.Target.Cpu.Arch { |
| 1082 | return switch (machine_type) { | 1065 | return switch (machine_type) { |
| 1083 | .ARM => .arm, | 1066 | .ARM => .arm, |
src/link/Coff.zig+1-1| ... | @@ -2259,7 +2259,7 @@ fn writeHeader(self: *Coff) !void { | ... | @@ -2259,7 +2259,7 @@ fn writeHeader(self: *Coff) !void { |
| 2259 | const timestamp = if (self.repro) 0 else std.time.timestamp(); | 2259 | const timestamp = if (self.repro) 0 else std.time.timestamp(); |
| 2260 | const size_of_optional_header = @as(u16, @intCast(self.getOptionalHeaderSize() + self.getDataDirectoryHeadersSize())); | 2260 | const size_of_optional_header = @as(u16, @intCast(self.getOptionalHeaderSize() + self.getDataDirectoryHeadersSize())); |
| 2261 | var coff_header = coff.CoffHeader{ | 2261 | var coff_header = coff.CoffHeader{ |
| 2262 | .machine = coff.MachineType.fromTargetCpuArch(target.cpu.arch), | 2262 | .machine = target.cpu.arch.toCoffMachine(), |
| 2263 | .number_of_sections = @as(u16, @intCast(self.sections.slice().len)), // TODO what if we prune a section | 2263 | .number_of_sections = @as(u16, @intCast(self.sections.slice().len)), // TODO what if we prune a section |
| 2264 | .time_date_stamp = @as(u32, @truncate(@as(u64, @bitCast(timestamp)))), | 2264 | .time_date_stamp = @as(u32, @truncate(@as(u64, @bitCast(timestamp)))), |
| 2265 | .pointer_to_symbol_table = self.strtab_offset orelse 0, | 2265 | .pointer_to_symbol_table = self.strtab_offset orelse 0, |