about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2020-06-08 01:59:41 +0200
committeraszlig <aszlig@nix.build>2020-06-08 02:04:52 +0200
commitab90835031a7b47bf501631c71b8c13f2a2f8062 (patch)
treeb61c31b0abee7be374a0db75abb4b0e8cca1b796 /pkgs/games
parentef6f2c0eb0f4dfc19c932a3c442883807e52817f (diff)
setup-hooks/fix-fmod: Patch all calls to system()
In newer versions of libfmod, there are two calls to system(), which
cause the setup hook to fail, since it only expects one such call.

Fortunately, we don't want libfmod to execute *any* external commands,
so fixing this is rather easy by just making *all* calls to system() a
no-op.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/build-support/setup-hooks/fix-fmod.sh17
1 files changed, 10 insertions, 7 deletions
diff --git a/pkgs/games/build-support/setup-hooks/fix-fmod.sh b/pkgs/games/build-support/setup-hooks/fix-fmod.sh
index bc490a64..219bf709 100644
--- a/pkgs/games/build-support/setup-hooks/fix-fmod.sh
+++ b/pkgs/games/build-support/setup-hooks/fix-fmod.sh
@@ -12,16 +12,19 @@ _doPatchFmod() {
 
     case "$(objdump -f "$1" | sed -n -e 's/^architecture: *//p')" in
         i386:x86-64,*)
-            local addr="$(objdump -d "$1" | sed -n -e '
+            local addrs="$(objdump -d "$1" | sed -n -e '
                 /callq.*system@plt/s/^ *\([^:]\+\).*/\1/p
             ')"
 
-            # This is quite easy, just replace the system() call with XOR EAX
-            # so we get a return value of 0 and pad the rest with NOP.
-            local offset=$(("0x$addr"))
-            ( printf '\x31\xc0'     # XOR the EAX register
-              printf '\x90\x90\x90' # Fill with NOPs
-            ) | dd of="$1" obs=1 seek=$offset conv=notrunc status=none
+            local addr
+            for addr in $addrs; do
+                # This is quite easy, just replace the system() call with XOR
+                # EAX so we get a return value of 0 and pad the rest with NOP.
+                local offset=$(("0x$addr"))
+                ( printf '\x31\xc0'     # XOR the EAX register
+                  printf '\x90\x90\x90' # Fill with NOPs
+                ) | dd of="$1" obs=1 seek=$offset conv=notrunc status=none
+            done
             ;;
         i386,*)
             local relocSystem="$(readelf -r "$1" | sed -n -e '