[build] Allow binaries to request a log partition from genfsimg
For UEFI, the USB disk image is constructed from the built EFI binary (e.g. bin-x86_64-efi/ipxe.efi) by genfsimg, which does not itself have any way to access the build configuration. We therefore need a way to annotate the binary such that genfsimg can determine whether or not to include a log partition within the USB disk image. The "OEM ID" and "OEM information" fields within the PE header can be used for this, since they are easily accessed and serve no other purpose. We define bit 0 of "OEM information" as a flag indicating that a log partition should be included. If this bit is set, genfsimg will create a log partition with a layout matching that of the BIOS build (i.e. using partition 3 and at an offset of 16kB from the start of the disk). The PE header is constructed by elf2efi.c, which takes as an input the linked ELF form of the binary. We use an ELF .note section to allow any linked-in object to communicate the log partition request through to elf2efi.c, which then populates the OEM information field accordingly. We choose to use the same field locations within the BIOS bzImage header, since this allows genfsimg to use the same logic for both BIOS and UEFI binaries. In a BIOS build, there is no external processing equivalent to elf2efi.c, and so we construct the field value directly using absolute symbols and explicit relocation records. (Note that the bzImage header is relevant only when using genfsimg to construct a combined BIOS/UEFI image. In the common case of building a BIOS-only image such as bin/ipxe.usb, the partition table is manually constructed by usbdisk.S and genfsimg is not involved.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -166,6 +166,31 @@
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup ipxenote Macros to provide ELF notes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Construct an iPXE-specific ELF note */
|
||||
#define IPXE_NOTE( type ) \
|
||||
__asm__ ( ".section \".note.ipxe\", \"\", " \
|
||||
_S2 ( ASM_TCHAR ) "note\n\t" \
|
||||
/* Owner name length */ \
|
||||
".long 4\n\t" \
|
||||
/* Content length */ \
|
||||
".long 0\n\t" \
|
||||
/* Type */ \
|
||||
".long " _S2 ( _C2 ( IPXE_NOTE_, type ) ) \
|
||||
"\n\t" \
|
||||
/* Owner name */ \
|
||||
".ascii \"iPXE\"\n\t" \
|
||||
".previous\n\t" )
|
||||
|
||||
/** Build will use a disk-based console log, if present */
|
||||
#define IPXE_NOTE_DISKLOG 0x18aed109
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup objmacros Macros to provide or require explicit objects
|
||||
* @{
|
||||
|
||||
Reference in New Issue
Block a user