summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2017-03-19 07:34:51 (GMT)
committerGitHub <noreply@github.com>2017-03-19 07:34:51 (GMT)
commit89f0971391fa26c442ce9bfb055c55e5cae2d0d1 (patch)
treeb82d03ad78739881aa8e4993e0dcf8d290e14c30 /scripts
parenta3dd55b96409922a416c05ab053569ec4f91126b (diff)
parent63b2a19de4b33f304b236850028b6c6f32ce51e2 (diff)
Merge pull request #639 from stilor/tweak-gcc-movelibs
When moving gcc libs, prefer the same directory as libc
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/cc/100-gcc.sh75
-rw-r--r--scripts/build/internals.sh52
-rw-r--r--scripts/build/libc/glibc.sh2
-rw-r--r--scripts/build/libc/musl.sh6
-rw-r--r--scripts/build/libc/uClibc.sh48
-rw-r--r--scripts/functions155
-rw-r--r--scripts/xldd.in56
7 files changed, 293 insertions, 101 deletions
diff --git a/scripts/build/cc/100-gcc.sh b/scripts/build/cc/100-gcc.sh
index 56517d3..e3ae783 100644
--- a/scripts/build/cc/100-gcc.sh
+++ b/scripts/build/cc/100-gcc.sh
@@ -129,6 +129,40 @@ cc_gcc_classify_opt() {
echo "unknown"
}
+evaluate_multilib_cflags()
+{
+ local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count
+ local mdir mdir_os dirtop
+ local f
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ mdir="lib/${multi_dir}"
+ mdir_os="lib/${multi_os_dir_gcc}"
+ CT_SanitizeVarDir mdir mdir_os
+ CT_DoLog EXTRA " '${multi_flags}' --> ${mdir} (gcc) ${mdir_os} (os)"
+ for f in ${multi_flags}; do
+ eval ml_`cc_gcc_classify_opt ${f}`=seen
+ done
+ if [ "${CT_DEMULTILIB}" = "y" ]; then
+ case "${mdir_os}" in
+ lib/*)
+ ;;
+ *)
+ dirtop="${mdir_os%%/*}"
+ if [ ! -e "${multi_root}/${mdir_os}" ]; then
+ CT_DoExecLog ALL ln -sfv lib "${multi_root}/${mdir_os}"
+ fi
+ if [ ! -e "${multi_root}/usr/${mdir_os}" ]; then
+ CT_DoExecLog ALL ln -sfv lib "${multi_root}/usr/${mdir_os}"
+ fi
+ ;;
+ esac
+ fi
+}
+
#------------------------------------------------------------------------------
# This function lists the multilibs configured in the compiler (even if multilib
# is disabled - so that it lists the default GCC/OS directory, which may differ
@@ -151,9 +185,11 @@ cc_gcc_classify_opt() {
# work, but 'gcc -mabi=32 -mabi=n32' produces an internal error in ld. Thus we do
# not supply target's CFLAGS in multilib builds - and after compiling pass-1 gcc,
# attempt to determine which CFLAGS need to be filtered out.
+#
+# 3. If "demultilibing" is in effect, create top-level directories for any
+# multilibs not in lib/ as symlinks to lib.
cc_gcc_multilib_housekeeping() {
local cc host
- local flags osdir dir multilibs i f
local multilib_defaults
local suffix sysroot base lnk
local ml_arch ml_abi ml_cpu ml_tune ml_fpu ml_float ml_endian ml_mode ml_unknown ml
@@ -175,25 +211,7 @@ cc_gcc_multilib_housekeeping() {
multilib_defaults=( $( cc_gcc_get_spec multilib_defaults "${cc}" | \
sed 's/\(^\|[[:space:]]\+\)\([^[:space:]]\)/ -\2/g' ) )
CT_DoLog EXTRA "gcc default flags: '${multilib_defaults}'"
-
- multilibs=( $( "${cc}" -print-multi-lib ) )
- if [ ${#multilibs[@]} -ne 0 ]; then
- CT_DoLog EXTRA "gcc configured with these multilibs (including the default):"
- for i in "${multilibs[@]}"; do
- dir="lib/${i%%;*}"
- flags="${i#*;}"
- flags=${flags//@/ -}
- flags=$( echo ${flags} )
- osdir="lib/"$( "${cc}" -print-multi-os-directory ${flags} )
- CT_SanitizeVarDir dir osdir
- CT_DoLog EXTRA " '${flags}' --> ${dir} (gcc) ${osdir} (os)"
- for f in ${flags}; do
- eval ml_`cc_gcc_classify_opt ${f}`=seen
- done
- done
- else
- CT_DoLog WARN "no multilib configuration: GCC unusable?"
- fi
+ CT_IterateMultilibs evaluate_multilib_cflags evaluate_cflags
# Filtering out some of the options provided in CT-NG config. Then *prepend*
# them to CT_TARGET_CFLAGS, like scripts/crosstool-NG.sh does. Zero out
@@ -789,8 +807,8 @@ do_gcc_for_build() {
}
gcc_movelibs() {
- local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count
- local gcc_dir
+ local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count
+ local gcc_dir dst_dir
for arg in "$@"; do
eval "${arg// /\\ }"
@@ -803,6 +821,15 @@ gcc_movelibs() {
# GCC didn't install anything outside of sysroot
return
fi
+ # Depending on the selected libc, we may or may not have the ${multi_os_dir_gcc}
+ # created by libc installation. If we do, use it. If we don't, use ${multi_os_dir}
+ # to avoid creating an otherwise empty directory.
+ dst_dir="${multi_root}/lib/${multi_os_dir_gcc}"
+ if [ ! -d "${dst_dir}" ]; then
+ dst_dir="${multi_root}/lib/${multi_os_dir}"
+ fi
+ CT_SanitizeVarDir dst_dir gcc_dir
+
ls "${gcc_dir}" | while read f; do
case "${f}" in
*.ld)
@@ -812,8 +839,8 @@ gcc_movelibs() {
;;
esac
if [ -f "${gcc_dir}/${f}" ]; then
- CT_DoExecLog ALL mkdir -p "${multi_root}/lib/${multi_os_dir}"
- CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${multi_root}/lib/${multi_os_dir}/${f}"
+ CT_DoExecLog ALL mkdir -p "${dst_dir}"
+ CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${dst_dir}/${f}"
fi
done
}
diff --git a/scripts/build/internals.sh b/scripts/build/internals.sh
index 95fb72b..a1c9b55 100644
--- a/scripts/build/internals.sh
+++ b/scripts/build/internals.sh
@@ -1,5 +1,27 @@
# This file contains crosstool-NG internal steps
+create_ldso_conf()
+{
+ local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count multi_target
+ local b d
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoExecLog ALL mkdir -p "${multi_root}/etc"
+ for b in /lib /usr/lib /usr/local/lib; do
+ d="${b}/${multi_os_dir}"
+ CT_SanitizeVarDir d
+ echo "${d}" >> "${multi_root}/etc/ld.so.conf"
+ if [ "${multi_os_dir}" != "${multi_os_dir_gcc}" ]; then
+ d="${b}/${multi_os_dir_gcc}"
+ CT_SanitizeVarDir d
+ echo "${d}" >> "${multi_root}/etc/ld.so.conf"
+ fi
+ done
+}
+
# This step is called once all components were built, to remove
# un-wanted files, to add tuple aliases, and to add the final
# crosstool-NG-provided files.
@@ -10,7 +32,14 @@ do_finish() {
local gcc_version
local exe_suffix
- CT_DoStep INFO "Cleaning-up the toolchain's directory"
+ CT_DoStep INFO "Finalizing the toolchain's directory"
+
+ if [ "${CT_SHARED_LIBS}" = "y" ]; then
+ # Create /etc/ld.so.conf
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-create-ldso"
+ CT_IterateMultilibs create_ldso_conf create-ldso
+ CT_Popd
+ fi
if [ "${CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES}" = "y" ]; then
case "$CT_HOST" in
@@ -103,25 +132,8 @@ do_finish() {
# Create the aliases to the target tools
CT_DoLog EXTRA "Creating toolchain aliases"
- CT_Pushd "${CT_PREFIX_DIR}/bin"
- for t in "${CT_TARGET}-"*; do
- if [ -n "${CT_TARGET_ALIAS}" ]; then
- _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
- CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
- fi
- if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
- _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
- if [ "${_t}" = "${t}" ]; then
- CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
- else
- CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
- fi
- fi
- done
- CT_Popd
-
- CT_DoLog EXTRA "Removing access to the build system tools"
- CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
+ CT_SymlinkTools "${CT_PREFIX_DIR}/bin" "${CT_PREFIX_DIR}/bin" \
+ "${CT_TARGET_ALIAS}" "${CT_TARGET_ALIAS_SED_EXPR}"
# Remove the generated documentation files
if [ "${CT_REMOVE_DOCS}" = "y" ]; then
diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh
index 569183a..a630633 100644
--- a/scripts/build/libc/glibc.sh
+++ b/scripts/build/libc/glibc.sh
@@ -297,6 +297,8 @@ do_libc_backend_once() {
# or even after they get installed...
echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
+ CT_SymlinkToolsMultilib
+
# Configure with --prefix the way we want it on the target...
# There are a whole lot of settings here. You'll probably want
# to read up on what they all mean, and customize a bit, possibly
diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh
index 4ccb84c..5a53fd0 100644
--- a/scripts/build/libc/musl.sh
+++ b/scripts/build/libc/musl.sh
@@ -29,7 +29,9 @@ do_libc() {
}
do_libc_post_cc() {
- :
+ # MUSL creates dynamic linker symlink with absolute path - which works on the
+ # target but not on the host. We want our cross-ldd tool to work.
+ CT_MultilibFixupLDSO
}
do_libc_backend() {
@@ -102,6 +104,8 @@ do_libc_backend_once() {
extra_config+=( "--includedir=/usr/include/${hdr_install_subdir}" )
fi
+ CT_SymlinkToolsMultilib
+
# NOTE: musl handles the build/host/target a little bit differently
# then one would expect:
# build : not used
diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh
index fcabee8..9f1eb37 100644
--- a/scripts/build/libc/uClibc.sh
+++ b/scripts/build/libc/uClibc.sh
@@ -453,51 +453,5 @@ do_libc_post_cc() {
# file in /lib. Thus, need to do this after all the variants are built.
# Moreover, need to do this after the final compiler is built: on targets
# that use elf2flt, the core compilers cannot find ld when running elf2flt.
- CT_DoStep INFO "Checking dynamic linker symlinks"
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-post_cc"
- echo "int main(void) { return 0; }" > test-ldso.c
- CT_IterateMultilibs do_libc_ldso_fixup ldso_fixup
- CT_Popd
- CT_EndStep
-}
-
-do_libc_ldso_fixup() {
- local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
- local binary
- local ldso ldso_f ldso_d multilib_dir
-
- for arg in "$@"; do
- eval "${arg// /\\ }"
- done
-
- CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'"
-
- multilib_dir="/lib/${multi_os_dir}"
- CT_SanitizeVarDir multilib_dir
-
- CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags}
- if [ -r "test-ldso.gdb" ]; then
- binary="test-ldso.gdb"
- else
- binary="test-ldso"
- fi
- if ${CT_TARGET}-readelf -Wl "${binary}" | grep -q 'Requesting program interpreter: '; then
- ldso=$( ${CT_TARGET}-readelf -Wl "${binary}" | \
- grep 'Requesting program interpreter: ' | \
- sed -e 's,.*: ,,' -e 's,\].*,,' )
- fi
- CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'"
-
- ldso_d="${ldso%/ld*.so.*}"
- ldso_f="${ldso##*/}"
- # Create symlink if GCC produced an executable, dynamically linked, it was requesting
- # a linker not in the current directory, and there is no such file in the expected
- # ldso dir.
- if [ -n "${ldso}" -a "${ldso_d}" != "${multilib_dir}" -a ! -r "${multi_root}${ldso}" ]; then
- # Convert ldso_d to "how many levels we need to go up" and remove
- # leading slash.
- ldso_d=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' )
- CT_DoExecLog ALL ln -sf "${ldso_d}${multilib_dir}/${ldso_f}" \
- "${multi_root}${ldso}"
- fi
+ CT_MultilibFixupLDSO
}
diff --git a/scripts/functions b/scripts/functions
index 969e9bf..ab141d5 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -1750,15 +1750,156 @@ CT_IterateMultilibs() {
dir_postfix=_${multi_dir//\//_}
dir_postfix=${dir_postfix%_.}
CT_mkdir_pushd "${prefix}${dir_postfix}"
- $func multi_dir="${multi_dir}" \
- multi_os_dir="${multi_os_dir}" \
- multi_flags="${multi_flags}" \
- multi_root="${multi_root}" \
- multi_target="${multi_target}" \
- multi_index="${multi_index}" \
- multi_count="${#multilibs[@]}" \
+ $func multi_dir="${multi_dir}" \
+ multi_os_dir="${multi_os_dir}" \
+ multi_os_dir_gcc="${multi_os_dir_gcc}" \
+ multi_flags="${multi_flags}" \
+ multi_root="${multi_root}" \
+ multi_target="${multi_target}" \
+ multi_index="${multi_index}" \
+ multi_count="${#multilibs[@]}" \
"$@"
CT_Popd
multi_index=$((multi_index+1))
done
}
+
+# Create symbolic links in buildtools for binutils using a different
+# target name.
+# Usage:
+# CT_SymlinkTools BIN-DIR SRC-DIR NEW-PREFIX SED-EXPR
+CT_SymlinkTools()
+{
+ local bindir="$1"
+ local srcdir="$2"
+ local newpfx="$3"
+ local sedexpr="$4"
+ local dirpfx
+ local t _t
+
+ # if bindir==srcdir, create symlinks just with the filename
+ if [ "${bindir}" != "${srcdir}" ]; then
+ dirpfx="${srcdir}/"
+ fi
+
+ CT_Pushd "${srcdir}"
+ for t in "${CT_TARGET}-"*; do
+ if [ -n "${newpfx}" -a "${newpfx}" != "${CT_TARGET}" ]; then
+ _t="${newpfx}-${t#${CT_TARGET}-}"
+ CT_DoExecLog ALL ln -sfv "${dirpfx}${t}" "${bindir}/${_t}"
+ fi
+ if [ -n "${sedexpr}" ]; then
+ _t=$( echo "${t}" | sed -r -e "${sedexpr}" )
+ if [ "${_t}" = "${t}" ]; then
+ CT_DoLog WARN "The sed expression '${sedexpr}' has no effect on '${t}'"
+ else
+ CT_DoExecLog ALL ln -sfv "${dirpfx}${t}" "${bindir}/${_t}"
+ fi
+ fi
+ done
+ CT_Popd
+}
+
+# Create symbolic links for multilib iterator. Expects ${multi_target}
+# variable to indicate the desired triplet for the tools.
+CT_SymlinkToolsMultilib()
+{
+ # Make configure detect ${target}-tool binaries even if it is different
+ # from configured tuple. Only symlink to final tools if they're executable
+ # on build.
+ CT_SymlinkTools "${CT_BUILDTOOLS_PREFIX_DIR}/bin" \
+ "${CT_BUILDTOOLS_PREFIX_DIR}/bin" "${multi_target}"
+ case "${CT_TOOLCHAIN_TYPE}" in
+ native|cross)
+ CT_SymlinkTools "${CT_BUILDTOOLS_PREFIX_DIR}/bin" \
+ "${CT_PREFIX_DIR}/bin" "${multi_target}"
+ ;;
+ esac
+}
+
+# Helper (iterator) for CT_MultilibFixupLDSO
+CT__FixupLDSO()
+{
+ local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count multi_target
+ local binary
+ local ldso ldso_l ldso_f ldso_d ldso_u multilib_dir
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'"
+
+ multilib_dir="/lib/${multi_os_dir}"
+ CT_SanitizeVarDir multilib_dir
+
+ CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags}
+ if [ -r "test-ldso.gdb" ]; then
+ binary="test-ldso.gdb"
+ else
+ binary="test-ldso"
+ fi
+ if ${CT_TARGET}-readelf -Wl "${binary}" | grep -q 'Requesting program interpreter: '; then
+ ldso=$( ${CT_TARGET}-readelf -Wl "${binary}" | \
+ grep 'Requesting program interpreter: ' | \
+ sed -e 's,.*: ,,' -e 's,\].*,,' )
+ fi
+ CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'"
+
+ # Create symlink if GCC produced a dynamically linked executable.
+ if [ -z "${ldso}" ]; then
+ return # Probably, we're building a static toolchain.
+ fi
+
+ ldso_d="${ldso%/ld*.so.*}"
+ ldso_f="${ldso##*/}"
+
+ # Convert ldso_d to "how many levels we need to go up" and remove
+ # leading slash.
+ ldso_u=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' )
+
+ # If the requested dynamic linker exists, but is a symlink - check that it is either
+ # relative (in which case, if it is readable, we trust libc to have created it properly)
+ # or otherwise, convert it from absolute (target) path to a relative path that works on
+ # both host & target.
+ if [ -L "${multi_root}${ldso}" ]; then
+ ldso_l=`readlink "${multi_root}${ldso}"`
+ case "${ldso_l}" in
+ /*) # Absolute, convert to relative
+ if [ -r "${multi_root}${ldso_l}" ]; then
+ CT_DoExecLog ALL ln -sfv "${ldso_u}${ldso_l}" "${multi_root}${ldso}"
+ else
+ CT_DoLog WARN "Compiler selects '${ldso}' as dynamic linker for '${multi_flags}'"
+ CT_DoLog WARN "but '${ldso}' is a symlink to '${ldso_l}' which is not valid on target."
+ fi
+ ;;
+ *) # Relative, must be readable
+ if [ ! -r "${multi_root}${ldso}" ]; then
+ CT_DoLog WARN "Compiler selects '${ldso}' as dynamic linker for '${multi_flags}'"
+ CT_DoLog WARN "but '${ldso}' is a symlink to '${ldso_l}' which is invalid relative symlink."
+ fi
+ ;;
+ esac
+ return
+ elif [ -r "${multi_root}${ldso}" ]; then
+ return # Not a symlink but readable - looks like libc installed a real executable.
+ fi
+
+ # Is it requesting a linker not in the current directory? uClibc case.
+ if [ "${ldso_d}" != "${multilib_dir}" ]; then
+ CT_DoExecLog ALL ln -sfv "${ldso_u}${multilib_dir}/${ldso_f}" \
+ "${multi_root}${ldso}"
+ fi
+}
+
+# Go over multilib variants and check that the requested dynamic linker
+# is present and resolves on both target and host.
+CT_MultilibFixupLDSO()
+{
+ CT_DoStep INFO "Checking dynamic linker symlinks"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-check-ldso"
+ echo "int main(void) { return 0; }" > test-ldso.c
+ CT_IterateMultilibs CT__FixupLDSO ldso_fixup
+ CT_Popd
+ CT_EndStep
+}
diff --git a/scripts/xldd.in b/scripts/xldd.in
index 0e8c0d0..d575e3c 100644
--- a/scripts/xldd.in
+++ b/scripts/xldd.in
@@ -16,6 +16,10 @@ fake_load_addr_rpath="$((0xdeadc0de))"
fake_load_addr_sysroot="$((0x8badf00d))"
ld_library_path="/lib:/usr/lib"
+need_e_class=
+need_e_flags=
+need_e_mach=
+
do_error() {
printf "%s: %s\n" "${my_name}" "$*" >&2
}
@@ -200,6 +204,35 @@ do_report_needed_found() {
"${sys}"
}
+do_check_compat() {
+ local file="${1}"
+ local info e_mach e_class e_flags
+
+ if [ ! -r "${file}" ]; then
+ return 1
+ fi
+ info=`${readelf} -Wh "${file}"`
+ e_class=`echo "${info}" | "${sed}" -nr 's/.*Class:[[:space:]]*//p'`
+ e_mach=`echo "${info}" | "${sed}" -nr 's/.*Machine:[[:space:]]*//p'`
+ e_flags=`echo "${info}" | "${sed}" -nr 's/.*Flags:[[:space:]]*//p'`
+ if [ "${e_class}" != "${need_e_class}" ]; then
+ do_trace "-> skip incompatible '%s' (class '%s', need '%s')\n" \
+ "${base}${d}/${needed}" "${e_class}" "${need_e_class}"
+ return 1
+ fi
+ if [ "${e_mach}" != "${need_e_mach}" ]; then
+ do_trace "-> skip incompatible '%s' (machine '%s', need '%s')\n" \
+ "${base}${d}/${needed}" "${e_mach}" "${need_e_mach}"
+ return 1
+ fi
+ if [ "${e_flags}" != "${need_e_flags}" ]; then
+ do_trace "-> skip incompatible '%s' (flags '%s', need '%s')\n" \
+ "${base}${d}/${needed}" "${e_flags}" "${need_e_flags}"
+ return 1
+ fi
+ return 0
+}
+
# Search a needed file, scanning ${lib_dir} in the root directory
do_find_needed() {
local needed="${1}"
@@ -229,7 +262,7 @@ do_find_needed() {
fi
for d in "${dirs[@]}"; do
do_trace "-> looking in '%s' (%s)\n" "${d}" "${where}"
- if [ -f "${base}${d}/${needed}" ]; then
+ if do_check_compat "${base}${d}/${needed}"; then
found="${d}/${needed}"
do_trace "---> found\n"
break 2
@@ -250,9 +283,11 @@ do_find_needed() {
# Scan a file for all NEEDED tags
do_process_file() {
local file="${1}"
+ local initial="${2}"
local -a save_search_rpath
local n m
local found
+ local info
do_trace "Parsing file '%s'\n" "${file}"
@@ -270,6 +305,17 @@ do_process_file() {
done
do_trace ": end search path\n"
+ if [ -n "${initial}" ]; then
+ if ! "${readelf}" -Wl "${file}" |
+ "${grep}" 'Requesting program interpreter: ' >/dev/null; then
+ printf " not a dynamic executable\n"
+ exit 1
+ fi
+ info=`${readelf} -Wh "${file}"`
+ need_e_class=`echo "${info}" | "${sed}" -nr 's/.*Class:[[:space:]]*//p'`
+ need_e_mach=`echo "${info}" | "${sed}" -nr 's/.*Machine:[[:space:]]*//p'`
+ need_e_flags=`echo "${info}" | "${sed}" -nr 's/.*Flags:[[:space:]]*//p'`
+ fi
for n in $( "${readelf}" -d "${file}" \
|"${grep}" -E '\(NEEDED\)' \
|"${sed}" -r -e 's/^.*Shared library:[[:space:]]+\[([^]]+)\].*/\1/;' \
@@ -324,6 +370,12 @@ do_scan_etc_ldsoconf() {
do_trace "Finished parsing ld.so.conf: '%s'\n" "${ldsoconf}"
}
+if [ -z "${1}" ]; then
+ show_help
+elif [ ! -r "${1}" ]; then
+ do_error "${1}: No such file or directory"
+fi
+
# Build up the full list of search directories
declare -a needed_search_path
do_trace "Adding basic lib dirs\n"
@@ -348,5 +400,5 @@ done
declare -a needed_list
declare -a search_rpath
do_trace "Scanning file '%s'\n" "${1}"
-do_process_file "${1}"
+do_process_file "${1}" initial
do_trace "Done scanning file '%s'\n" "${1}"