ukify: Validate that there are no overlapping sections

Let's make sure that after calling objcopy we have no overlapping
sections in the UKI
This commit is contained in:
Daan De Meyer
2022-12-22 12:21:11 +01:00
parent 789a642738
commit 3fc1ae89e7
+14
View File
@@ -424,6 +424,18 @@ def join_initrds(initrds):
assert False
def pe_validate(filename):
import pefile
pe = pefile.PE(filename)
sections = sorted(pe.sections, key=lambda s: (s.VirtualAddress, s.Misc_VirtualSize))
for l, r in itertools.pairwise(sections):
if l.VirtualAddress + l.Misc_VirtualSize > r.VirtualAddress + r.Misc_VirtualSize:
raise ValueError(f'Section "{l.Name.decode()}" ({l.VirtualAddress}, {l.Misc_VirtualSize}) overlaps with section "{r.Name.decode()}" ({r.VirtualAddress}, {r.Misc_VirtualSize})')
def make_uki(opts):
# kernel payload signing
@@ -540,6 +552,8 @@ def make_uki(opts):
print('+', shell_join(cmd))
subprocess.check_call(cmd)
pe_validate(output)
# UKI signing
if opts.sb_key: