]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: do not fail if pefile complains about hardcoded 256MB limit 36181/head
authorLuca Boccassi <luca.boccassi@gmail.com>
Thu, 30 Jan 2025 01:19:59 +0000 (01:19 +0000)
committerLuca Boccassi <bluca@debian.org>
Fri, 7 Feb 2025 13:58:51 +0000 (13:58 +0000)
pefile has an hardcoded limit to 256MB per section:

https://github.com/erocarrera/pefile/issues/396

When building an initrd with large firmware files and
lots of kernel modules, this limit can be reached.
Skip over those warnings.

src/ukify/ukify.py

index af1b1b4a448da33e9c661a53228f058aadc88884..7a6ffd299567aeddc5827cb1b84cd7d57e11b139 100755 (executable)
@@ -953,8 +953,14 @@ def pe_add_sections(opts: UkifyConfig, uki: UKI, output: str) -> None:
     )
     pe = pefile.PE(data=pe.write(), fast_load=True)
 
+    # pefile has an hardcoded limit of 256MB, which is not enough when building an initrd with large firmware
+    # files and all kernel modules. See: https://github.com/erocarrera/pefile/issues/396
     warnings = pe.get_warnings()
-    if warnings:
+    for w in warnings:
+        if 'VirtualSize is extremely large' in w:
+            continue
+        if 'VirtualAddress is beyond' in w:
+            continue
         raise PEError(f'pefile warnings treated as errors: {warnings}')
 
     # When attaching signatures we are operating on an existing UKI which might be signed