Browse Source

[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.
master
Victor Lowther 16 years ago committed by Dave Jones
parent
commit
7d18dca5c1
  1. 15
      dracut-functions

15
dracut-functions

@ -66,16 +66,10 @@ inst_binary() { @@ -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() { @@ -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"
}


Loading…
Cancel
Save