summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2018-02-12 10:52:01 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-02-15 13:28:54 +0000
commit3e10060c99d6752236317c7590a0aa7563193346 (patch)
tree93c4bfc7868be4991dc1e2a6cae9616fb6013ee2
parent60ff32e38df02dc29aa161f922789b42f2ebb19c (diff)
downloadpoky-3e10060c99d6752236317c7590a0aa7563193346.tar.gz
icecc-create-env: Use program interpreter for deps
ldd cannot always be used to determine a program's dependencies correctly, particularly when the program specifies an alternate program interpreter (dynamic loader). This commonly happens when using a uninative tarball. Instead, determine the program's requested interpreter, and ask it to list the dependencies. (From OE-Core rev: 96d5831ef0e535d3f91acd3e979316355fbde04e) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xmeta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env20
1 files changed, 17 insertions, 3 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 c838256f74..7636d090a4 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
@@ -6,6 +6,12 @@
6 6
7target_files= 7target_files=
8 8
9is_dynamic_elf ()
10{
11 # Is the file an dynamically linked ELF executable?
12 (file -L "$1" | grep 'ELF' > /dev/null 2>&1) && (! file -L "$1" | grep 'static' > /dev/null 2>&1)
13}
14
9is_contained () 15is_contained ()
10{ 16{
11 case " $target_files " in 17 case " $target_files " in
@@ -34,8 +40,16 @@ add_file ()
34 target_files="$target_files $toadd" 40 target_files="$target_files $toadd"
35 if test -x "$path"; then 41 if test -x "$path"; then
36 # Only call ldd when it makes sense 42 # Only call ldd when it makes sense
37 if file -L "$path" | grep 'ELF' > /dev/null 2>&1; then 43 if is_dynamic_elf "$path"; then
38 if ! file -L "$path" | grep 'static' > /dev/null 2>&1; then 44 # Request the program interpeter (dynamic loader)
45 interp=`readelf -w -l "$path" | grep "Requesting program interpreter:" | sed "s/\s*\[Requesting program interpreter:\s*\(.*\)\]/\1/g"`
46
47 if test -n "$interp" && test -x "$interp"; then
48 # Use the dynamic loaders --list argument to list the
49 # depenencies. The program may have a a different program
50 # interpeter (typical when using uninative tarballs), which is
51 # why we can't just call ldd.
52 #
39 # ldd now outputs ld as /lib/ld-linux.so.xx on current nptl based glibc 53 # ldd now outputs ld as /lib/ld-linux.so.xx on current nptl based glibc
40 # this regexp parse the outputs like: 54 # this regexp parse the outputs like:
41 # ldd /usr/bin/gcc 55 # ldd /usr/bin/gcc
@@ -43,7 +57,7 @@ add_file ()
43 # libc.so.6 => /lib/tls/libc.so.6 (0xb7e81000) 57 # libc.so.6 => /lib/tls/libc.so.6 (0xb7e81000)
44 # /lib/ld-linux.so.2 (0xb7fe8000) 58 # /lib/ld-linux.so.2 (0xb7fe8000)
45 # covering both situations ( with => and without ) 59 # covering both situations ( with => and without )
46 for lib in `ldd "$path" | sed -n 's,^[^/]*\(/[^ ]*\).*,\1,p'`; do 60 for lib in `$interp --list "$path" | sed -n 's,^[^/]*\(/[^ ]*\).*,\1,p'`; do
47 test -f "$lib" || continue 61 test -f "$lib" || continue
48 # Check wether the same library also exists in the parent directory, 62 # Check wether the same library also exists in the parent directory,
49 # and prefer that on the assumption that it is a more generic one. 63 # and prefer that on the assumption that it is a more generic one.