From 8ad503a7866066162828796c66489070d661dc44 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 30 Jun 2011 19:30:58 -0400 Subject: avoid touching the linker directly Much to my chagrin, we're going back to using ldd directly, as it's otherwise too difficult to account for odd setups, such as idiots wanting to create multilib initramfs images, or more commonly -- a 64 bit kernel on a 32 bit userland. Fortunately, we don't suffer too large a regression in speed compared to the previous implementation. Signed-off-by: Dave Reisner --- functions | 10 +++------- mkinitcpio | 18 +----------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/functions b/functions index 1aea1a7..136b281 100644 --- a/functions +++ b/functions @@ -204,10 +204,6 @@ add_module() { esac } -_ldd() { - LD_TRACE_LOADED_OBJECTS=1 "$LD_SO" "$@" -} - _add_file() { # add a file to $BUILDROOT # $1: pathname on initcpio @@ -264,10 +260,10 @@ add_binary() { # always add the binary itself _add_file "${dest#$BASEDIR}" "$binary" "$mode" - $LD_SO --verify "$binary" &>/dev/null || return # not a binary! + lddout=$(ldd "$binary" 2>/dev/null) || return 1 # not a binary! # resolve sodeps - regex='^[[:space:]]*[^/].+ => (.*) \(.*\)' + regex='(/.+) \(0x[a-fA-F0-9]+\)' while read line; do [[ "$line" =~ $regex ]] && sodep=${BASH_REMATCH[1]} || continue @@ -282,7 +278,7 @@ add_binary() { _add_file "${resolved#$BASEDIR}" "$resolved" 755 fi fi - done < <(_ldd "$binary") + done <<< "$lddout" return 0 } diff --git a/mkinitcpio b/mkinitcpio index 459c828..71d3e0d 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -22,7 +22,7 @@ INSTDIR=install PRESETDIR=mkinitcpio.d COMPRESSION=gzip -declare TMPDIR BASEDIR MODULE_FILE GENIMG PRESET COMPRESSION_OPTIONS BUILDROOT LD_SO +declare TMPDIR BASEDIR MODULE_FILE GENIMG PRESET COMPRESSION_OPTIONS BUILDROOT declare NC= BOLD= BLUE= GREEN= RED= YELLOW= declare -i QUIET=1 SHOW_AUTOMODS=0 SAVELIST=0 COLOR=1 declare -a SKIPHOOKS ADDED_MODULES @@ -294,22 +294,6 @@ trap '[[ $FUNCNAME = parse_hook ]] && (( ++builderrors ))' ERR #parse 'global' hook, as defined in ${CONFIG} parse_hook -# resolve the linker and add it -case $CARCH in - i686) LD_SO=("$BASEDIR"/lib/ld-linux.so.?*) ;; - x86_64) LD_SO=("$BASEDIR"/lib/ld-linux-${CARCH//_/-}.so.?*) ;; - *) die "unknown architecture: $CARCH" ;; -esac - -if (( ${#LD_SO[*]} != 1 )); then # uh oh... - die "failed to resolve the location of /lib/ld.so. Please report this bug." -fi - -resolved=$(readlink -e "$LD_SO") -_add_file "${resolved#$BASEDIR}" "$resolved" 755 -_add_symlink "${LD_SO#$BASEDIR}" "$resolved" -unset resolved - for hook in ${HOOKS}; do in_array "$hook" "${SKIPHOOKS[@]}" && continue unset MODULES BINARIES FILES SCRIPT -- cgit v1.2.3-24-g4f1b