about summary refs log tree commit diff
path: root/nixpkgs/pkgs/stdenv/cygwin/rebase-x86_64.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/stdenv/cygwin/rebase-x86_64.sh')
-rw-r--r--nixpkgs/pkgs/stdenv/cygwin/rebase-x86_64.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/stdenv/cygwin/rebase-x86_64.sh b/nixpkgs/pkgs/stdenv/cygwin/rebase-x86_64.sh
new file mode 100644
index 000000000000..4c8f8ebd7eb2
--- /dev/null
+++ b/nixpkgs/pkgs/stdenv/cygwin/rebase-x86_64.sh
@@ -0,0 +1,24 @@
+fixupOutputHooks+=(_cygwinFixAutoImageBase)
+
+_cygwinFixAutoImageBase() {
+    if [ "$dontRebase" == 1 ] || [ ! -d "$prefix" ]; then
+        return
+    fi
+    find "$prefix" -name "*.dll" -type f | while read DLL; do
+        if [ -f /etc/rebasenix.nextbase ]; then
+            NEXTBASE="$(</etc/rebasenix.nextbase)"
+        fi
+        NEXTBASE=${NEXTBASE:-0x200000001}
+
+        REBASE=(`/bin/rebase -i $DLL`)
+        BASE=${REBASE[2]}
+        SIZE=${REBASE[4]}
+        SKIP=$(((($SIZE>>16)+1)<<16))
+
+        echo "REBASE FIX: $DLL $BASE -> $NEXTBASE"
+        /bin/rebase -b $NEXTBASE $DLL
+        NEXTBASE="0x`printf %x $(($NEXTBASE+$SKIP))`"
+
+        echo $NEXTBASE > /etc/rebasenix.nextbase
+    done
+}