Skip to content

Commit 364ce31

Browse files
committed
ukify: do not fail if pefile complains about hardcoded 256MB limit
pefile has an hardcoded limit to 256MB per section: erocarrera/pefile#396 When building an initrd with large firmware files and lots of kernel modules, this limit can be reached. Skip over those warnings. (cherry picked from commit 32caed5) (cherry picked from commit 87224a2)
1 parent c7fcf98 commit 364ce31

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ukify/ukify.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,14 @@ def pe_add_sections(uki: UKI, output: str):
622622
pe.OPTIONAL_HEADER.SizeOfHeaders = round_up(pe.OPTIONAL_HEADER.SizeOfHeaders, pe.OPTIONAL_HEADER.FileAlignment)
623623
pe = pefile.PE(data=pe.write(), fast_load=True)
624624

625+
# pefile has an hardcoded limit of 256MB, which is not enough when building an initrd with large firmware
626+
# files and all kernel modules. See: https://github.com/erocarrera/pefile/issues/396
625627
warnings = pe.get_warnings()
626-
if warnings:
628+
for w in warnings:
629+
if 'VirtualSize is extremely large' in w:
630+
continue
631+
if 'VirtualAddress is beyond' in w:
632+
continue
627633
raise PEError(f'pefile warnings treated as errors: {warnings}')
628634

629635
security = pe.OPTIONAL_HEADER.DATA_DIRECTORY[pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_SECURITY']]

0 commit comments

Comments
 (0)