binutils: Let crosssdk gold linker generate 4096 btyes long .interp section
PATCH 1/4 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
@@ -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
PATCH 2/4 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]
--- .../gcc/gcc-cross-canadian.inc | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +20 -0
@@ -139,6 +139,26 @@ 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*) + 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
Re: [PATCH 2/4] gcc-cross-canadian: Install gcc/g++ wrappers for musl
Hi Khem,
Thanks for looking into this. I applied your patch on top of our zeus branch (I think the issue is in zeus, dunfell, master).
meta/recipes-devtools/gcc/gcc-cross-canadian.inc
Quoted 8 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]
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +0
-0
Can you elaborate why this is the proper solution over just TARGET_CC_ARCH_append_linux-musl = " --mmusl" in toolchain-scripts.bbclass?
meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 143
Quoted 2 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +2
-0+ + for i in linux ${CANADIANEXTRAOS}
Why keep linux in here?
meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 148
Quoted 5 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +5
-0+ do + for v in ${CANADIANEXTRAVENDOR} + do + d=${D}${bindir}/../${TARGET_ARCH}$v-$i + install -d $d
Hmm, even for the non-musl case?
meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 154
Quoted 6 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +6
-0+ 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*) + echo "#!/usr/bin/env sh" > $d/$p
$d/$p already exists at this point, and it's a softlink to the actual gcc. The redirected output will end up in the *target* of the softlink; this replaces the actual gcc compiler binary by a script, which calls itself.
It ends up being a recursive invocation.
I have added rm -f $d/$p above to fix this locally, while testing.
meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 157
Quoted 3 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +3
-0+ echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p + chmod 0755 $d/$p + ;;
Regards,
Leon.
Re: [PATCH 2/4] gcc-cross-canadian: Install gcc/g++ wrappers for musl
Quoted 12 lines · Leon Woestenberg
Hi Khem,
Thanks for looking into this. I applied your patch on top of our zeus branch (I think the issue is in zeus, dunfell, master).
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
meta/recipes-devtools/gcc/gcc-cross-canadian.inc
Quoted 3 lines
[YOCTO #13459]
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +0
-0Can you elaborate why this is the proper solution over just TARGET_CC_ARCH_append_linux-musl = " --mmusl" in toolchain-scripts.bbclass?
this helps in keeping signatures the same when building SDK for musl as well as glibc, changing TARGET_CC_ARCH based on target OS means signatures will change for sdk environment recipe.
Quoted 6 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 143
Quoted 3 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +2
-0+ + for i in linux ${CANADIANEXTRAOS}Why keep linux in here?
Quoted 7 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 148
Quoted 5 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +5
-0+ do + for v in ${CANADIANEXTRAVENDOR} + do + d=${D}${bindir}/../${TARGET_ARCH}$v-$i + install -d $dHmm, even for the non-musl case?
this whole logic is taken from cross-canadian bbclass.
Quoted 8 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 154
Quoted 7 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +6
-0+ 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*) + echo "#!/usr/bin/env sh" > $d/$p
Quoted 7 lines
$d/$p already exists at this point, and it's a softlink to the actual gcc. The redirected output will end up in the *target* of the softlink; this replaces the actual gcc compiler binary by a script, which calls itself.
It ends up being a recursive invocation.I have added rm -f $d/$p above to fix this locally, while testing.
you should have tried v2
Quoted 8 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc do_install () { · line 157
Quoted 4 lines
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +3
-0+ echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p + chmod 0755 $d/$p + ;;Regards,
Leon.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [OE-core] [PATCH 2/4] gcc-cross-canadian: Install gcc/g++ wrappers for musl
With the rm -f $d/$p added, the links generated earlier are first removed, then replaced by the wrapper, as expected.
We have tested this to work correctly.
(This fixes the bug where the first echo ... > would write to the softlink target, the actual gcc binary.)
This is what I have locally in my meta-fixes overlay:
meta-fixes/recipes-devtools/gcc/gcc-cross-canadian_%.bbappend:
do_install_append () {
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 -es,${TARGET_PREFIX},,`
case $i in
*musl*)
# %d/$p is a link to the
compiler, if we redirect output to it, the target will be overwritten
rm -f $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
}Regards.
Leon.
PATCH 3/4 gcc-cross-canadian: Correct the regexp to delete versioned gcc binary
In reply to Khem RajAfter 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
@@ -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
PATCH 4/4 gcc-cross-canadian: Stop chown'ing D to root
In reply to Khem RajWe run under pseudo and this should no longer be needed
--- meta/recipes-devtools/gcc/gcc-cross-canadian.inc | 2 -- 1 file changed, 2 deletions(-)
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +0 -2
@@ -136,8 +136,6 @@ do_install () { cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ - chown -R root:root ${D} - cross_canadian_bindirlinks for i in linux ${CANADIANEXTRAOS}
Signature · 1 line
2.28.0
Re: [PATCH 4/4] gcc-cross-canadian: Stop chown'ing D to root
Please ignore this one.
Quoted 24 lines · Khem Raj
We run under pseudo and this should no longer be needed
Signed-off-by Khem Raj <[email protected]>--- meta/recipes-devtools/gcc/gcc-cross-canadian.inc | 2 -- 1 file changed, 2 deletions(-)meta/recipes-devtools/gcc/gcc-cross-canadian.inc +0
-3@@ -136,8 +136,6 @@ do_install () { cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ - chown -R root:root ${D} - cross_canadian_bindirlinks for i in linux ${CANADIANEXTRAOS} --2.28.0