[oe-commits] [openembedded-core] 29/29: image-mklibs: handle position independent binaries

git at git.openembedded.org git at git.openembedded.org
Wed Mar 9 22:46:20 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 18b0bdac30773ddb448e9370d74695c933832724
Author: Tyler Hall <tylerwhall at gmail.com>
AuthorDate: Tue Mar 8 21:07:40 2016 -0500

    image-mklibs: handle position independent binaries
    
    Executables built with -fpie have the ELF type DYN rather than EXEC
    which makes them difficult to distinguish from shared libraries.
    Currently when building the list of executables we omit these binaries
    so they might fail to run on the resultant rootfs due to missing
    symbols. One of these is systemd which builds -fpie unconditionally, so
    mklibs breaks images containing systemd.
    
    Modify the search to catch all executable files that are ELF and have an
    interpreter set. Omit libc and libpthread as special cases because they
    have an interpreter and are directly executable but treating them as
    such is antithetical to the pupose of mklibs.
    
    Signed-off-by: Tyler Hall <tylerwhall at gmail.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/image-mklibs.bbclass | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/meta/classes/image-mklibs.bbclass b/meta/classes/image-mklibs.bbclass
index 6c0e8dc..5f6df1b 100644
--- a/meta/classes/image-mklibs.bbclass
+++ b/meta/classes/image-mklibs.bbclass
@@ -9,13 +9,15 @@ mklibs_optimize_image_doit() {
 	mkdir -p ${WORKDIR}/mklibs/dest
 	cd ${IMAGE_ROOTFS}
 	du -bs > ${WORKDIR}/mklibs/du.before.mklibs.txt
-	for i in `find .`; do file $i; done \
-		| grep ELF \
-		| grep "LSB *executable" \
-		| grep "dynamically linked" \
-		| sed "s/:.*//" \
-		| sed "s+^\./++" \
-		> ${WORKDIR}/mklibs/executables.list
+
+	# Build a list of dynamically linked executable ELF files.
+	# Omit libc/libpthread as a special case because it has an interpreter
+	# but is primarily what we intend to strip down.
+	for i in `find . -type f -executable ! -name 'libc-*' ! -name 'libpthread-*'`; do
+		file $i | grep -q ELF || continue
+		${HOST_PREFIX}readelf -l $i | grep -q INTERP || continue
+		echo $i
+	done > ${WORKDIR}/mklibs/executables.list
 
 	dynamic_loader=$(linuxloader)
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list