diff options
author | P. J. McDermott <pj@pehjota.net> | 2019-03-22 12:54:00 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2019-03-22 12:54:00 (EDT) |
commit | 8595ada6ead613afd47c815045a7d1b2c425a351 (patch) | |
tree | d10aaa3e2bdca0328190cfd716c7eb4232d3ba68 /src | |
parent | fa0ed86cbefd4a45d190f2ce1b2594e46addef2d (diff) |
oh-shlibdeps: Use readelf instead of ldd
Diffstat (limited to 'src')
-rw-r--r-- | src/oh-shlibdeps.sh | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/src/oh-shlibdeps.sh b/src/oh-shlibdeps.sh index cf5473e..8077166 100644 --- a/src/oh-shlibdeps.sh +++ b/src/oh-shlibdeps.sh @@ -21,24 +21,63 @@ . '@pkgdatadir@/load.sm' +LIBRARY_PATH='@library_path@' +READELF_NEEDED_SED='s/^ 0x[0-9a-f]* (NEEDED) *Shared library: \[\(.*\)\]$/\1/p' + +find_lib() +{ + local lib="${1}" + shift 1 + local pkg= + local dir= + + # Check just-built packages. + for pkg in *.data/; do + IFS=':' + for dir in ${LIBRARY_PATH}; do + unset IFS + if [ -r "${pkg}/${dir}/${lib}" ]; then + printf '%s,\n' "${pkg%.data/}" + return 0 + fi + done + unset IFS + done + + # Check installed packages. + IFS=':' + for dir in ${LIBRARY_PATH}; do + unset IFS + if [ -r "${dir}/${lib}" ]; then + lib="${dir}/${lib}" + pkg="$('@OPKG@' search "${lib}" | sed 's/ - .*$//')" + if [ -n "${pkg}" ]; then + printf '%s,\n' "${pkg}" + return 0 + else + oh_warn "$(oh_get_msg 'shlib_no_pkg')" "${lib}" + return 0 + fi + fi + done + unset IFS + + oh_warn "$(oh_get_msg 'shlib_no_lib')" "${lib}" + return 0 +} + find_needed() { local elf="${1}" shift 1 while IFS='' read -r lib; do - pkg="$('@OPKG@' search "${lib}" | sed 's/ - .*$//')" - if [ -z "${pkg}" ]; then - oh_warn "$(oh_msg 'shlib_no_pkg')" "${lib}" - else - printf '%s,\n' "${pkg}" - fi + find_lib "${lib}" done <<-EOF - $('@LDD@' "${elf}" | sed -n 's/^\t.* => \(.*\) (.*)$/\1/p' \ - 2>/dev/null) + $('@READELF@' -d "${elf}" | sed -n "${READELF_NEEDED_SED}") EOF - # The above ldd's stderr is redirected to /dev/null to hide glibc ldd's - # "you do not have execution permission" warning. + + return 0 } find_elves() |