Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ValveSoftware/Proton.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gofman <pgofman@codeweavers.com>2021-03-18 18:27:03 +0300
committerAndrew Eikum <aeikum@codeweavers.com>2021-05-03 17:20:02 +0300
commit139ee36b3bb667995d5ed8bea7e26155691a0265 (patch)
tree6bf1318280496975f66becb89b67b67b3458c536
parent2fa3a438fde28e6255ac7c6c1f4eda6c88829cd9 (diff)
build: Fixup PE section headers.
For FH4.
-rw-r--r--Makefile7
-rw-r--r--Vagrantfile2
-rwxr-xr-xmake/pefixup.py27
-rw-r--r--make/rules-common.mk8
4 files changed, 41 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index bb878db6..d93f89b9 100644
--- a/Makefile
+++ b/Makefile
@@ -145,6 +145,7 @@ module: configure
vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) module=$(module) module && \
cp -f $(BUILD_DIR)/obj-wine32/dlls/$(module)/$(module)$(MODULE_SFX)* /vagrant/$(module)/lib/wine/ && \
cp -f $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module)$(MODULE_SFX)* /vagrant/$(module)/lib64/wine/ && \
+ find /vagrant/$(module)/ -type f -name "*.dll" -printf "%p\0" | xargs --verbose -0 -r -P8 -n3 proton/make/pefixup.py && \
if [ -e $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module).so ]; then \
cp -f $(BUILD_DIR)/obj-wine32/dlls/$(module)/$(module).so /vagrant/$(module)/lib/wine/ && \
cp -f $(BUILD_DIR)/obj-wine64/dlls/$(module)/$(module).so /vagrant/$(module)/lib64/wine/; \
@@ -156,14 +157,16 @@ dxvk: configure
mkdir -p vagrant_share/dxvk/lib64/wine/dxvk/
vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) dxvk && \
cp -f $(BUILD_DIR)/dist/files/lib/wine/dxvk/*.dll /vagrant/dxvk/lib/wine/dxvk/ && \
- cp -f $(BUILD_DIR)/dist/files/lib64/wine/dxvk/*.dll /vagrant/dxvk/lib64/wine/dxvk/'
+ cp -f $(BUILD_DIR)/dist/files/lib64/wine/dxvk/*.dll /vagrant/dxvk/lib64/wine/dxvk/ && \
+ find /vagrant/dxvk/ -type f -name "*.dll" -printf "%p\0" | xargs --verbose -0 -r -P8 -n3 proton/make/pefixup.py'
vkd3d-proton: configure
mkdir -p vagrant_share/vkd3d-proton/lib/wine/vkd3d-proton/
mkdir -p vagrant_share/vkd3d-proton/lib64/wine/vkd3d-proton/
vagrant ssh -c 'make -C $(BUILD_DIR)/ $(UNSTRIPPED) $(CCACHE_FLAG) vkd3d-proton && \
cp -f $(BUILD_DIR)/dist/files/lib/wine/vkd3d-proton/*.dll /vagrant/vkd3d-proton/lib/wine/vkd3d-proton/ && \
- cp -f $(BUILD_DIR)/dist/files/lib64/wine/vkd3d-proton/*.dll /vagrant/vkd3d-proton/lib64/wine/vkd3d-proton/'
+ cp -f $(BUILD_DIR)/dist/files/lib64/wine/vkd3d-proton/*.dll /vagrant/vkd3d-proton/lib64/wine/vkd3d-proton/ && \
+ find /vagrant/vkd3d-proton/ -type f -name "*.dll" -printf "%p\0" | xargs --verbose -0 -r -P8 -n3 proton/make/pefixup.py'
lsteamclient: configure
mkdir -p vagrant_share/lsteamclient/lib/wine
diff --git a/Vagrantfile b/Vagrantfile
index 585a42ed..75f164ac 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -77,7 +77,7 @@ Vagrant.configure(2) do |config|
#install host build-time dependencies
apt-get update
apt-get install -y ccache texinfo gpgv2 gnupg2 git docker-ce docker-ce-cli containerd.io \
- fontforge-nox python-debian python-pip
+ fontforge-nox python-debian python-pip python3-pefile
#install adobe font devkit to build source san hans
pip install afdko
diff --git a/make/pefixup.py b/make/pefixup.py
new file mode 100755
index 00000000..ae6fe729
--- /dev/null
+++ b/make/pefixup.py
@@ -0,0 +1,27 @@
+#!/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)
+
+ print("Fixed up PE: ", path)
diff --git a/make/rules-common.mk b/make/rules-common.mk
index fda3e3db..a5b32b55 100644
--- a/make/rules-common.mk
+++ b/make/rules-common.mk
@@ -82,6 +82,14 @@ endif
$(1)-dist$(3): $$(OBJ)/.$(1)-dist$(3)
.INTERMEDIATE: $(1)-dist$(3)
+ifeq ($(CONTAINER),)
+$(1)-dist$(3): $$(OBJ)/.$(1)-fixup$(3)
+$$(OBJ)/.$(1)-fixup$(3): $$(OBJ)/.$(1)-dist$(3)
+ cd $$($(2)_LIBDIR$(3)) && find -type f -name '*.dll' -printf '$$(DST_LIBDIR$(3))/%p\0' | xargs --verbose -0 -r -P8 -n3 $$(SRC)/make/pefixup.py
+ touch $$@
+endif
+
+
all-dist$(3) $(1)-dist: $(1)-dist$(3)
.PHONY: all-dist$(3) $(1)-dist