From: Joshua Watt <jpewhacker@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [sumo][PATCH 3/7] icecc-create-env: Fix library interpreter usage
Date: Tue, 10 Apr 2018 21:21:56 -0500 [thread overview]
Message-ID: <20180411022200.22277-4-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20180411022200.22277-1-JPEWhacker@gmail.com>
Shared libraries sometimes (frequently?) don't have a program
interpreter specified. The previous code would fail to find the library
dependencies in these cases because no interpreter could be found.
Commonly, this meant that if a library depends on another library, it
might not be included toolchain because dependency scanning stops with
the first one.
Instead, capture the program interpreter from the program or library
that starts the dependency chain and use that interpreter to get all of
the dependencies in the chain, recursively.
Additionally, if no interpreter can be found, fallback to using ldd
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
.../icecc-create-env/icecc-create-env | 112 ++++++++++++++-------
1 file changed, 77 insertions(+), 35 deletions(-)
diff --git a/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env b/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
index 3015f4e2155..b88c53a424b 100755
--- a/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
+++ b/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
@@ -99,48 +99,90 @@ normalize_path ()
echo $path
}
-add_file ()
+add_file_common()
+{
+ local p="$1"
+ local path="$2"
+ local alias="$3"
+
+ add_alias "$path" "$p"
+ if test -n "$alias"; then
+ add_alias "$path" "$alias"
+ fi
+
+ add_path "$path" || return 1
+ print_debug "Adding file '$path'"
+
+ return 0
+}
+
+add_deps()
+{
+ local path="$1"
+ local interp="$2"
+
+ if test -n "$interp" && test -x "$interp"; then
+ # Use the dynamic loaders --list argument to list the
+ # dependencies. The program may have a different program
+ # interpreter (typical when using uninative tarballs), which is
+ # why we can't just call ldd.
+ deps="`$interp --list "$path"`"
+ else
+ deps="`ldd "$path"`"
+ fi
+
+ print_debug "Dependencies are:"
+ print_debug "$deps"
+ if test -n "$deps"; then
+ for lib in $deps; do
+ # ldd now outputs ld as /lib/ld-linux.so.xx on current nptl
+ # based glibc this regexp parse the outputs like:
+ # ldd /usr/bin/gcc
+ # linux-gate.so.1 => (0xffffe000)
+ # libc.so.6 => /lib/tls/libc.so.6 (0xb7e81000)
+ # /lib/ld-linux.so.2 (0xb7fe8000)
+ # covering both situations ( with => and without )
+ lib="`echo "$lib" | sed -n 's,^[^/]*\(/[^ ]*\).*,\1,p'`"
+
+ test -f "$lib" || continue
+ # Check whether the same library also exists in the parent
+ # directory, and prefer that on the assumption that it is a
+ # more generic one.
+ local baselib=`echo "$lib" | sed 's,\(/[^/]*\)/.*\(/[^/]*\)$,\1\2,'`
+ test -f "$baselib" && lib=$baselib
+ add_dependency "$lib" "$interp"
+ done
+ fi
+}
+
+add_dependency()
{
local p=`normalize_path $1`
# readlink is required for Yocto, so we can use it
local path=`readlink -f "$p"`
+ local interp="$2"
- add_alias "$path" "$p"
- if test -n "$2"; then
- add_alias "$path" "$2"
+ add_file_common "$p" "$path" || return
+
+ if test -x "$path" && is_dynamic_elf "$path"; then
+ add_deps "$path" "$interp"
fi
+}
- add_path "$path" || return
-
- if test -x "$path"; then
- # Only call ldd when it makes sense
- if is_dynamic_elf "$path"; then
- # Request the program interpeter (dynamic loader)
- interp=`readelf -w -l "$path" | grep "Requesting program interpreter:" | sed "s/\s*\[Requesting program interpreter:\s*\(.*\)\]/\1/g"`
-
- if test -n "$interp" && test -x "$interp"; then
- # Use the dynamic loaders --list argument to list the
- # depenencies. The program may have a a different program
- # interpeter (typical when using uninative tarballs), which is
- # why we can't just call ldd.
- #
- # ldd now outputs ld as /lib/ld-linux.so.xx on current nptl based glibc
- # this regexp parse the outputs like:
- # ldd /usr/bin/gcc
- # linux-gate.so.1 => (0xffffe000)
- # libc.so.6 => /lib/tls/libc.so.6 (0xb7e81000)
- # /lib/ld-linux.so.2 (0xb7fe8000)
- # covering both situations ( with => and without )
- for lib in `$interp --list "$path" | sed -n 's,^[^/]*\(/[^ ]*\).*,\1,p'`; do
- test -f "$lib" || continue
- # Check wether the same library also exists in the parent directory,
- # and prefer that on the assumption that it is a more generic one.
- local baselib=`echo "$lib" | sed 's,\(/[^/]*\)/.*\(/[^/]*\)$,\1\2,'`
- test -f "$baselib" && lib=$baselib
- add_file "$lib"
- done
- fi
- fi
+add_file ()
+{
+ local p=`normalize_path $1`
+ # readlink is required for Yocto, so we can use it
+ local path=`readlink -f "$p"`
+
+ add_file_common "$p" "$path" "$2" || return
+
+ if test -x "$path" && is_dynamic_elf "$path"; then
+ # Request the program interpeter (dynamic loader)
+ interp=`readelf -W -l "$path" | grep "Requesting program interpreter:" | sed "s/\s*\[Requesting program interpreter:\s*\(.*\)\]/\1/g"`
+ print_debug "Interpreter is '$interp'"
+
+ add_deps "$path" "$interp"
fi
}
--
2.14.3
next prev parent reply other threads:[~2018-04-11 2:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-11 2:21 [sumo][PATCH 0/7] Icecream fixes Joshua Watt
2018-04-11 2:21 ` [sumo][PATCH 1/7] icecc-create-env: Allow logging to a file Joshua Watt
2018-04-11 2:21 ` [sumo][PATCH 2/7] icecc-create-env: Fix RUNPATH files Joshua Watt
2018-04-11 2:21 ` Joshua Watt [this message]
2018-04-11 2:21 ` [sumo][PATCH 4/7] icecc-create-env: Add extra tools option Joshua Watt
2018-04-11 2:21 ` [sumo][PATCH 5/7] icecc.bbclass: Add ICECC_ENV_DEBUG variable Joshua Watt
2018-04-11 2:21 ` [sumo][PATCH 6/7] icecc.bbclass: Improve error reporting Joshua Watt
2018-04-11 2:22 ` [sumo][PATCH 7/7] icecc.bbclass: Bump version number Joshua Watt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180411022200.22277-4-JPEWhacker@gmail.com \
--to=jpewhacker@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox