]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: Set fast_load option when parsing PE files
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 20 Feb 2023 13:45:19 +0000 (14:45 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 20 Feb 2023 19:02:22 +0000 (20:02 +0100)
Let's skip parsing of some irrelevant information that we don't use
to speed up building UKIs with large initrds from +-15s to less than
1s.

src/ukify/ukify.py

index 335de994d88ef6d8af9902aac64af857030cb65c..fc84cd640b4152564bef2432c7f987e32ae7f514 100755 (executable)
@@ -80,7 +80,7 @@ def path_is_readable(s: typing.Optional[str]) -> typing.Optional[pathlib.Path]:
 def pe_next_section_offset(filename):
     import pefile
 
-    pe = pefile.PE(filename)
+    pe = pefile.PE(filename, fast_load=True)
     section = pe.sections[-1]
     return pe.OPTIONAL_HEADER.ImageBase + section.VirtualAddress + section.Misc_VirtualSize
 
@@ -457,7 +457,7 @@ def pairwise(iterable):
 def pe_validate(filename):
     import pefile
 
-    pe = pefile.PE(filename)
+    pe = pefile.PE(filename, fast_load=True)
 
     sections = sorted(pe.sections, key=lambda s: (s.VirtualAddress, s.Misc_VirtualSize))