Bug 10282

Summary: Prelink: doesn't work on qemux86-64 on the qemu target
Product: [Yocto Project Subprojects] Cross-prelink Reporter: brian avery <brian.avery>
Component: cross-prelinkAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: richard.purdie, yp.cp.watcher, yp.watcher
Version: 2.2   
Target Milestone: 2.2 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description brian avery 2016-09-14 23:20:04 UTC
If I include prelink on the image by adding 
IMAGE_INSTALL_append= " prelink  " 

and I try to run prelink on the qemux86-64 target it fails with:
root@qemux86-64:~# prelink --verify --md5 /bin/busybox.nosuid                                                                              
prelink: /bin/busybox.nosuid: Using /lib/ld-linux-x86-64.so.2, not /lib64/ld-linux-x86-64.so.2 as dynamic linker 
prelink: /bin/busybox.nosuid disappeared while running --verify

On qemux86 it works correctly and looks like:
root@qemux86:~# prelink --verify --md5 /bin/busybox.nosuid                      
29fa665f1beb95a98422ef522dec2b3a  /bin/busybox.nosuid
Comment 1 Mark Hatle 2016-09-15 15:23:34 UTC
Can you please retest and enable the LSB library paths?

Specifically:

require conf/multilib.conf
MULTILIBS = ""

I suspect the problem is that not using proper LSB paths is confusing the prelinker's internal RTLD.  In the cross install, there is code that is specifically passing in the libc  ld.so path into the RTLD to avoid that issue.
Comment 2 brian avery 2016-09-15 21:57:42 UTC
Tried/Verified.

Adding:

require conf/multilib.conf
MULTILIBS = ""

to meta/classes/image-prelink.bbclass

resulted in a qemux86-64 target that could successfully run :
prelink --verify --md5 /bin/busybox.nosuid

It also continued to work for qemux86.
Mark, is this generic  enough to be ok as a patch?
Comment 3 Mark Hatle 2016-09-16 16:20:19 UTC
OE will not accept the change.  They want the ability to specify an arbitrary (within reason) libdir, that may not conform to LSB guidelines.

The prelink RTLD utility is expecting LSB style path names to the ld.so executable.  If this is not present, then the (target) absolute path to the ld.so must be passed in (similarly to how the cross processing does) as:

prelink <args> --dynamic-linker <path to loader>

The 'linuxloader.bbclass' has a list of the known loaders paths.

One way to deal with this could be a wrapper script to prelink (for the target)... another solution could simply be to document what is required.
Comment 4 brian avery 2016-09-16 20:24:54 UTC
Hmm, I guess I'd lean toward the docs as I shy away from obscuring things like this.

Something is not working when I try the change we would document, however.
-----
First I removied: 
require conf/multilib.conf
MULTILIBS = ""
------

Then I got the expected:
root@qemux86-64:~# prelink --verify --md5 /bin/bash                    
prelink: /bin/bash: Using /lib/ld-linux-x86-64.so.2, not /lib64/ld-linux-x86-64.so.2 as dynamic linker
prelink: /bin/bash disappeared while running --verify

------
Then I tried this
root@qemux86-64:~# prelink --verify --md5 --dynamic-linker=/lib/ld-linux-x86-64.so.2  /bin/bash                     
prelink: /bin/bash: Could not parse `/usr/sbin//prelink-rtld: error while loading shared libraries: libdl.so.2'                     
prelink: /bin/bash: at least one of file's dependencies has changed since prelinking  

and it still failed for me.  Is there something additional I should specify on the target to have it work there ?