Merge pull request #25981 from mlugg/macos-fuzz-2

make the fuzzer vaguely work on macOS
This commit is contained in:
Matthew Lugg
2025-11-20 17:48:35 +00:00
committed by GitHub
21 changed files with 876 additions and 534 deletions
+2 -2
View File
@@ -4167,7 +4167,7 @@ pub const Platform = struct {
/// Using Apple's ld64 as our blueprint, `min_version` as well as `sdk_version` are set to
/// the extracted minimum platform version.
pub fn fromLoadCommand(lc: macho.LoadCommandIterator.LoadCommand) Platform {
switch (lc.cmd()) {
switch (lc.hdr.cmd) {
.BUILD_VERSION => {
const cmd = lc.cast(macho.build_version_command).?;
return .{
@@ -4200,7 +4200,7 @@ pub const Platform = struct {
// We can't distinguish Mac Catalyst here, but this is legacy stuff anyway.
const cmd = lc.cast(macho.version_min_command).?;
return .{
.os_tag = switch (lc.cmd()) {
.os_tag = switch (lc.hdr.cmd) {
.VERSION_MIN_IPHONEOS => .ios,
.VERSION_MIN_MACOSX => .macos,
.VERSION_MIN_TVOS => .tvos,
+2 -5
View File
@@ -90,11 +90,8 @@ fn parseBinary(self: *Dylib, macho_file: *MachO) !void {
if (amt != lc_buffer.len) return error.InputOutput;
}
var it = LoadCommandIterator{
.ncmds = header.ncmds,
.buffer = lc_buffer,
};
while (it.next()) |cmd| switch (cmd.cmd()) {
var it = LoadCommandIterator.init(&header, lc_buffer) catch |err| std.debug.panic("bad dylib: {t}", .{err});
while (it.next() catch |err| std.debug.panic("bad dylib: {t}", .{err})) |cmd| switch (cmd.hdr.cmd) {
.ID_DYLIB => {
self.id = try Id.fromLoadCommand(gpa, cmd.cast(macho.dylib_command).?, cmd.getDylibPathName());
},
+4 -10
View File
@@ -109,11 +109,8 @@ pub fn parse(self: *Object, macho_file: *MachO) !void {
if (amt != self.header.?.sizeofcmds) return error.InputOutput;
}
var it = LoadCommandIterator{
.ncmds = self.header.?.ncmds,
.buffer = lc_buffer,
};
while (it.next()) |lc| switch (lc.cmd()) {
var it = LoadCommandIterator.init(&self.header.?, lc_buffer) catch |err| std.debug.panic("bad object: {t}", .{err});
while (it.next() catch |err| std.debug.panic("bad object: {t}", .{err})) |lc| switch (lc.hdr.cmd) {
.SEGMENT_64 => {
const sections = lc.getSections();
try self.sections.ensureUnusedCapacity(gpa, sections.len);
@@ -1644,11 +1641,8 @@ pub fn parseAr(self: *Object, macho_file: *MachO) !void {
if (amt != self.header.?.sizeofcmds) return error.InputOutput;
}
var it = LoadCommandIterator{
.ncmds = self.header.?.ncmds,
.buffer = lc_buffer,
};
while (it.next()) |lc| switch (lc.cmd()) {
var it = LoadCommandIterator.init(&self.header.?, lc_buffer) catch |err| std.debug.panic("bad object: {t}", .{err});
while (it.next() catch |err| std.debug.panic("bad object: {t}", .{err})) |lc| switch (lc.hdr.cmd) {
.SYMTAB => {
const cmd = lc.cast(macho.symtab_command).?;
try self.strtab.resize(gpa, cmd.strsize);