Skip to content

Commit 1f05a99

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 32caed550f5a81eb87d2e39bc83917df2898d844) (cherry picked from commit 87224a2) (cherry picked from commit 9141043)
1 parent 078015a commit 1f05a99

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
@@ -617,8 +617,14 @@ def pe_add_sections(uki: UKI, output: str):
617617
pe.OPTIONAL_HEADER.SizeOfHeaders = round_up(pe.OPTIONAL_HEADER.SizeOfHeaders, pe.OPTIONAL_HEADER.FileAlignment)
618618
pe = pefile.PE(data=pe.write(), fast_load=True)
619619

620+
# pefile has an hardcoded limit of 256MB, which is not enough when building an initrd with large firmware
621+
# files and all kernel modules. See: https://github.com/erocarrera/pefile/issues/396
620622
warnings = pe.get_warnings()
621-
if warnings:
623+
for w in warnings:
624+
if 'VirtualSize is extremely large' in w:
625+
continue
626+
if 'VirtualAddress is beyond' in w:
627+
continue
622628
raise PEError(f'pefile warnings treated as errors: {warnings}')
623629

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

0 commit comments

Comments
 (0)