| ... | ... | @@ -34,6 +34,7 @@ const LoadCommand = union(enum) { |
| 34 | 34 | Dylib: macho.dylib_command, |
| 35 | 35 | EntryPoint: macho.entry_point_command, |
| 36 | 36 | MinVersion: macho.version_min_command, |
| 37 | SourceVersion: macho.source_version_command, |
| 37 | 38 | |
| 38 | 39 | pub fn cmdsize(self: LoadCommand) u32 { |
| 39 | 40 | return switch (self) { |
| ... | ... | @@ -46,6 +47,7 @@ const LoadCommand = union(enum) { |
| 46 | 47 | .Dylib => |x| x.cmdsize, |
| 47 | 48 | .EntryPoint => |x| x.cmdsize, |
| 48 | 49 | .MinVersion => |x| x.cmdsize, |
| 50 | .SourceVersion => |x| x.cmdsize, |
| 49 | 51 | }; |
| 50 | 52 | } |
| 51 | 53 | |
| ... | ... | @@ -60,6 +62,7 @@ const LoadCommand = union(enum) { |
| 60 | 62 | .Dylib => |cmd| writeGeneric(cmd, file, offset), |
| 61 | 63 | .EntryPoint => |cmd| writeGeneric(cmd, file, offset), |
| 62 | 64 | .MinVersion => |cmd| writeGeneric(cmd, file, offset), |
| 65 | .SourceVersion => |cmd| writeGeneric(cmd, file, offset), |
| 63 | 66 | }; |
| 64 | 67 | } |
| 65 | 68 | |
| ... | ... | @@ -101,6 +104,8 @@ function_starts_cmd_index: ?u16 = null, |
| 101 | 104 | main_cmd_index: ?u16 = null, |
| 102 | 105 | /// Minimum OS version |
| 103 | 106 | version_min_cmd_index: ?u16 = null, |
| 107 | /// Source version |
| 108 | source_version_cmd_index: ?u16 = null, |
| 104 | 109 | |
| 105 | 110 | /// Table of all sections |
| 106 | 111 | sections: std.ArrayListUnmanaged(macho.section_64) = .{}, |
| ... | ... | @@ -1377,6 +1382,16 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 1377 | 1382 | }, |
| 1378 | 1383 | }); |
| 1379 | 1384 | } |
| 1385 | if (self.source_version_cmd_index == null) { |
| 1386 | self.source_version_cmd_index = @intCast(u16, self.load_commands.items.len); |
| 1387 | try self.load_commands.append(self.base.allocator, .{ |
| 1388 | .SourceVersion = .{ |
| 1389 | .cmd = macho.LC_SOURCE_VERSION, |
| 1390 | .cmdsize = @sizeOf(macho.source_version_command), |
| 1391 | .version = 0x0, |
| 1392 | }, |
| 1393 | }); |
| 1394 | } |
| 1380 | 1395 | { |
| 1381 | 1396 | const linkedit = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; |
| 1382 | 1397 | const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfo; |