OpenCore
1.0.4
OpenCore Bootloader
|
This toolset allows one to quickly port UEFI code to userspace utilities in popular operating systems such as macOS, Windows, or Linux. The only requirement is a C11-supporting compiler with the build scripts adopted for modern versions of clang and gcc.
Create a Makefile
with the contents similar to an example below:
Build it with the make
command.
Additional variables are supported to adjust the compilation process.
COVERAGE=1
— build with coverage information gathering.DEBUG=1
— build with debugging information.FUZZ=1
— build with fuzzing enabled.FUZZ_JOBS=2
— run with 2 fuzzing jobs (defaults to 4).FUZZ_MEM=1024
- run with 1024 MB fuzzing memory limit (defaults to 4096)*.SANITIZE=1
— build with LLVM sanitizers enabled.CC=cc
— build with cc
compiler (e.g. i686-w64-mingw32-gcc
for Windows).DIST=Target
— build for target Target
(e.g. Darwin
, Linux
, Windows
).STRIP=strip
— build with strip
stripping tool (e.g. i686-w64-mingw32-strip
for Windows).OC_PATH
- path to OpenCorePkg for out-of-tree utilities (defaults to ../..
).UDK_ARCH=Ia32
— build with 32-bit UDK architecture (defaults to X64
).UDK_PATH=/path/to/UDK
— build with custom UDK path (defaults to $PACKAGES_PATH
).WERROR=1
— treat compiler warnings as errors.SYDR=1
— change $(SUFFIX)
to store compilation results for Sydr DSE in a directory distinct from the default one.*NOTE: If your program uses UserBaseMemoryLib
and calls custom allocation functions, be sure that besides FUZZ_MEM
limit you correctly set limit mPoolAllocationSizeLimit
which defaults to the 512 MB in cases if your code could allocate more than this limit at single AllocatePool.
To set up your limit, use SetPoolAllocationSizeLimit
routine like shown in the example below:
Example 1. To build 32-bit version of utility on macOS (use High Sierra 10.13 or below):
Example 2. To build for 32-bit Windows (requires MinGW installed) use the following command:
Example 3. To build with LLVM sanitizers use the following command:
Example 4. Perform fuzzing and generate coverage report:
Note: fuzzing corpus is saved in FUZZDICT
.
Example 5. Perform fuzzing with the help of Sydr tool (path to which should be in $PATH
):
Most UDK variables are available due to including the original headers.
MDE_CPU_*
variables can be used. For example, MDE_CPU_IA32
for 32-bit Intel and MDE_CPU_X64
for 64-bit Intel.EFIUSER
variable.EFIUSER_DEBUG
variable.SANITIZE_TEST
.FUZZING_TEST
.ENTRY_POINT
variable for main
to automatically disable it for fuzzing.