Terse Executable Format

From PhoenixWiki

Jump to: navigation, search

The Terse Executable (TE) image format was created as a mechanism to reduce the overhead of the PE/COFF headers in PE32/PE32+ images, resulting in a corresponding reduction of image sizes for executables running in the pre-OS.

Reducing image size provides an opportunity for use of a smaller system flash part. TE images, both drivers and applications, are created as PE32 (or PE32+) executables. PE32 is a generic executable image format that is intended to support multiple target systems, processors, and operating systems. As a result, the headers in the image contain information that is not necessarily applicable to all target systems. In an effort to reduce image size, a new executable image header (TE) was created that includes only those fields from the PE/COFF headers required for execution under the PI Architecture. Since this header contains the information required for execution of the image, it can replace the PE/COFF headers from the original image.

A PE/COFF file header contains an MS-DOS* stub, a PE signature, a COFF header, an optional header, and section headers. For successful execution, pre-OS drivers require very little of the data from these headers, and in fact the MS-DOS stub and PE signature are not required at all.

The following table describes the COFF header fields used in TE images.

COFF Header Description
Machine Target machine identifier. 2 bytes in both COFF header and TE header
NumberOfSections Number of sections/section headers. 2 bytes in COFF header, 1 byte in TE header

The following table describes the Optional Header fields required for TE images.

Optional Header Description
AddressOfEntryPoint Address of entry point relative to image base. 4 bytes in both optional header and TE header
BaseOfCode Offset from image base to the start of the code section. 4 bytes in both optional header and TE header
ImageBase Image’s linked address. 4 bytes in OptionalHeader32, 8 bytes in OptionalHeader64, and 8 bytes in TE header
Subsystem Subsystem required to run the image. 2 bytes in optional header, 1 byte in TE header

The full TE header structure is described by the EFI_TE_IMAGE_HEADER.

Copyright (C) 2008 Phoenix Technologies Ltd. All Rights Reserved. Portions copyright (C) 2008 UEFI Forum, Inc. Used with permission

Personal tools