Understanding INF Files in EDK II UEFI Build

In the TianoCore EDK II UEFI development environment, Information (INF) files serve as the definitive module-level blueprints that orchestrate compilation and linking. This article explains how INF metadata files specify source code, architectural dependencies, library mappings, and compiler options, enabling the EDK II build engine to generate platform-agnostic build scripts, produce autogenerated source wrappers, and invoke platform toolchains to generate UEFI-compliant binaries.

The Role of the INF File in EDK II

In EDK II, an INF file defines a single discrete component—such as a UEFI driver, application, or library. While Platform Description (DSC) files describe the entire firmware target, the INF file encapsulates all module-specific compilation requirements. It isolates module implementation from underlying toolchains, allowing developers to target multiple CPU architectures (IA-32, X64, ARM, AArch64, RISC-V) without rewriting build routines.

Key INF Sections Structuring the Build Process

The EDK II build tool parses the INI-style sections within the INF file to determine the compilation pipeline:

  • [Defines]: Defines core metadata including the module's name (BASE_NAME), unique GUID (FILE_GUID), module type (MODULE_TYPE, such as PEIM, DXE_DRIVER, or UEFI_APPLICATION), entry point (ENTRY_POINT), and specification version. The MODULE_TYPE dictates which runtime constraints and default libraries apply during compilation and linking.
  • [Sources]: Lists all source files (.c, .nasm, .S, etc.) required to build the module. Files can be scoped to specific architectures (e.g., [Sources.X64]). The build tool routes each file to its corresponding toolchain component (compiler, assembler, etc.).
  • [Packages]: References Package Declaration (DEC) files. This defines the search paths for header files and declares the public interfaces available to the module.
  • [LibraryClasses]: Lists abstract library interfaces required by the module. Instead of linking directly to static paths, the INF requests functional interfaces (e.g., BaseLib, UefiDriverEntryPoint), which the platform's DSC file resolves to concrete instances.
  • [Protocols], [Guids], and [Ppis]: Declares the GUIDs used by the module. These declarations ensure the build system validates interface availability and exposes the appropriate identifier symbols to the source code.
  • [Pcd]: Lists Platform Configuration Databases (PCDs) accessed by the module, establishing compile-time or dynamic configuration settings.
  • [BuildOptions]: Supplies toolchain-specific compiler and linker flags to tailor optimization levels, include paths, or warning suppressions for that specific module.

The AutoGen Phase

Before native compilers (such as GCC, Clang, or MSVC) are invoked, the EDK II build system processes the INF file to produce intermediate source files named AutoGen.c and AutoGen.h:

  1. Symbol and GUID Instantiation: External GUID structures for Protocols, PPIs, and PCDs are instantiated as C symbols to satisfy linker requirements.
  2. Library Constructor/Destructor Chains: The build engine inspects the dependencies listed in [LibraryClasses] and generates sequential calls to initialize and terminate linked libraries in AutoGen.c.
  3. Entry Point Wrapping: If an entry point is designated in [Defines], AutoGen.c implements the low-level image entry function that delegates execution to the module's main entry routine after library constructors complete.

Makefile Generation and Toolchain Invocation

Once the metadata and AutoGen files are processed, the EDK II build system constructs GNU Makefiles, NMake Makefiles, or Ninja build files customized to the active target toolchain. The generated makefile maps every file in [Sources] alongside AutoGen.c, applies the flags defined in tools_def.txt merged with the INF's [BuildOptions], and passes the compiled object files to the linker.

The linker uses the MODULE_TYPE settings provided by the INF to enforce correct subsystem flags, producing a Terse Executable (TE) or Portable Executable/Common Object File Format (PE/COFF) binary suitable for dispatch by the UEFI firmware.