mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Merge pull request #23193 from mlafeldt/fix-macho-detection
Fetch: enhance Mach-O executable detection for modern Macs closes #21044
This commit is contained in:
parent
5ffd8bf5f6
commit
7e751e8040
@ -1850,7 +1850,11 @@ const FileHeader = struct {
|
|||||||
return magic_number == std.macho.MH_MAGIC or
|
return magic_number == std.macho.MH_MAGIC or
|
||||||
magic_number == std.macho.MH_MAGIC_64 or
|
magic_number == std.macho.MH_MAGIC_64 or
|
||||||
magic_number == std.macho.FAT_MAGIC or
|
magic_number == std.macho.FAT_MAGIC or
|
||||||
magic_number == std.macho.FAT_MAGIC_64;
|
magic_number == std.macho.FAT_MAGIC_64 or
|
||||||
|
magic_number == std.macho.MH_CIGAM or
|
||||||
|
magic_number == std.macho.MH_CIGAM_64 or
|
||||||
|
magic_number == std.macho.FAT_CIGAM or
|
||||||
|
magic_number == std.macho.FAT_CIGAM_64;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn isExecutable(self: *FileHeader) bool {
|
pub fn isExecutable(self: *FileHeader) bool {
|
||||||
@ -1875,6 +1879,11 @@ test FileHeader {
|
|||||||
h.bytes_read = 0;
|
h.bytes_read = 0;
|
||||||
h.update(&macho64_magic_bytes);
|
h.update(&macho64_magic_bytes);
|
||||||
try std.testing.expect(h.isExecutable());
|
try std.testing.expect(h.isExecutable());
|
||||||
|
|
||||||
|
const macho64_cigam_bytes = [_]u8{ 0xFE, 0xED, 0xFA, 0xCF };
|
||||||
|
h.bytes_read = 0;
|
||||||
|
h.update(&macho64_cigam_bytes);
|
||||||
|
try std.testing.expect(h.isExecutable());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result of the `unpackResource` operation. Enables collecting errors from
|
// Result of the `unpackResource` operation. Enables collecting errors from
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user