commit 274400c57d97dc4ea8fff5a6f516feac93eca4e0 (tree) parent 71cc2e67593fb5da38e84900ef4c409f6aa99b94 Author: Jakub Konka <kubkon@jakubkonka.com> Date: Fri, 18 Aug 2023 11:55:29 +0200 macho: add helper for accessing tools array in LC_BUILD_VERSION cmd Diffstat:
| M | lib/std/macho.zig | | | 10 | ++++++++++ |
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/lib/std/macho.zig b/lib/std/macho.zig @@ -1898,6 +1898,16 @@ pub const LoadCommandIterator = struct { const data = lc.data[rpath_lc.path..]; return mem.sliceTo(data, 0); } + + /// Asserts LoadCommand is of type build_version_command. + pub fn getBuildVersionTools(lc: LoadCommand) []const build_tool_version { + const build_lc = lc.cast(build_version_command).?; + const ntools = build_lc.ntools; + if (ntools == 0) return &[0]build_tool_version{}; + const data = lc.data[@sizeOf(build_version_command)..]; + const tools = @as([*]const build_tool_version, @ptrCast(@alignCast(&data[0])))[0..ntools]; + return tools; + } }; pub fn next(it: *LoadCommandIterator) ?LoadCommand {