Skip to contentSkip to conversation

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

PATCH In review Richard Purdie 4 participants 4 messages Sep 29, 2015 – 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.

meta/classes/image-mklibs.bbclass +4 -20
index c455a8e..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"
-			;;
-		i586 )
-			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 d4bb3ae..4bb090d 100644
@@ -2,6 +2,8 @@ do_rootfs[depends] += "prelink-native:do_populate_sysroot"
 
 IMAGE_PREPROCESS_COMMAND += "prelink_image; "
 
+inherit linuxloader
+
 prelink_image () {
 #	export PSEUDO_DEBUG=4
 #	/bin/env | /bin/grep PSEUDO
@@ -20,8 +22,11 @@ prelink_image () {
 		dummy_prelink_conf=false;
 	fi
 
+	# 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..578df14
@@ -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"
+			;;
+		i586 )
+			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
Quoted 102 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.

meta/classes/image-mklibs.bbclass +0 -0
index c455a8e..45a66fb 100644
@@ -2,6 +2,8 @@ do_rootfs[depends] += "mklibs-native:do_populate_sysroot"
 

IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "

meta/classes/image-mklibs.bbclass +2 -0
+inherit linuxloader
+
mklibs_optimize_image_doit() {
	rm -rf ${WORKDIR}/mklibs
	mkdir -p ${WORKDIR}/mklibs/dest
meta/classes/image-mklibs.bbclass +2 -20
@@ -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"
-			;;
-		i586 )
-			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 +0 -0
index d4bb3ae..4bb090d 100644
@@ -2,6 +2,8 @@ do_rootfs[depends] += "prelink-native:do_populate_sysroot"
 

IMAGE_PREPROCESS_COMMAND += "prelink_image; "

meta/classes/image-prelink.bbclass +2 -0
+inherit linuxloader
+

prelink_image () {
# export PSEUDO_DEBUG=4
# /bin/env | /bin/grep PSEUDO

meta/classes/image-prelink.bbclass +4 -1
@@ -20,8 +22,11 @@ prelink_image () {
 		dummy_prelink_conf=false;
 	fi
 
+	# 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 +13 -0
new file mode 100644
index 0000000..578df14
@@ -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"
+			;;
+		i586 )

meta/classes/linuxloader.bbclass line 23

Quoted 10 lines
meta/classes/linuxloader.bbclass new file +10 -0
+			dynamic_loader="${base_libdir}/ld-linux.so.2"
+			;;
+		arm )
+			dynamic_loader="${base_libdir}/ld-linux.so.3"
+			;;
+		* )
+			dynamic_loader="/unknown_dynamic_linker"
+			;;
+	esac
+}

For readability it would have been nice if it was returning the value from function so it could be used

myloader = call this function

Quoted 5 lines

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

#2 lore raw
Quoted 123 lines · Khem Raj
Quoted 2 lines

On Sep 29, 2015, at 6:27 AM, Richard Purdie <

Quoted 6 lines · [email protected]> wrote:

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.

Review

Quoted 6 lines

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

(quoted diff) +0 -0

b/meta/classes/image-mklibs.bbclass

Quoted 15 lines

index c455a8e..45a66fb 100644

meta/classes/image-mklibs.bbclass +0 -0
@@ -2,6 +2,8 @@ do_rootfs[depends] += "mklibs-native:do_populate_sysroot"
 

IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "

meta/classes/image-mklibs.bbclass +2 -0
+inherit linuxloader
+
mklibs_optimize_image_doit() {
      rm -rf ${WORKDIR}/mklibs
      mkdir -p ${WORKDIR}/mklibs/dest
meta/classes/image-mklibs.bbclass +0 -0
@@ -15,26 +17,8 @@ mklibs_optimize_image_doit() {
              | sed "s+^\./++" \
              > ${WORKDIR}/mklibs/executables.list

meta/classes/image-mklibs.bbclass mklibs_optimize_image_doit() { · line 26

Quoted 10 lines
meta/classes/image-mklibs.bbclass +0 -9
 
-     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"

Review

Quoted 17 lines
meta/classes/image-mklibs.bbclass +2 -11
-                     ;;
-             i586 )
-                     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} \
(quoted diff) +0 -0

b/meta/classes/image-prelink.bbclass

meta/classes/image-prelink.bbclass do_rootfs[depends] +=

Quoted 4 lines

index d4bb3ae..4bb090d 100644

meta/classes/image-prelink.bbclass +0 -0
@@ -2,6 +2,8 @@ do_rootfs[depends] +=

"prelink-native:do_populate_sysroot"

Quoted 9 lines

IMAGE_PREPROCESS_COMMAND += "prelink_image; "

meta/classes/image-prelink.bbclass +2 -0
+inherit linuxloader
+

prelink_image () {
# export PSEUDO_DEBUG=4
# /bin/env | /bin/grep PSEUDO

meta/classes/image-prelink.bbclass prelink_image () { · line 24

Quoted 8 lines
meta/classes/image-prelink.bbclass +3 -1
@@ -20,8 +22,11 @@ prelink_image () {
              dummy_prelink_conf=false;
      fi
 
+     # Set $dynamic_loader
+     linuxloader
+
      # prelink!
-     ${STAGING_DIR_NATIVE}${sbindir_native}/prelink --root

${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf

meta/classes/image-prelink.bbclass prelink_image () { · line 29

Quoted 1 line
meta/classes/image-prelink.bbclass +1 -0
+     ${STAGING_DIR_NATIVE}${sbindir_native}/prelink --root

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

Review

Quoted 4 lines
meta/classes/image-prelink.bbclass +0 -0
      # Remove the prelink.conf if we had to add it.
      if [ "$dummy_prelink_conf" = "true" ]; then
(quoted diff) +0 -0

b/meta/classes/linuxloader.bbclass

Quoted 6 lines

new file mode 100644
index 0000000..578df14

meta/classes/linuxloader.bbclass new file +1 -0
@@ -0,0 +1,23 @@
+

meta/classes/linuxloader.bbclass line 11

Quoted 10 lines
meta/classes/linuxloader.bbclass new file +10 -0
+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"

Quoted 4 lines
meta/classes/linuxloader.bbclass new file +2 -0
+                     ;;
+             i586 )

meta/classes/linuxloader.bbclass line 23

Quoted 10 lines
meta/classes/linuxloader.bbclass new file +10 -0
+                     dynamic_loader="${base_libdir}/ld-linux.so.2"
+                     ;;
+             arm )
+                     dynamic_loader="${base_libdir}/ld-linux.so.3"
+                     ;;
+             * )
+                     dynamic_loader="/unknown_dynamic_linker"
+                     ;;
+     esac
+}
Quoted 5 lines

For readability it would have been nice if it was returning the value from function so it could be used

myloader = call this function

Agreed, I was just thinking this could be used for UNINATIVE_LOADER in uninative.bbclass.

#3 lore raw
Quoted 7 lines · Christopher Larson
Quoted 3 lines · Khem Raj
Quoted 3 lines

On Sep 29, 2015, at 6:27 AM, Richard Purdie <

Quoted 4 lines · [email protected]> wrote:
Quoted 4 lines
Quoted 4 lines

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

Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines

option avoids this.

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

(quoted diff) +0 -0

b/meta/classes/image-mklibs.bbclass

Quoted 4 lines
Quoted 4 lines

meta/classes/image-mklibs.bbclass do_rootfs[depends] +=

Quoted 4 lines

index c455a8e..45a66fb 100644

meta/classes/image-mklibs.bbclass +0 -0
@@ -2,6 +2,8 @@ do_rootfs[depends] +=

"mklibs-native:do_populate_sysroot"

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

IMAGE_PREPROCESS_COMMAND += "mklibs_optimize_image; "

meta/classes/image-mklibs.bbclass +2 -0
+inherit linuxloader
+
mklibs_optimize_image_doit() {
      rm -rf ${WORKDIR}/mklibs
      mkdir -p ${WORKDIR}/mklibs/dest
meta/classes/image-mklibs.bbclass +0 -0
@@ -15,26 +17,8 @@ mklibs_optimize_image_doit() {
              | sed "s+^\./++" \
              > ${WORKDIR}/mklibs/executables.list
 
Quoted 9 lines
Quoted 9 lines

meta/classes/image-mklibs.bbclass mklibs_optimize_image_doit() {

Quoted 9 lines
meta/classes/image-mklibs.bbclass +0 -9
-     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"

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
meta/classes/image-mklibs.bbclass +2 -11
-                     ;;
-             i586 )
-                     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
 
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
meta/classes/image-mklibs.bbclass +0 -0
      mklibs -v \
              --ldlib ${dynamic_loader} \
(quoted diff) +0 -0

b/meta/classes/image-prelink.bbclass

Quoted 4 lines
Quoted 4 lines

meta/classes/image-prelink.bbclass do_rootfs[depends] +=

Quoted 4 lines

index d4bb3ae..4bb090d 100644

meta/classes/image-prelink.bbclass +0 -0
@@ -2,6 +2,8 @@ do_rootfs[depends] +=

"prelink-native:do_populate_sysroot"

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

IMAGE_PREPROCESS_COMMAND += "prelink_image; "

meta/classes/image-prelink.bbclass +2 -0
+inherit linuxloader
+

prelink_image () {
# export PSEUDO_DEBUG=4
# /bin/env | /bin/grep PSEUDO

meta/classes/image-prelink.bbclass +0 -0
@@ -20,8 +22,11 @@ prelink_image () {
              dummy_prelink_conf=false;
      fi
 
Quoted 5 lines
Quoted 5 lines

meta/classes/image-prelink.bbclass prelink_image () {

Quoted 5 lines
meta/classes/image-prelink.bbclass +3 -1
+     # Set $dynamic_loader
+     linuxloader
+
      # prelink!
-     ${STAGING_DIR_NATIVE}${sbindir_native}/prelink --root

${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf

Quoted 1 line
Quoted 1 line

meta/classes/image-prelink.bbclass prelink_image () { · line 29

Quoted 1 line
meta/classes/image-prelink.bbclass +1 -0
+     ${STAGING_DIR_NATIVE}${sbindir_native}/prelink --root

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

Quoted 4 lines
Quoted 4 lines

Review

Quoted 4 lines
meta/classes/image-prelink.bbclass +0 -0
      # Remove the prelink.conf if we had to add it.
      if [ "$dummy_prelink_conf" = "true" ]; then
(quoted diff) +0 -0

b/meta/classes/linuxloader.bbclass

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

new file mode 100644
index 0000000..578df14

meta/classes/linuxloader.bbclass new file +3 -0
@@ -0,0 +1,23 @@
+
+linuxloader () {
+     case ${TARGET_ARCH} in
Quoted 8 lines
Quoted 8 lines

meta/classes/linuxloader.bbclass

Quoted 8 lines
meta/classes/linuxloader.bbclass new file +8 -0
+             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"

Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
meta/classes/linuxloader.bbclass new file +12 -0
+                     ;;
+             i586 )
+                     dynamic_loader="${base_libdir}/ld-linux.so.2"
+                     ;;
+             arm )
+                     dynamic_loader="${base_libdir}/ld-linux.so.3"
+                     ;;
+             * )
+                     dynamic_loader="/unknown_dynamic_linker"
+                     ;;
+     esac
+}
Quoted 1 line
Quoted 1 line

For readability it would have been nice if it was returning the value

from function so it could be used

Quoted 5 lines
Quoted 2 lines

myloader = call this function

Agreed, I was just thinking this could be used for UNINATIVE_LOADER in

uninative.bbclass.

Quoted 3 lines

--

This would also be handy for the go stuff I'm writing at $work.