]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Revert "ukify: Weaken file alignment assertions"
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 28 Mar 2023 11:31:38 +0000 (13:31 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 28 Mar 2023 11:31:38 +0000 (13:31 +0200)
This reverts commit 23428bb19e49cf510c65e2896f1a7e4b12ca1dbc.

src/ukify/ukify.py

index 99128014d93e14f5b8af27c318e8678e7b59d540..2cdfc01ad4f80c061385b8b3b7d67e2a61f610e5 100755 (executable)
@@ -449,7 +449,7 @@ class PeError(Exception):
 
 def pe_add_sections(uki: UKI, output: str):
     pe = pefile.PE(uki.executable, fast_load=True)
-    assert pe.FILE_HEADER.PointerToSymbolTable != 0 or len(pe.__data__) % pe.OPTIONAL_HEADER.FileAlignment == 0
+    assert len(pe.__data__) % pe.OPTIONAL_HEADER.FileAlignment == 0
 
     warnings = pe.get_warnings()
     if warnings:
@@ -460,12 +460,6 @@ def pe_add_sections(uki: UKI, output: str):
         # We could strip the signatures, but why would anyone sign the stub?
         raise PeError(f'Stub image is signed, refusing.')
 
-    # If the executable has not been stripped, it might not be aligned to a multiple of the file alignment so
-    # let's make sure it is by padding it.
-    if pe.FILE_HEADER.PointerToSymbolTable != 0:
-        padlen = round_up(len(pe.__data__), pe.OPTIONAL_HEADER.FileAlignment) - len(pe.__data__)
-        pe.__data__ = pe.__data__[:] + padlen * b'\0'
-
     for section in uki.sections:
         new_section = pefile.SectionStructure(pe.__IMAGE_SECTION_HEADER_format__, pe=pe)
         new_section.__unpack__(b'\0' * new_section.sizeof())