mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +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
1 changed files with 10 additions and 1 deletions
|
|
@ -1850,7 +1850,11 @@ const FileHeader = struct {
|
|||
return magic_number == std.macho.MH_MAGIC or
|
||||
magic_number == std.macho.MH_MAGIC_64 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 {
|
||||
|
|
@ -1875,6 +1879,11 @@ test FileHeader {
|
|||
h.bytes_read = 0;
|
||||
h.update(&macho64_magic_bytes);
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue