From 7d18dca5c1b99cda942c7e0c95a3df2959dea2c2 Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Fri, 13 Feb 2009 04:43:14 -0800 Subject: [PATCH] [PATCH 43/50] Use ldd to find shared library deps. This replaces the eu-readelf and ld-linux.so.2 hackery. As a bonus it will keep working if we (for some bizzare reason) need to load a non-elf executable or shared library on the initrd. --- dracut-functions | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/dracut-functions b/dracut-functions index 8beba8b7c..62038f6d3 100755 --- a/dracut-functions +++ b/dracut-functions @@ -66,16 +66,10 @@ inst_binary() { local bin="$1" target="${2:-$1}" local LDSO NAME IO FILE ADDR I1 n f TLIBDIR [[ -f $initdir$target ]] && return 0 - - LDSO=$(LANG=C eu-readelf -l $bin 2>/dev/null | \ - awk '/interpreter/ {print $4}' |sed -e 's/]$//') - [[ $LDSO && $LDSO != $bin ]] || LDSO="$IF_RTLD" - [[ $LDSO && $LDSO != $bin ]] || return 1 - [[ $IF_RTLD ]] || IF_RTLD="$LDSO" - # I love bash! - while read NAME I0 FILE ADDR I1 ; do - [[ $FILE = $bin ]] && continue + while read line; do + [[ $line =~ '([^ ]*/lib/[^ ]*\.so[^ ]*)' ]] || continue + FILE=${BASH_REMATCH[1]} [[ $FILE = not || $NAME = not ]] && { echo "Missing a shared library required by $bin." >&2 echo "dracut cannot create an initrd." >&2 @@ -96,8 +90,7 @@ inst_binary() { continue } inst_library "$FILE" - done < <(LD_TRACE_PRELINKING=1 LD_WARN= LD_TRACE_LOADED_OBJECTS=1 \ - $LDSO $bin 2>/dev/null) + done < <(ldd $bin 2>/dev/null) inst_simple "$bin" "$target" } -- 2.47.3