Skip to contentSkip to conversation

kernel-arch: Force BFD kernel when using gcc for linking

PATCH In review Khem Raj 4 participants 5 messages Aug 19, 2015

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 kernel-arch: Force BFD kernel when using gcc for linking

We redefine LD to point to ld.bfd when building kernel, which works in most cases since kbuild system calls out for bare LD most of the time, however some of newer kernels e.g. 4.1+ have some code added which can call gcc directly to do the linking job e.g. arm vdso code

This causes build failures when we have configured the default cross toolchain to use gold linker as default. Errors like

BFD: arch/arm/vdso/vdso.so: Not enough room for program headers, try linking with -N
| arm-angstrom-linux-gnueabi-objcopy:arch/arm/vdso/vdso.so[.hash]: Bad value

start happening.

With this patch we force gcc to choose bfd linker as well

---
 meta/classes/kernel-arch.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel-arch.bbclass +1 -1
index 6650870..211b72b 100644
@@ -53,7 +53,7 @@ HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
 TARGET_AR_KERNEL_ARCH ?= ""
 HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
 
-KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH}"
+KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} -fuse-ld=bfd"
 KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
 KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 8 lines · Khem Raj

We redefine LD to point to ld.bfd when building kernel, which works in most cases since kbuild system calls out for bare LD most of the time, however some of newer kernels e.g. 4.1+ have some code added which can call gcc directly to do the linking job e.g. arm vdso code

This causes build failures when we have configured the default cross toolchain to use gold linker as default. Errors like

Quoted 8 lines

BFD: arch/arm/vdso/vdso.so: Not enough room for program headers, try linking with -N
| arm-angstrom-linux-gnueabi-objcopy:arch/arm/vdso/vdso.so[.hash]: Bad value

start happening.

With this patch we force gcc to choose bfd linker as well

This is fixed upstream as of:

commit d2b30cd4b7223a96e606dfc8120626f66d81e091

Author: Nathan Lynch <[email protected]>
Date:   Wed Jun 3 00:41:15 2015 +0100

ARM: 8384/1: VDSO: force use of BFD linker

which should make it to 4.1-stable soon.

#2 lore raw
Quoted 21 lines · Nathan Lynch
Quoted 8 lines · Khem Raj

We redefine LD to point to ld.bfd when building kernel, which works in most cases since kbuild system calls out for bare LD most of the time, however some of newer kernels e.g. 4.1+ have some code added which can call gcc directly to do the linking job e.g. arm vdso code

This causes build failures when we have configured the default cross toolchain to use gold linker as default. Errors like

Quoted 8 lines

BFD: arch/arm/vdso/vdso.so: Not enough room for program headers, try linking with -N
| arm-angstrom-linux-gnueabi-objcopy:arch/arm/vdso/vdso.so[.hash]: Bad value

start happening.

With this patch we force gcc to choose bfd linker as well

This is fixed upstream as of:

Quoted 7 lines

commit d2b30cd4b7223a96e606dfc8120626f66d81e091

Author: Nathan Lynch <[email protected]>
Date:   Wed Jun 3 00:41:15 2015 +0100

ARM: 8384/1: VDSO: force use of BFD linker

which should make it to 4.1-stable soon.

CC'ing Bruce.

I'll stage the fix from Khem in my master-unde-test branch. Bruce: if you end up merging this fix into the oe-core kernels, please remind me to revert Khem's patch. :)

Ross

#3 lore raw
Quoted 31 lines · Ross

On 19 August 2015 at 20:59, Nathan Lynch <[email protected] <mailto:[email protected]>> wrote:

On 08/19/2015 12:44 PM, Khem Raj wrote:
> We redefine LD to point to ld.bfd when building kernel, which works in > most cases since kbuild system calls out for bare LD most of the time, > however some of newer kernels e.g. 4.1+ have some code added which can > call gcc directly to do the linking job e.g. arm vdso code >
> This causes build failures when we have configured the default cross > toolchain to use gold linker as default. Errors like
>
> BFD: arch/arm/vdso/vdso.so: Not enough room for program headers, try > linking with -N
> | arm-angstrom-linux-gnueabi-objcopy:arch/arm/vdso/vdso.so[.hash]: Bad > value
>
> start happening.
>
> With this patch we force gcc to choose bfd linker as well

This is fixed upstream as of:

commit d2b30cd4b7223a96e606dfc8120626f66d81e091
Author: Nathan Lynch <[email protected] <mailto:[email protected]>>
Date: Wed Jun 3 00:41:15 2015 +0100

ARM: 8384/1: VDSO: force use of BFD linker

Quoted 8 lines

which should make it to 4.1-stable soon.

CC'ing Bruce.

I'll stage the fix from Khem in my master-unde-test branch. Bruce: if you end up merging this fix into the oe-core kernels, please remind me to revert Khem's patch. :)

Noted. And will do.

Bruce

Quoted 2 lines

Ross

author
#4 lore raw
In reply to Burton, Ross
Quoted 23 lines · Ross
Quoted 22 lines · Nathan Lynch
Quoted 8 lines · Khem Raj

We redefine LD to point to ld.bfd when building kernel, which works in most cases since kbuild system calls out for bare LD most of the time, however some of newer kernels e.g. 4.1+ have some code added which can call gcc directly to do the linking job e.g. arm vdso code

This causes build failures when we have configured the default cross toolchain to use gold linker as default. Errors like

Quoted 8 lines

BFD: arch/arm/vdso/vdso.so: Not enough room for program headers, try linking with -N
| arm-angstrom-linux-gnueabi-objcopy:arch/arm/vdso/vdso.so[.hash]: Bad value

start happening.

With this patch we force gcc to choose bfd linker as well

This is fixed upstream as of:

Quoted 7 lines
Quoted 7 lines

commit d2b30cd4b7223a96e606dfc8120626f66d81e091

Author: Nathan Lynch <[email protected]>
Date:   Wed Jun 3 00:41:15 2015 +0100

ARM: 8384/1: VDSO: force use of BFD linker

which should make it to 4.1-stable soon.

it fixes one case yes, there could be many more to come. We want to make sure that we use bfd ld through out the kernel.

Quoted 7 lines

CC'ing Bruce.

I'll stage the fix from Khem in my master-unde-test branch. Bruce: if you end up merging this fix into the oe-core kernels, please remind me to revert Khem's patch. :)

There is no need to revert it. Since it convey's what we want to do in more comprehensive way i.e. to use bfd linker for all kernel links in all forms.
It covers us for future issues of similar kind