Skip to contentSkip to conversation

linuxloader/image-prelink/image-mklibs: Fix non-standard path prelinking

PATCH In review Richard Purdie 2 participants 2 messages Mar 4, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linuxloader/image-prelink/image-mklibs: Fix non-standard path prelinking

Prelinking on x86-64 wasn't working out the box as it uses /lib and not /lib64 for libs. Prelink was refusing to link as the dynamic loader didn't match its idea of the right path. Passing in the --dyanmic-linker option avoids this.

We can share code from image-mklibs so abstract that into a new class, linuxloader.bbclass.

This does break prelinking of multilib images, I've opened a bug so we can loop back and fix that problem, the code would need to iterate the dynamic loaders (and setup ld.so.conf files for it).

meta/classes/image-mklibs.bbclass +4 -20
index cfb3ffc..45a66fb 100644
@@ -2,6 +2,8 @@ do_rootfs[depends] += "mklibs-native:do_populate_sysroot"
 
 IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "
 
+inherit linuxloader
+
 mklibs_optimize_image_doit() {
 	rm -rf ${WORKDIR}/mklibs
 	mkdir -p ${WORKDIR}/mklibs/dest
@@ -15,26 +17,8 @@ mklibs_optimize_image_doit() {
 		| sed "s+^\./++" \
 		> ${WORKDIR}/mklibs/executables.list
 
-	case ${TARGET_ARCH} in
-		powerpc | mips | mipsel | microblaze )
-			dynamic_loader="${base_libdir}/ld.so.1"
-			;;
-		powerpc64)
-			dynamic_loader="${base_libdir}/ld64.so.1"
-			;;
-		x86_64)
-			dynamic_loader="${base_libdir}/ld-linux-x86-64.so.2"
-			;;
-		i*86 )
-			dynamic_loader="${base_libdir}/ld-linux.so.2"
-			;;
-		arm )
-			dynamic_loader="${base_libdir}/ld-linux.so.3"
-			;;
-		* )
-			dynamic_loader="/unknown_dynamic_linker"
-			;;
-	esac
+	# Set $dynamic_loader 
+        linuxloader
 
 	mklibs -v \
 		--ldlib ${dynamic_loader} \
meta/classes/image-prelink.bbclass +6 -1
index 53c4b0b..3fe097b 100644
@@ -6,6 +6,8 @@ python prelink_setup () {
     oe.utils.write_ld_so_conf(d)
 }
 
+inherit linuxloader
+
 prelink_image () {
 #	export PSEUDO_DEBUG=4
 #	/bin/env | /bin/grep PSEUDO
@@ -31,8 +33,11 @@ prelink_image () {
 	fi
 	cat ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf >> $ldsoconf
 
+	# Set $dynamic_loader
+	linuxloader
+
 	# prelink!
-	${STAGING_DIR_NATIVE}${sbindir_native}/prelink --root ${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf
+	${STAGING_DIR_NATIVE}${sbindir_native}/prelink --root ${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader
 
 	# Remove the prelink.conf if we had to add it.
 	if [ "$dummy_prelink_conf" = "true" ]; then
meta/classes/linuxloader.bbclass new file +23 -0
new file mode 100644
index 0000000..af649cc
@@ -0,0 +1,23 @@
+
+linuxloader () {
+	case ${TARGET_ARCH} in
+		powerpc | mips | mipsel | microblaze )
+			dynamic_loader="${base_libdir}/ld.so.1"
+			;;
+		powerpc64)
+			dynamic_loader="${base_libdir}/ld64.so.1"
+			;;
+		x86_64)
+			dynamic_loader="${base_libdir}/ld-linux-x86-64.so.2"
+			;;
+		i*86 )
+			dynamic_loader="${base_libdir}/ld-linux.so.2"
+			;;
+		arm )
+			dynamic_loader="${base_libdir}/ld-linux.so.3"
+			;;
+		* )
+			dynamic_loader="/unknown_dynamic_linker"
+			;;
+	esac
+}
#1 lore raw

This looks good to me

Quoted 127 lines · Richard Purdie

Prelinking on x86-64 wasn't working out the box as it uses /lib and not /lib64 for libs. Prelink was refusing to link as the dynamic loader didn't match its idea of the right path. Passing in the --dyanmic-linker option avoids this.

We can share code from image-mklibs so abstract that into a new class, linuxloader.bbclass.

This does break prelinking of multilib images, I've opened a bug so we can loop back and fix that problem, the code would need to iterate the dynamic loaders (and setup ld.so.conf files for it).

meta/classes/image-mklibs.bbclass +4 -20
index cfb3ffc..45a66fb 100644
@@ -2,6 +2,8 @@ do_rootfs[depends] += "mklibs-native:do_populate_sysroot"
 
 IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "
 
+inherit linuxloader
+
 mklibs_optimize_image_doit() {
        rm -rf ${WORKDIR}/mklibs
        mkdir -p ${WORKDIR}/mklibs/dest
@@ -15,26 +17,8 @@ mklibs_optimize_image_doit() {
                | sed "s+^\./++" \
                > ${WORKDIR}/mklibs/executables.list
 
-       case ${TARGET_ARCH} in
-               powerpc | mips | mipsel | microblaze )
-                       dynamic_loader="${base_libdir}/ld.so.1"
-                       ;;
-               powerpc64)
-                       dynamic_loader="${base_libdir}/ld64.so.1"
-                       ;;
-               x86_64)
-
 dynamic_loader="${base_libdir}/ld-linux-x86-64.so.2"
-                       ;;
-               i*86 )
-                       dynamic_loader="${base_libdir}/ld-linux.so.2"
-                       ;;
-               arm )
-                       dynamic_loader="${base_libdir}/ld-linux.so.3"
-                       ;;
-               * )
-                       dynamic_loader="/unknown_dynamic_linker"
-                       ;;
-       esac
+       # Set $dynamic_loader
+        linuxloader
 
        mklibs -v \
                --ldlib ${dynamic_loader} \
meta/classes/image-prelink.bbclass +5 -1
index 53c4b0b..3fe097b 100644
@@ -6,6 +6,8 @@ python prelink_setup () {
     oe.utils.write_ld_so_conf(d)
 }
 
+inherit linuxloader
+
 prelink_image () {
 #      export PSEUDO_DEBUG=4
 #      /bin/env | /bin/grep PSEUDO
@@ -31,8 +33,11 @@ prelink_image () {
        fi
        cat ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf >> $ldsoconf
 
+       # Set $dynamic_loader
+       linuxloader
+
        # prelink!
-       ${STAGING_DIR_NATIVE}${sbindir_native}/prelink --root

${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf
+ ${STAGING_DIR_NATIVE}${sbindir_native}/prelink --root
${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader

# Remove the prelink.conf if we had to add it. if [ "$dummy_prelink_conf" = "true" ]; then

meta/classes/linuxloader.bbclass new file +23 -1
new file mode 100644
index 0000000..af649cc
@@ -0,0 +1,23 @@
+
+linuxloader () {
+       case ${TARGET_ARCH} in
+               powerpc | mips | mipsel | microblaze )
+                       dynamic_loader="${base_libdir}/ld.so.1"
+                       ;;
+               powerpc64)
+                       dynamic_loader="${base_libdir}/ld64.so.1"
+                       ;;
+               x86_64)
+
 dynamic_loader="${base_libdir}/ld-linux-x86-64.so.2"
+                       ;;
+               i*86 )
+                       dynamic_loader="${base_libdir}/ld-linux.so.2"
+                       ;;
+               arm )
+                       dynamic_loader="${base_libdir}/ld-linux.so.3"
+                       ;;
+               * )
+                       dynamic_loader="/unknown_dynamic_linker"
+                       ;;
+       esac
+}
 
 
--

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core