Skip to content

Commit 1e3a090

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) (cherry picked from commit 870c665)
1 parent e74cc36 commit 1e3a090

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

583+
# pefile has an hardcoded limit of 256MB, which is not enough when building an initrd with large firmware
584+
# files and all kernel modules. See: https://github.com/erocarrera/pefile/issues/396
583585
warnings = pe.get_warnings()
584-
if warnings:
586+
for w in warnings:
587+
if 'VirtualSize is extremely large' in w:
588+
continue
589+
if 'VirtualAddress is beyond' in w:
590+
continue
585591
raise PEError(f'pefile warnings treated as errors: {warnings}')
586592

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

0 commit comments

Comments
 (0)