Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | do_rootfs[depends] += "prelink-native:do_populate_sysroot" |
| 2 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 3 | IMAGE_PREPROCESS_COMMAND_append_libc-glibc = " prelink_setup; prelink_image; " |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 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 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 36 | dynamic_loader=${@get_linuxloader(d)} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 37 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | # prelink! |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 39 | if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 40 | bbnote " prelink: BUILD_REPRODUCIBLE_BINARIES..." |
| 41 | if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then |
| 42 | export PRELINK_TIMESTAMP=`git log -1 --pretty=%ct ` |
| 43 | else |
| 44 | export PRELINK_TIMESTAMP=$REPRODUCIBLE_TIMESTAMP_ROOTFS |
| 45 | fi |
| 46 | ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS} -am -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader |
| 47 | else |
| 48 | ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader |
| 49 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | |
| 51 | # Remove the prelink.conf if we had to add it. |
| 52 | if [ "$dummy_prelink_conf" = "true" ]; then |
| 53 | rm -f ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf |
| 54 | fi |
| 55 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 56 | if [ -e $ldsoconf.prelink ]; then |
| 57 | mv $ldsoconf.prelink $ldsoconf |
| 58 | else |
| 59 | rm $ldsoconf |
| 60 | fi |
| 61 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | pre_prelink_size=`du -ks ${IMAGE_ROOTFS} | awk '{size = $1 ; print size }'` |
| 63 | echo "Size after prelinking $pre_prelink_size." |
| 64 | } |