scripts: bundle-libraries.sh: fix broken SDK compiler
[openwrt/openwrt.git] / scripts / bundle-libraries.sh
index d3c7206a4dddd2b44a5b7d506f88212de850e0b4..90002453ecce6764afe0d01f4275c9783de7841e 100755 (executable)
@@ -125,6 +125,23 @@ _patch_glibc() {
        fi
 }
 
+should_be_patched() {
+       local bin="$1"
+
+       [ -x "$bin" ] || return 1
+
+       case "$bin" in
+               *.so|*.so.[0-9]*)
+                       return 1
+               ;;
+               *)
+                       file "$bin" | grep -sqE "ELF.*(executable|interpreter)" && return 0
+               ;;
+       esac
+
+       return 1
+}
+
 for LDD in ${PATH//://ldd }/ldd; do
        "$LDD" --version >/dev/null 2>/dev/null && break
        LDD=""
@@ -150,7 +167,7 @@ for BIN in "$@"; do
 
        LDSO=""
 
-       [ -n "$LDD" ] && [ -x "$BIN" ] && file "$BIN" | grep -sqE "ELF.*(executable|interpreter)" && {
+       [ -n "$LDD" ] && should_be_patched "$BIN" && {
                for token in $("$LDD" "$BIN" 2>/dev/null); do
                        case "$token" in */*.so*)
                                dest="$DIR/lib/${token##*/}"