KEXTUTIL(8) | System Manager's Manual | KEXTUTIL(8) |
kextutil
— load,
diagnose problems with, and generate symbols for kernel extensions
(kexts)
kextutil |
[options] [-- ]
[kext] ... |
The kextutil
utility has been deprecated.
Please use the kmutil(8) equivalents:
kmutil load, or kmutil print-diagnostics.
The kextutil
program is used to explicitly
load kernel extensions (kexts), diagnose problems with kexts, and to
generate symbol files for debugging kexts. In order to load a kext into the
kernel kextutil
must run as the superuser; for all
other uses it can run as any user.
kextutil
is the developer utility for kext
loading in the Darwin OS and in macOS. Software and installers should use
kextload(8) instead of this
program.
The arguments and options available are these:
-bundle-id
option.-a
identifier@address, -address
identifier@address-no-load
option. See also
-use-load-addresses
and
-no-load
.-arch
-A
,
-use-load-addresses
-no-load
option. See also
-address
and
-no-load
.-b
identifier, -bundle-id
identifier-dependency
,
-no-system-extensions
, and
-repository
options for more information.-c
,
-no-caches
kextutil
attempts to use cache files and (when running as root) to create them if
they are out of date or don't exist.-d
kext, -dependency
kext-no-system-extensions
and -repository
options.-e
,
-no-system-extensions
-dependency
and
-repository
options. See “Explicitly
Specifying Dependencies” for more information.-h
,
-help
-i
,
-interactive
-I
,
-interactive-all
-k
kernel_file, -kernel
kernel_file-no-load
option to generate debug
symbols. By default kextutil
attempts to get link
symbols from the kernel at /System/Library/Kernels/kernel.-l
,
-load-only
-m
,
-match-only
-load-only
and after setting up the debugger.-n
,
-no-load
-symbols
option, or when diagnosing kexts with the
-print-diagnostics
option. For convenience in
development, this option implies the
-no-authentication
option. See also the
-address
and
-use-load-addresses
options.-p
personality, -personality
personality-interactive
option to have kextutil
ask for each
personality.-q
,
-quiet
kextutil
is run with
-quiet
in a way that might require user
interaction, as with the -interactive
and
-interactive-all
options, and some uses of
-no-load
, the program silently exits with an error
status.-r
directory, -repository
directory-bundle-id
option. This is not recursive; only the directory's immediate contents
(and their plugins) are scanned. See “Explicitly Specifying
Dependencies” for more information, as well as the
-dependency
and
-no-system-extensions
options.-s
directory, -symbols
directory-t
,
-print-diagnostics
-v
[0-6
|
0x####
],
-verbose
[0-6
|
0x####
]kextutil
prints only warnings and errors. You can
specify a level from 0-6, or a hexadecimal log specification (as described
in
kext_logging(8)).
The levels of verbose output are:
-quiet
.To ease debug loading of kexts, the verbose levels 1-6 in
kextutil
implicitly set the
OSBundleEnableKextLogging property for each kext specified on the
command line to true. See
kext_logging(8) for more
information on verbose logging.
-x
,
-safe-boot
kextutil
as if in safe boot mode (indicating
startup with the Shift key held down). Kexts that don't specify a proper
value for the OSBundleRequired info dictionary property will not load.
This option implies the use of the -no-caches
option.
Note that if the system has actually started up in safe boot mode, this option is redundant. There is no way to simulate non-safe boot mode for a system running in safe boot mode.
-z
,
-no-authentication
-Z
,
-no-resolve-dependencies
-no-load
and
-print-diagnostics
options to test a kext for
problems. It is not allowed with the -symbols
option as generating symbols requires dependencies to be resolved.--
Here are the common uses and usage patterns for
kextutil
.
To load a kext you must run kextutil
as
the superuser and supply a kext bundle name; no options are required:
kextutil TabletDriver.kext
Alternatively, you can use the -bundle-id
(-b
) option to specify a kext by its
CFBundleIdentifier:
kextutil -b com.mycompany.driver.TabletDriver
With no additional options kextutil
looks
in /System/Library/Extensions/ and
/Library/Extensions/ for a kext with the given
CFBundleIdentifier. Adding repository directories with the
-repository
(-r
) option or
individual kexts with the -dependency
(-d
) option expands the set of kexts that
kextutil
looks among:
kextutil -r ${USER}/Library/Extensions TabletDriver.kext
kextutil
prints diagnostic information
about kexts by default, but some options cause certain tests to be skipped.
The ensure that all tests are performed, use the
-print-diagnostics
(-t
)
option.
The -print-diagnostics
option is typically
used with -no-load
(-n
)
after a load failure to pinpoint a problem. It can be used with any other
set of options, however.
If you want to validate a kext in isolation, as in a build
environment where dependencies may not be available, you can use the
-no-system-extensions
(-e
)
and -no-resolve-dependencies
(-Z
) options to omit the
/System/Library/Extensions/ and
/Library/Extensions/ repositories and to suppress
dependency resolution, respectively:
kextutil -entZ PacketSniffer.kext
Only validation and authentication checks are performed.
To generate a symbol file for use with gdb when loading a kext,
use the -symbols
(-s
) option
to specify a directory where symbol files will be written for the kext being
loaded and all its dependencies.
kextutil -s ~/ksyms PacketSniffer.kext
If you want to generate symbols for a kext that's already loaded,
whether on the same system or on another, use the
-symbols
(-s
) option along
with the -no-load
(-n
)
option. Since in this case addresses must be known for the kext and all its
dependencies, though, you must specify them. If you don't indicate them on
the command line, kextutil
asks for the load address
of each kext needed. To get these addresses you can use
kextstat(8) on the machine you're
generating symbols for, the
showallkmods
gdb(1) macro defined by the
kgmacros file in the Kernel Development Kit, or
consult a panic backtrace.
kextutil -n -s ~/ksyms GrobbleEthernet.kext enter the hexadecimal load addresses for these modules: com.apple.iokit.IONetworkingFamily: 0x1001000 ...
Alternatively, if you know the CFBundleIdentifiers of all the
kexts, you can use the -address
(-a
) option for each kext (you needn't specify
-no-load
when using the
-address
option):
kextutil -s ~/ksyms \ -a com.apple.iokit.IONetworkingFamily@0x1001000 \ -a com.apple.iokit.IOPCIFamily@0x1004000 \ -a com.mycompany.driver.GrobbleEthernet@0x1007000 \ GrobbleEthernet.kext
Simplest of all, however, provided you can run
kextutil
on the same machine as the loaded kext, is
to use the -use-load-addresses
(-A
) option, which checks with the kernel for all
loaded kexts and automatically gets their load addresses.
kextutil -s ~/ksyms -A GrobbleEthernet.kext
Because kextutil
resolves dependencies
automatically, it's possible that a kext other than the one you intend might
get used as a dependency (as when there are multiple copies of the same
version, or if you're working with a different version of a kext that's
already in /System/Library/Extensions/). By default,
when loading a kext into the kernel, kextutil
checks
which versions of possible dependencies are already loaded in order to
assure a successful load. When not loading and not using
-use-load-addresses
, however, it always chooses the
highest versions of any dependencies, and in the case of a tie it chooses
from kexts specified on the command line using the
-dependency
or -repository
options, or as command line arguments (in decreasing order of priority).
For precise control over the set of extensions used to resolve
dependencies, use the -no-system-extensions
(-e
) option along with the
-dependency
(-d
),
and
-repository
(-r
) options.
The -no-system-extensions
option excludes the
standard /System/Library/Extensions/ and
/Library/Extensions/ directories, leaving the set of
candidate extensions for dependency resolution entirely up to you. To
specify candidate dependencies you use either
-dependency
(-d
),
which names a single
kext as a candidate, or -repository
(-r
),
which adds an entire
directory of extensions.
kextutil -n -s ~/ksyms -e \ -d /System/Library/Extensions/System.kext \ -r ~/TestKexts -d JoystickSupport.kext JoystickDriver.kext
Note also that if you use
-no-system-extensions
(-e
),
you must supply at
least some version of System.kext in order to supply
information about the kernel. This should always match the kernel you're
linking against, which is by default the installed kernel on the machine
you're using kextutil
on; you can use the
-kernel
(-k
) option to
specify a different kernel file. You may also need to explicitly specify
other library or family kexts.
Pure I/O Kit driver kexts have empty module-start routines, but
trigger matching and driver instance creation on load. If you need to debug
an I/O Kit driver's early startup code, you can load the driver on the
target machine without starting matching by using the
-load-only
(-l
) option:
kextutil -l DiskController.kext
Once you have done this, you can use the generated symbol file in
your debug session to set breakpoints and then trigger matching by running
kextutil
again on the target machine with the
-match-only
(-m
) option:
kextutil -m DiskController.kext
You may wish to use the -personality
(-p
) option as well in order to send selected
personalities to the kernel. Alternatively, you can use the
-interactive
(-i
) option for
the whole process, which causes kextutil
to pause
just before loading any personalities and then to ask you for each
personality whether that one should be sent to the kernel:
kextutil -i DiskController.kext DiskController.kext appears to be loadable (not including linkage for on-disk libraries). Load DiskController.kext and its dependencies into the kernel [Y/n]? y Loading DiskController.kext. DiskController.kext successfully loaded (or already loaded). DiskController.kext and its dependencies are now loaded, but not started (unless they were already running). You may now set breakpoints in the debugger before starting them. start DiskController.kext [Y/n]? y DiskController.kext started. send personalities for DiskController.kext [Y/n]? y send personality Test Match Personality [Y/n]? y
In order to debug a kext's module-start routine, you must use the
-interactive
(-i
) or
-interactive-all
(-I
)
option, which pause after loading and before calling the module-start
function, so that you can set up your debugging session as needed before
proceeding.
kextutil
exits with a zero status upon
success. Upon failure, it prints an error message and continues processing
remaining kexts if possible, then exits with a nonzero status.
For a kext to be loadable, it must be valid, authentic, have all
dependencies met (that is, all dependencies must be found and loadable). A
valid kext has a well formed bundle, info dictionary, and executable. An
authentic kext's component files are owned by root:wheel, with permissions
nonwritable by group and other. If your kext fails to load, try using the
-print-diagnostics
(-t
)
option to print diagnostics related to validation and authentication.
Many single-letter options are inconsistent in meaning with (or directly contradictory to) the same letter options in other kext tools.
kmutil(8), kernelmanagerd(8), kextcache(8), kextd(8), kextload(8), kextstat(8), kextunload(8), kext_logging(8)
November 14, 2012 | Darwin |