summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-07-01 01:30:58 +0200
committerDave Reisner <dreisner@archlinux.org>2011-07-01 21:52:24 +0200
commit8ad503a7866066162828796c66489070d661dc44 (patch)
treef0d31bf3ba69ee27a4215775d1358102b1a6c580
parent549af8c1b9a72cacf8cda41f8dd4b76983930945 (diff)
downloadmkinitcpio-8ad503a7866066162828796c66489070d661dc44.tar.gz
mkinitcpio-8ad503a7866066162828796c66489070d661dc44.tar.xz
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 <dreisner@archlinux.org>
-rw-r--r--functions10
-rwxr-xr-xmkinitcpio18
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