mirror of
https://git.suyu.dev/suyu/Yucom.git
synced 2025-12-23 15:54:07 +01:00
build: Fixup PE section headers.
For FH4.
This commit is contained in:
parent
8448591ebd
commit
5b406be13e
3 changed files with 37 additions and 2 deletions
25
make/pefixup.py
Executable file
25
make/pefixup.py
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import stat
|
||||
import pefile
|
||||
|
||||
for path in sys.argv[1:]:
|
||||
pe = pefile.PE(path)
|
||||
|
||||
for section in pe.sections:
|
||||
if section.Name.decode("utf-8")[0:5] == ".text":
|
||||
section.Characteristics &= ~pefile.SECTION_CHARACTERISTICS['IMAGE_SCN_CNT_INITIALIZED_DATA']
|
||||
section.Characteristics &= ~pefile.SECTION_CHARACTERISTICS['IMAGE_SCN_ALIGN_MASK']
|
||||
|
||||
pe.OPTIONAL_HEADER.CheckSum = pe.generate_checksum()
|
||||
|
||||
perm = stat.S_IMODE(os.stat(path).st_mode)
|
||||
if (perm & stat.S_IWUSR) == 0:
|
||||
os.chmod(path, perm | stat.S_IWUSR)
|
||||
|
||||
pe.write(path)
|
||||
|
||||
if (perm & stat.S_IWUSR) == 0:
|
||||
os.chmod(path, perm)
|
||||
Loading…
Add table
Add a link
Reference in a new issue