[OE-core] [PATCH] prelink: Allow it to work on 64 bit binaries in /lib

Mark Hatle mark.hatle at windriver.com
Tue Sep 29 18:11:46 UTC 2015


On 9/29/15 12:12 PM, Khem Raj wrote:
> 
>> On Sep 29, 2015, at 6:26 AM, Richard Purdie <richard.purdie at linuxfoundation.org> wrote:
>>
>> Checks within prelink force 64 bit binaries into lib64 and n32 binaries
>> into lib32. We load prelink.conf with all combinations but this code
>> then defeats it for us and means /lib is ignored.
>>
>> Comment out this code to disable it and allow our settings to work. This
>> allows 64 bit binaries in /lib to work. We pass in the correct dyanamic
>> loader path anyhow and our binaries don't contain ld.so so this should
>> be safe for us.
>>
>> Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
>>
>> diff --git a/meta/recipes-devtools/prelink/prelink/64bitfix.patch b/meta/recipes-devtools/prelink/prelink/64bitfix.patch
>> new file mode 100644
>> index 0000000..74b1a7d
>> --- /dev/null
>> +++ b/meta/recipes-devtools/prelink/prelink/64bitfix.patch
>> @@ -0,0 +1,35 @@
>> +These checks force 64 bit binaries into lib64 and n32 binaries into lib32. We
>> +load prelink.conf with all combinations but this code then defeats it for us
>> +and means /lib is ignored.
>> +
>> +Comment out this code to disable it and allow our settings to work. This
>> +allows 64 bit binaries in /lib to work. We pass in the correct dyanamic
>> +loader path anyhow and our binaries don't contain ld.so so this should be
>> +safe for us.
>> +
>> +Upstream-Status: Inappropriate
>> +RP 2015/9/23
>> +
>> +
>> +Index: trunk/src/rtld/rtld.c
>> +===================================================================
>> +--- trunk.orig/src/rtld/rtld.c
>> ++++ trunk/src/rtld/rtld.c
>> +@@ -334,7 +334,7 @@ load_ld_so_conf (int use_64bit, int use_
>> +
>> +   /* Only use the correct machine, to prevent mismatches if we
>> +      have both /lib/ld.so and /lib64/ld.so on x86-64.  */
>> +-  if (use_64bit)
>> ++  /*if (use_64bit)
> 
> may be it would be good to use it as fallback if nothing comes out of prelink.conf
> such a patch would be acceptable upstream too.

This is the emulated rtld that prelink uses.  It's only in the cross-prelink.

As far as I can tell the previous 'upstream prelink' is abandon-ware now.. so
cross-prelink is more or less the new (final) upstream.

This code block is from the original (cross) prelink work done back in roughly
2006.  Obviously things have changed a bit since then.

However, this code will break the normal multilib use-case.  So I don't think it
can be generically applied.

The dst_LIB value being set to only 'lib' won't be set properly.  (dst_LIB is
used when executables or libraries have embedded '$LIB', this is similar to
$PLATFORM, or $ORIGIN...)  So any executables using it in their internal search
paths will reference the wrong values in a any config where 'libdir' isn't '/lib'.

The 'ld_dirs' is used by the dynamic search capabilities of the emulated rtld.
So when something says give me "libfoo.so.1".  It uses the ld_dirs to search for
the library.  Again if the libdir is not '/lib' then it won't find the libraries
and prelinking may abort for that particular item.

>> +     {
>> +       dst_LIB = "lib64";
>> +       add_dir (&ld_dirs, "/lib64/tls", strlen ("/lib64/tls"));
>> +@@ -350,7 +350,7 @@ load_ld_so_conf (int use_64bit, int use_
>> +       add_dir (&ld_dirs, "/usr/lib32/tls", strlen ("/usr/lib32/tls"));
>> +       add_dir (&ld_dirs, "/usr/lib32", strlen ("/usr/lib32"));
>> +     }
>> +-  else
>> ++  else*/
>> +     {
>> +       dst_LIB = "lib";
>> +       add_dir (&ld_dirs, "/lib/tls", strlen ("/lib/tls"));

If we were to only comment out the last 'else'.  We still have the dst_LIB issue
as mentioned above.. (what is the right value?)

It also open up the possibility though where the system has a flaw -- where an
ELF64/ELF N32 is on the system and asks for libfoo.so.1, but that was not
installed for the 64-bit/n32 system.  It will fall back and find it in the
'32-bit' side and use that for the processing....  (I'm not sure if prelink has
the ability to detect that there is a mismatch between the two executables.)

The rtld as far as I can remember does nothing globally to make sure that the
binaries are all for the same machine type... (this may be a bug that could be
easily fixed given a good test case, like what I suggested above.  Pull the
machine from the executable and skip any libraries that are not of the same
machine type....)


An alternative to all of this would be only applying the path if BASELIB == lib?

--Mark

>> diff --git a/meta/recipes-devtools/prelink/prelink_git.bb b/meta/recipes-devtools/prelink/prelink_git.bb
>> index 79a5f501..0cbce36 100644
>> --- a/meta/recipes-devtools/prelink/prelink_git.bb
>> +++ b/meta/recipes-devtools/prelink/prelink_git.bb
>> @@ -27,6 +27,7 @@ FILES_${PN}-cron = "${sysconfdir}/cron.daily ${sysconfdir}/default"
>> PACKAGES =+ "${PN}-cron"
>>
>> SRC_URI = "git://git.yoctoproject.org/prelink-cross.git;branch=cross_prelink \
>> +           file://64bitfix.patch \
>>            file://prelink.conf \
>>            file://prelink.cron.daily \
>>            file://prelink.default \
>>
>>
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core at lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
> 
> 
> 




More information about the Openembedded-core mailing list