summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/icecc-create-env
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2018-02-12 10:52:04 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-02-15 13:28:54 +0000
commit971a3c0e2ace38db28f9f07c1f884abb7d6927a9 (patch)
treebf436bfc332725fe98cb5e430964749c031b1781 /meta/recipes-devtools/icecc-create-env
parent8a229332a074c1471e2bf500e357906a9fffeee0 (diff)
downloadpoky-971a3c0e2ace38db28f9f07c1f884abb7d6927a9.tar.gz
icecc-create-env: Fix executable rpaths
Executables in the toolchain archive occasionally contain runtime library search paths (RPATH) that use the $ORIGIN placeholder. However, in order for that placeholder to work, /proc must be mounted. When iceccd executes the toolchain in the chroot environment, it doesn't mount /proc, so it is unable to resolve $ORIGIN resulting in a failure to find dynamic libraries. The fix is to replace $ORIGIN in executable RPATH entries with the known chroot executable path. In order for this to work, the actual real path to the executable must be resolved to remove any symlinks, otherwise the calculate $ORIGIN replacement will be wrong. This is done by using "readlink -f", which is an acceptable dependency because Yocto already requires it. (From OE-Core rev: cfe98765b40c28a132b5a4bce39f71f06b4eb0bc) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/icecc-create-env')
-rwxr-xr-xmeta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env40
1 files changed, 37 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 426b093d91..90d249df9f 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
@@ -12,6 +12,26 @@ is_dynamic_elf ()
12 (file -L "$1" | grep 'ELF' > /dev/null 2>&1) && (! file -L "$1" | grep 'static' > /dev/null 2>&1) 12 (file -L "$1" | grep 'ELF' > /dev/null 2>&1) && (! file -L "$1" | grep 'static' > /dev/null 2>&1)
13} 13}
14 14
15fix_rpath ()
16{
17 # Patches the RPATH for a file. When the program is executed in the chroot
18 # be iceccd, /proc is not mounted. As such, $ORIGIN can't be resolved. To
19 # work around this, replace all instances of $ORIGIN in RPATH with the
20 # known chroot path to the executables directory
21 local path="$1"
22 local origin="$2"
23 if ! is_dynamic_elf "$path"; then
24 return
25 fi
26 local new_rpath="`readelf -w -d "$path" | grep RPATH | \
27 sed 's/.*\[\(.*\)\]/\1/g' | \
28 sed "s,\\\$ORIGIN,/$origin,g"`"
29
30 if test -n "$new_rpath"; then
31 $PATCHELF --set-rpath "$new_rpath" "$path"
32 fi
33}
34
15is_contained () 35is_contained ()
16{ 36{
17 case " $target_files " in 37 case " $target_files " in
@@ -47,9 +67,8 @@ add_file ()
47 name="$2" 67 name="$2"
48 fi 68 fi
49 test -z "$name" && return 69 test -z "$name" && return
50 # ls -H isn't really the same as readlink, but 70 # readlink is required for Yocto, so we can use it
51 # readlink is not portable enough. 71 path=`readlink -f "$path"`
52 path=`ls -H $path`
53 toadd="$name=$path" 72 toadd="$name=$path"
54 is_contained "$toadd" && return 73 is_contained "$toadd" && return
55 if test -z "$silent"; then 74 if test -z "$silent"; then
@@ -108,6 +127,17 @@ added_as=$1
108shift 127shift
109archive_name=$1 128archive_name=$1
110 129
130if test -z "$PATCHELF"; then
131 PATCHELF=`which patchelf 2> /dev/null`
132fi
133if test -z "$PATCHELF"; then
134 PATCHELF=`which patchelf-uninative 2> /dev/null`
135fi
136if test -z "$PATCHELF"; then
137 echo "patchelf is required"
138 exit 1
139fi
140
111if test -z "$added_gcc" || test -z "$added_gxx" ; then 141if test -z "$added_gcc" || test -z "$added_gxx" ; then
112 echo "usage: $0 <gcc_path> <g++_path>" 142 echo "usage: $0 <gcc_path> <g++_path>"
113 exit 1 143 exit 1
@@ -197,6 +227,8 @@ for i in $target_files; do
197 if test -f $tempdir/$target -a -x $tempdir/$target; then 227 if test -f $tempdir/$target -a -x $tempdir/$target; then
198 strip -s $tempdir/$target 2>/dev/null 228 strip -s $tempdir/$target 2>/dev/null
199 fi 229 fi
230
231 fix_rpath $tempdir/$target `dirname $target`
200 else 232 else
201 mkdir -p $tempdir/`dirname $path` 233 mkdir -p $tempdir/`dirname $path`
202 cp -pH $path $tempdir/$path 234 cp -pH $path $tempdir/$path
@@ -210,6 +242,8 @@ for i in $target_files; do
210 strip -s $tempdir/$path 2>/dev/null 242 strip -s $tempdir/$path 2>/dev/null
211 fi 243 fi
212 244
245 fix_rpath $tempdir/$path `dirname $path`
246
213 path=`echo $path | cut -b2-` 247 path=`echo $path | cut -b2-`
214 new_target_files="$new_target_files $path" 248 new_target_files="$new_target_files $path"
215 fi 249 fi