From 4af374e2c191465de99d4169376e1a9430302e82 Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 1 Feb 2018 21:17:04 +0100 Subject: auto-patchelf: Only search for deps with same arch So far we only matched the file name of the dependency but not its architecture, so if for example there is one shared object for i686-linux and another one with the same name but for x86_64-linux, chances are that the wrong architecture is chosen. Now we're checking the architecture of the shared object file and only pick it, if it matches the architecture of the file to patchelf. Signed-off-by: aszlig --- pkgs/games/build-support/setup-hooks/auto-patchelf.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'pkgs/games/build-support') diff --git a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh b/pkgs/games/build-support/setup-hooks/auto-patchelf.sh index 99ce3be4..e24e278f 100644 --- a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/games/build-support/setup-hooks/auto-patchelf.sh @@ -62,8 +62,13 @@ populateCacheWithRecursiveDeps() { done } +getSoArch() { + objdump -f "$1" | sed -ne 's/^architecture: *\([^,]\+\).*/\1/p' +} + findDependency() { local filename="$1" + local arch="$2" local lib dep if [ $depCacheInitialised -eq 0 ]; then @@ -75,15 +80,17 @@ findDependency() { for dep in "${cachedDependencies[@]}"; do if [ "$filename" = "${dep##*/}" ]; then - foundDependency="$dep" - return 0 + if [ "$(getSoArch "$dep")" = "$arch" ]; then + foundDependency="$dep" + return 0 + fi fi done if [ $doneRecursiveSearch -eq 0 ]; then populateCacheWithRecursiveDeps doneRecursiveSearch=1 - findDependency "$filename" || return 1 + findDependency "$filename" "$arch" || return 1 return 0 fi return 1 @@ -113,7 +120,7 @@ autoPatchelfFile() { for dep in $missing; do echo -n " $dep -> " >&2 - if findDependency "$dep"; then + if findDependency "$dep" "$(getSoArch "$toPatch")"; then rpath="$rpath${rpath:+:}${foundDependency%/*}" echo "found: $foundDependency" >&2 else -- cgit 1.4.1