Skip to content

Commit 87224a2

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)
1 parent d14161d commit 87224a2

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
@@ -892,8 +892,14 @@ def pe_add_sections(uki: UKI, output: str) -> None:
892892
)
893893
pe = pefile.PE(data=pe.write(), fast_load=True)
894894

895+
# pefile has an hardcoded limit of 256MB, which is not enough when building an initrd with large firmware
896+
# files and all kernel modules. See: https://github.com/erocarrera/pefile/issues/396
895897
warnings = pe.get_warnings()
896-
if warnings:
898+
for w in warnings:
899+
if 'VirtualSize is extremely large' in w:
900+
continue
901+
if 'VirtualAddress is beyond' in w:
902+
continue
897903
raise PEError(f'pefile warnings treated as errors: {warnings}')
898904

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

0 commit comments

Comments
 (0)