blob: 6a8afa8fa95ae913a820a8f43850fc6b41965448 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001do_rootfs[depends] += "prelink-native:do_populate_sysroot"
2
Brad Bishopd7bf8c12018-02-25 22:55:05 -05003IMAGE_PREPROCESS_COMMAND_append_libc-glibc = " prelink_setup; prelink_image; "
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05004
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!
Brad Bishop316dfdd2018-06-25 12:45:53 -040039 if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
Brad Bishopd7bf8c12018-02-25 22:55:05 -050040 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 Williamsc124f4f2015-09-15 14:41:29 -050050
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 Williamsd8c66bc2016-06-20 12:57:21 -050056 if [ -e $ldsoconf.prelink ]; then
57 mv $ldsoconf.prelink $ldsoconf
58 else
59 rm $ldsoconf
60 fi
61
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062 pre_prelink_size=`du -ks ${IMAGE_ROOTFS} | awk '{size = $1 ; print size }'`
63 echo "Size after prelinking $pre_prelink_size."
64}