From ab90835031a7b47bf501631c71b8c13f2a2f8062 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 8 Jun 2020 01:59:41 +0200 Subject: 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 --- pkgs/games/build-support/setup-hooks/fix-fmod.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'pkgs/games') 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 ' -- cgit 1.4.1