UefiPayloadPkg: Enhance universal payload build

If there is no relocation in the payload it would build failure.
This will fix the build failure.

Signed-off-by: Guo Dong <guo.dong@intel.com>
This commit is contained in:
Guo Dong 2024-11-19 15:46:11 -07:00 committed by mergify[bot]
parent 72b65146bf
commit c5811ef1b3

@ -266,13 +266,14 @@ def BuildUniversalPayload(Args):
#
RelocBinary = b''
PeCoff = pefile.PE (TargetRebaseFile)
for reloc in PeCoff.DIRECTORY_ENTRY_BASERELOC:
for entry in reloc.entries:
if (entry.type == 0):
continue
Type = entry.type
Offset = entry.rva + fit_image_info_header.DataOffset
RelocBinary += Offset.to_bytes (8, 'little') + Type.to_bytes (8, 'little')
if hasattr(PeCoff, 'DIRECTORY_ENTRY_BASERELOC'):
for reloc in PeCoff.DIRECTORY_ENTRY_BASERELOC:
for entry in reloc.entries:
if (entry.type == 0):
continue
Type = entry.type
Offset = entry.rva + fit_image_info_header.DataOffset
RelocBinary += Offset.to_bytes (8, 'little') + Type.to_bytes (8, 'little')
RelocBinary += b'\x00' * (0x1000 - (len(RelocBinary) % 0x1000))
#