aboutsummaryrefslogtreecommitdiff
path: root/src/link/Elf/Object.zig
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2024-08-19 13:25:08 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2024-08-23 19:56:24 +0200
commita69f55a7cc3980f4d4dfcce6cb9d21a597975c7f (patch)
treea3ec23392b88a7d9e9a2fa9cb99f21d5c2cc6b9f /src/link/Elf/Object.zig
parent3fb6e46f6e4231b9569193a15a4357a2ae11fb0f (diff)
downloadzig-a69f55a7cc3980f4d4dfcce6cb9d21a597975c7f.tar.gz
zig-a69f55a7cc3980f4d4dfcce6cb9d21a597975c7f.zip
std.{coff,elf}: Remove the {MachineType,EM}.toTargetCpuArch() functions.
These are fundamentally incapable of producing accurate information for reasons I've laid out in #20771. Since our only use of these functions is to check that object files have the correct machine type, and since #21020 made `std.Target.to{Coff,Elf}Machine()` more accurate, just switch these checks over to that and compare the machine type tags instead. Closes #20771.
Diffstat (limited to 'src/link/Elf/Object.zig')
-rw-r--r--src/link/Elf/Object.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/link/Elf/Object.zig b/src/link/Elf/Object.zig
index a6f9c4ac18..d329218b8d 100644
--- a/src/link/Elf/Object.zig
+++ b/src/link/Elf/Object.zig
@@ -105,12 +105,12 @@ fn parseCommon(self: *Object, allocator: Allocator, handle: std.fs.File, elf_fil
defer allocator.free(header_buffer);
self.header = @as(*align(1) const elf.Elf64_Ehdr, @ptrCast(header_buffer)).*;
- const target = elf_file.base.comp.root_mod.resolved_target.result;
- if (target.cpu.arch != self.header.?.e_machine.toTargetCpuArch().?) {
+ const em = elf_file.base.comp.root_mod.resolved_target.result.toElfMachine();
+ if (em != self.header.?.e_machine) {
try elf_file.reportParseError2(
self.index,
- "invalid cpu architecture: {s}",
- .{@tagName(self.header.?.e_machine.toTargetCpuArch().?)},
+ "invalid ELF machine type: {s}",
+ .{@tagName(self.header.?.e_machine)},
);
return error.InvalidCpuArch;
}