Skip to contentSkip to conversation

binutils: Let crosssdk gold linker generate 4096 btyes long .interp section

PATCH In review Khem Raj 3 participants 7 messages Aug 20, 2020 – Aug 21, 2020

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/3 binutils: Let crosssdk gold linker generate 4096 btyes long .interp section

When gold is used as default linker in crosssdk e.g. when building SDK binaries with LTO, the binaries do not have large enough .interp section size and SDK relocation fails for those nativesdk binaries and libraries which used gold for linking. This patch extends the .interp relaxation fix to gold

---
 ...s-crosssdk-Generate-relocatable-SDKs.patch | 26 +++++++++++++++----
 1 file changed, 21 insertions(+), 5 deletions(-)
meta/recipes-devtools/binutils/binutils/0001-binutils-crosssdk-Generate-relocatable-SDKs.patch +21 -5
index 0e62d47616..4c1d11291b 100644
@@ -1,22 +1,38 @@
-From b8d182865081d17549fb9a4b9bc3062b526caf65 Mon Sep 17 00:00:00 2001
+From a0b23b160d6cfa7be4437c6e623633d76395f2ad Mon Sep 17 00:00:00 2001
 From: Khem Raj <[email protected]>
 Date: Mon, 2 Mar 2015 01:58:54 +0000
-Subject: [PATCH 01/17] binutils-crosssdk: Generate relocatable SDKs
+Subject: [PATCH 01/16] binutils-crosssdk: Generate relocatable SDKs
 
 This patch will modify the ELF linker scripts so that the crosssdk
 linker will generate binaries with a 4096 bytes PT_INTERP section. When the binaries
 will be relocated, at SDK install time, the interpreter path can be easily
 changed by the relocating script.
 
+generate larger .interp section for gold linker as well
+
 Upstream-Status: Inappropriate [SDK specific]
 
 Signed-off-by: Laurentiu Palcu <[email protected]>
 Signed-off-by: Khem Raj <[email protected]>
 ---
+ gold/layout.cc        | 2 +-
  ld/genscripts.sh      | 3 +++
  ld/scripttempl/elf.sc | 4 ++--
- 2 files changed, 5 insertions(+), 2 deletions(-)
+ 3 files changed, 6 insertions(+), 3 deletions(-)
 
+diff --git a/gold/layout.cc b/gold/layout.cc
+index 13e533aaf21..b0afff16e2e 100644
+--- a/gold/layout.cc
++++ b/gold/layout.cc
+@@ -5019,7 +5019,7 @@ Layout::create_interp(const Target* target)
+       gold_assert(interp != NULL);
+     }
+ 
+-  size_t len = strlen(interp) + 1;
++  size_t len = 4096;
+ 
+   Output_section_data* odata = new Output_data_const(interp, len, 1);
+ 
 diff --git a/ld/genscripts.sh b/ld/genscripts.sh
 index 03392d265c7..435689ea144 100755
 --- a/ld/genscripts.sh
@@ -43,10 +59,10 @@ index 03392d265c7..435689ea144 100755
  DATA_ALIGNMENT=${DATA_ALIGNMENT_}
  RELOCATING=" "
 diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
-index 0b8b32a4407..ee6b71075d7 100644
+index eb74743e5c3..c9a8a47615f 100644
 --- a/ld/scripttempl/elf.sc
 +++ b/ld/scripttempl/elf.sc
-@@ -140,8 +140,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
+@@ -143,8 +143,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
      DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
    fi
  fi
Signature · 1 line
2.28.0
author
#1 lore raw

PATCH v2 2/3 gcc-cross-canadian: Install gcc/g++ wrappers for musl

gcc needs -mmusl option to be passed in SDK since we ship crossdk compiler configured for glibc by default, this helps in creating correct compiler defaults for musl based SDK compilers

[YOCTO #13459]

Cc Leon Woestenberg <[email protected]>

---
v2: Delete file before creating wrapper

 .../gcc/gcc-cross-canadian.inc                | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +23 -0
index 553ef7fe62..c5935b978d 100644
@@ -139,6 +139,29 @@ do_install () {
 	chown -R root:root ${D}
 	
 	cross_canadian_bindirlinks
+
+	for i in linux ${CANADIANEXTRAOS}
+	do
+		for v in ${CANADIANEXTRAVENDOR}
+		do
+			d=${D}${bindir}/../${TARGET_ARCH}$v-$i
+			install -d $d
+			for j in ${TARGET_PREFIX}gcc${EXEEXT} ${TARGET_PREFIX}g++${EXEEXT}
+			do
+				p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
+				case $i in
+				*musl*)
+					rm -rf $d/$p
+					echo "#!/usr/bin/env sh" > $d/$p
+					echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p
+					chmod 0755 $d/$p
+					;;
+				*)
+					;;
+				esac
+			done
+		done
+	done
 }
 
 ELFUTILS = "nativesdk-elfutils"
Signature · 1 line
2.28.0
Tested-by Acked-by on v2 2/3
#2 lore raw

Re: [PATCH V2 2/3] gcc-cross-canadian: Install gcc/g++ wrappers for musl

Quoted 5 lines · Khem Raj

gcc needs -mmusl option to be passed in SDK since we ship crossdk compiler configured for glibc by default, this helps in creating correct compiler defaults for musl based SDK compilers

Quoted 7 lines

[YOCTO #13459]

Cc Leon Woestenberg <[email protected]>

---
v2: Delete file before creating wrapper

Thanks, v2 works and solves [YOCTO #13459]. We already independently had the same v1->v2 fix locally, while we tested your v1 approach (and ignored the mailing list...)

author
#3 lore raw

Re: [PATCH V2 2/3] gcc-cross-canadian: Install gcc/g++ wrappers for musl

Quoted 14 lines · Leon Woestenberg
Quoted 5 lines · Khem Raj

gcc needs -mmusl option to be passed in SDK since we ship crossdk compiler configured for glibc by default, this helps in creating correct compiler defaults for musl based SDK compilers

Quoted 7 lines

[YOCTO #13459]

Cc Leon Woestenberg <[email protected]>

---
v2: Delete file before creating wrapper

Quoted 6 lines

Thanks, v2 works and solves [YOCTO #13459]. We already independently had the same v1->v2 fix locally, while we tested your v1 approach (and ignored the mailing list...)

Great thanks for confirmation, happy musl'ing :)

#4 lore raw

Re: [OE-core] [PATCH V2 2/3] gcc-cross-canadian: Install gcc/g++ wrappers for musl

In reply to Khem Raj
Quoted 38 lines · Khem Raj

gcc needs -mmusl option to be passed in SDK since we ship crossdk compiler configured for glibc by default, this helps in creating correct compiler defaults for musl based SDK compilers

[YOCTO #13459]

Cc Leon Woestenberg <[email protected]>

---
v2: Delete file before creating wrapper

 .../gcc/gcc-cross-canadian.inc                | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +16 -0
index 553ef7fe62..c5935b978d 100644
@@ -139,6 +139,29 @@ do_install () {
 	chown -R root:root ${D}
 
 	cross_canadian_bindirlinks
+
+	for i in linux ${CANADIANEXTRAOS}
+	do
+		for v in ${CANADIANEXTRAVENDOR}
+		do
+			d=${D}${bindir}/../${TARGET_ARCH}$v-$i
+			install -d $d
+			for j in ${TARGET_PREFIX}gcc${EXEEXT} ${TARGET_PREFIX}g++${EXEEXT}
+			do
+				p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
+				case $i in
+				*musl*)
+					rm -rf $d/$p
+					echo "#!/usr/bin/env sh" > $d/$p
+					echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p
+					chmod 0755 $d/$p

meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 167

Quoted 10 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +7 -0
+					;;
+				*)
+					;;
+				esac
+			done
+		done
+	done
 }
 
 ELFUTILS = "nativesdk-elfutils"

I've bisected this error in mingw:

https://autobuilder.yoctoproject.org/typhoon/#/builders/89/builds/2341

to this change.

Error:
Problem: package gcc-cross-canadian-i686-10.2.0-r0.i686_nativesdk_mingw32 requires /usr/bin/env, but none of the providers can be installed
- package packagegroup-cross-canadian-qemux86-1.0-r0.i686_nativesdk_mingw32 requires gcc-cross-canadian-i686, but none of the providers can be installed
- package target-sdk-provides-dummy-1.0-r0.sdk_provides_dummy_target conflicts with /bin/sh provided by nativesdk-curl-7.71.1-r0.i686_nativesdk_mingw32
- conflicting requests
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages)

This is due to the addition of the /usr/bin/env dependency to the generated files.

I'm trying to unravel the problems but it may mean extra fixes to both meta-mingw and master handling of /bin/sh.

Cheers,

Richard

author
#5 lore raw

Re: [OE-core] [PATCH V2 2/3] gcc-cross-canadian: Install gcc/g++ wrappers for musl

Quoted 139 lines · Richard Purdie
Quoted 1 line · Khem Raj

gcc needs -mmusl option to be passed in SDK since we ship crossdk

compiler

Quoted 20 lines

configured for glibc by default, this helps in creating correct

compiler defaults for musl based SDK compilers

[YOCTO #13459]

Cc Leon Woestenberg <[email protected]>

---

v2: Delete file before creating wrapper

Review

Quoted 7 lines
 .../gcc/gcc-cross-canadian.inc                | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
(quoted diff) +0 -0

b/meta/recipes-devtools/gcc/gcc-cross-canadian.inc

Quoted 19 lines

index 553ef7fe62..c5935b978d 100644

--- a/meta/recipes-devtools/gcc/gcc-cross-canadian.inc

+++ b/meta/recipes-devtools/gcc/gcc-cross-canadian.inc

(quoted diff) +3 -0
@@ -139,6 +139,29 @@ do_install () {
 
      chown -R root:root ${D}
 
 
 
      cross_canadian_bindirlinks
 
+
 
+     for i in linux ${CANADIANEXTRAOS}
 
+     do

Review do_install () {

Quoted 10 lines
(quoted diff) +5 -0
 
+             for v in ${CANADIANEXTRAVENDOR}
 
+             do
 
+                     d=${D}${bindir}/../${TARGET_ARCH}$v-$i
 
+                     install -d $d
 
+                     for j in ${TARGET_PREFIX}gcc${EXEEXT}

${TARGET_PREFIX}g++${EXEEXT}

meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () {

Quoted 3 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +2 -0
+                     do
 
+                             p=${TARGET_ARCH}$v-$i-`echo $j | sed -e

s,${TARGET_PREFIX},,`

Review

Quoted 9 lines
(quoted diff) +5 -0
+                             case $i in
 
+                             *musl*)
 
+                                     rm -rf $d/$p
 
+                                     echo "#!/usr/bin/env sh" > $d/$p
 
+                                     echo "exec \`dirname

\$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p

Quoted 11 lines
(quoted diff) +6 -0
+                                     chmod 0755 $d/$p
 
+                                     ;;
 
+                             *)
 
+                                     ;;
 
+                             esac
 
+                     done

Review

Quoted 10 lines
(quoted diff) +2 -0
 
+             done
 
+     done
 
 }
 
 
 
 ELFUTILS = "nativesdk-elfutils"

I've bisected this error in mingw:

https://autobuilder.yoctoproject.org/typhoon/#/builders/89/builds/2341

to this change.

Error:

Problem: package gcc-cross-canadian-i686-10.2.0-r0.i686_nativesdk_mingw32
requires /usr/bin/env, but none of the providers can be installed

- package
packagegroup-cross-canadian-qemux86-1.0-r0.i686_nativesdk_mingw32 requires gcc-cross-canadian-i686, but none of the providers can be installed

- package target-sdk-provides-dummy-1.0-r0.sdk_provides_dummy_target
conflicts with /bin/sh provided by nativesdk-curl-7.71.1-r0.i686_nativesdk_mingw32

- conflicting requests

(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages)

This is due to the addition of the /usr/bin/env dependency to the

Quoted 7 lines

generated files.

I'm trying to unravel the problems but it may mean extra fixes to both

meta-mingw and master handling of /bin/sh.

Maybe we can call out /bin/sh directly will that work on mingw

Quoted 13 lines

Cheers,

Richard

author
#6 lore raw

PATCH v2 3/3 gcc-cross-canadian: Correct the regexp to delete versioned gcc binary

In reply to Khem Raj

After gcc 10 this expression needed to be adjusted, its better to use a bitbake variable which we do have readily available

---
 meta/recipes-devtools/gcc/gcc-cross-canadian.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +1 -1
index c5935b978d..d3875c94d3 100644
@@ -106,7 +106,7 @@ do_install () {
 	rm -f ${D}${bindir}/*c++
 
 	# We don't care about the gcc-<version> copies
-	rm -f ${D}${bindir}/*gcc-?.?*
+	rm -f ${D}${bindir}/*gcc-${BINV}*
 
 	# Cleanup empty directories which are not shipped
 	# we use rmdir instead of 'rm -f' to ensure the non empty directories are not deleted
Signature · 1 line
2.28.0