Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | do_rootfs[depends] += "prelink-native:do_populate_sysroot" |
| 2 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 3 | IMAGE_PREPROCESS_COMMAND += "prelink_setup; prelink_image; " |
| 4 | |
| 5 | python prelink_setup () { |
| 6 | oe.utils.write_ld_so_conf(d) |
| 7 | } |
| 8 | |
| 9 | inherit linuxloader |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | |
| 11 | prelink_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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 22 | cp ${STAGING_ETCDIR_NATIVE}/prelink.conf \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf |
| 24 | dummy_prelink_conf=true; |
| 25 | else |
| 26 | dummy_prelink_conf=false; |
| 27 | fi |
| 28 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 29 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | # prelink! |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 39 | ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | |
| 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 46 | if [ -e $ldsoconf.prelink ]; then |
| 47 | mv $ldsoconf.prelink $ldsoconf |
| 48 | else |
| 49 | rm $ldsoconf |
| 50 | fi |
| 51 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | pre_prelink_size=`du -ks ${IMAGE_ROOTFS} | awk '{size = $1 ; print size }'` |
| 53 | echo "Size after prelinking $pre_prelink_size." |
| 54 | } |