VTOOL(1) | General Commands Manual | VTOOL(1) |
vtool
— Mach-O
version number utility
vtool |
[-arch ⟨arch⟩]
...
⟨show command⟩
... file |
vtool |
[-arch ⟨arch⟩]
...
⟨set command⟩
... [-replace ]
-output out_file
file |
vtool |
[-arch ⟨arch⟩]
...
⟨remove command⟩
... -output
out_file file |
vtool |
-help |
The vtool
utility displays and edits build
and source version numbers embedded in the Mach-O(5) file
format. These version numbers are stored within the Mach-O load commands, as
described in the ⟨mach-o/loader.h⟩
header file and in the VERSION
LOAD COMMANDS section below. When editing files, a new
out_file must be specified using the
-output
flag; vtool
will
only ever write to a single output file, and input files are never modified
in place.
vtool
operates in one of three
functional modes (in addition to a
help mode) depending
on the type of arguments specified on the command line:
show,
set, and
remove.
All of these modes operate on “universal” (multi-architecture)
files as well as ordinary Mach-O files. The -arch
flag limits operation to one or more architectures within a universal
file.
-show
,
-show-build
, -show-source
,
and -show-space
. Only one of these commands may be
specified. The version information will be printed in a manner similar to
otool(1) or otool-classic(1).-set-build-tool
,
-set-build-version
,
-set-source-version
, and
-set-version-min
. Any number of these commands can
be combined in a single vtool
invocation. You can
use these set commands to add a new build version to a Mach-O or to
replace an existing version for a specific platform. When used with the
-replace
option, all existing build versions will
be entirely replaced by the new build versions specified on the command
line.-remove-build-tool
,
-remove-build-version
, and
-remove-source-version
. Any number of these
commands can be combined in a single vtool
invocation.Currently vtool
only operates on final
linked binaries, such as executable files, dynamic libraries, and bundles.
Because the executable code in Mach-O final linked binaries cannot be moved
or resized, and because the load commands reside between the mach header and
the executable code, there is only a limited amount of space available for
vtool
to save changes. Set operations that add or
resize load commands may fail if there isn't enough space in the Mach-O file
availble to hold the new load commands.
-arch
⟨arch⟩vtool
to operate on when the file is a universal
(multi-architecture) file. See arch(3) for the current
list of architectures. More than one architecture can be specified, and by
default vtool
will operate on all architectures in
a universal file.-h
,
-help
-o
,
-output
out_file-output
flag. This option is
required for all set and remove commands.-r
,
-replace
-set-build-version
or
-set-version-min
the
-replace
option instructs
vtool
to discard all of the existing build
versions from the input file. Use this to change a file's platform in a
single call to vtool
. When used with the
-set-build-tool
command,
vtool
will discard all of the existing tool
versions from the specified platform's build version. This option has no
effect on source versions.-remove-build-tool
platform toolLC_BUILD_VERSION
. Must be used with
-output
. See
VERSION LOAD COMMANDS for
more information on platform and tool values.-remove-build-version
platform-output
. See
VERSION LOAD COMMANDS for
more information on platform values.-remove-source-version
-output
.-set-build-tool
platform tool version-output
. See
VERSION LOAD COMMANDS for
more information on platform and tool values.-set-build-version
platform minos sdk [-tool
tool version]-output
. See
VERSION LOAD COMMANDS for
more information on platform and tool values.-set-source-version
version-output
.-set-version-min
platform minos sdk-set-build-version
instead. Note that version min
load commands do not support tool versions, and not all platforms can be
expressed using version min load commands. Must be used with
-output
.-show
,
-show-all
-show-build
-show-source
-show-space
-
vtool
to stop parsing
arguments. This is useful for operating on files whose names would
otherwise be interpreted as an option or flag.Modern Mach-O files can contain multiple build versions, one for
each unqiue
platform
represented in the file. A platform is a loosely-defined concept within
Mach-O, most often used to identify different Darwin operating systems, such
as macOS
and iOS.
Platforms and tools can be specified either by name (e.g., "macos"
or "clang") or by number (e.g., "1"). Common platform
and tool constants are defined in
⟨mach-o/loader.h⟩ and
vtool
will display platform and tool names when
invoked with -help
.
Modern Mach-O files store build information in one or more
LC_BUILD_VERSION
load commands.
LC_BUILD_VERSION
supports arbitrary platforms and
can include version information about the tools used to build the Mach-O
file. Older Mach-O files use a “version min” load command,
such as LC_VERSION_MIN_MACOSX
. While version min
commands are appropriate when deploying Mach-O files on older operating
systems, be aware that they do not support tool versions, and version min
load commands do not exist for all possible platforms. In some cases
LC_BUILD_VERSION
and
LC_VERSION_MIN_*
load commands can appear in a
single Mach-O file, but many restrictions apply, and
vtool
may not enforce these restrictions.
vtool
will prevent you from writing more than one
build version load command for the same platform.
Source versions are stored in a single
LC_SOURCE_VERSION
load command.
When writing new load commands, vtool
will
attempt to preserve the order of the load commands as they appear on the
command line. No attempt is made to preserve positions relative to other
existing load commands. Editing an existing load command may have the side
effect of moving the load command to the end of the load command list.
LC_BUILD_VERSION first appeared in macOS 10.13 in 2017 for use with the bridgeOS platform.
LC_BUILD_VERSION became the default build version load command for the macOS, iOS, tvOS, and watchOS platforms in 2018 with macOS 10.14, iOS 12.0, and friends. The list of platforms also grew to include iOSSimulator, tvOSSimulator, and watchOSSimulator.
vtool
first appeared in macOS 10.15 and
iOS 13.0 in 2019.
vtool
will write load commands in a
different order than ld(1).
Currently vtool
does not work with object
files or archives.
December 31, 2018 | Darwin |