blob: 4157df021a7439e6a1304adcf2e35044174da5c5 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001do_rootfs[depends] += "prelink-native:do_populate_sysroot"
2
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05003IMAGE_PREPROCESS_COMMAND += "prelink_setup; prelink_image; "
4
5python prelink_setup () {
6 oe.utils.write_ld_so_conf(d)
7}
8
9inherit linuxloader
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010
11prelink_image () {
12# export PSEUDO_DEBUG=4
13# /bin/env | /bin/grep PSEUDO
14# echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
15# echo "LD_PRELOAD=$LD_PRELOAD"
16
17 pre_prelink_size=`du -ks ${IMAGE_ROOTFS} | awk '{size = $1 ; print size }'`
18 echo "Size before prelinking $pre_prelink_size."
19
20 # We need a prelink conf on the filesystem, add one if it's missing
21 if [ ! -e ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050022 cp ${STAGING_ETCDIR_NATIVE}/prelink.conf \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf
24 dummy_prelink_conf=true;
25 else
26 dummy_prelink_conf=false;
27 fi
28
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050029 # We need a ld.so.conf with pathnames in,prelink conf on the filesystem, add one if it's missing
30 ldsoconf=${IMAGE_ROOTFS}${sysconfdir}/ld.so.conf
31 if [ -e $ldsoconf ]; then
32 cp $ldsoconf $ldsoconf.prelink
33 fi
34 cat ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf >> $ldsoconf
35
36 dynamic_loader=$(linuxloader)
37
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038 # prelink!
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039 ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040
41 # Remove the prelink.conf if we had to add it.
42 if [ "$dummy_prelink_conf" = "true" ]; then
43 rm -f ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf
44 fi
45
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050046 if [ -e $ldsoconf.prelink ]; then
47 mv $ldsoconf.prelink $ldsoconf
48 else
49 rm $ldsoconf
50 fi
51
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 pre_prelink_size=`du -ks ${IMAGE_ROOTFS} | awk '{size = $1 ; print size }'`
53 echo "Size after prelinking $pre_prelink_size."
54}