Skip to contentSkip to conversation

arm64: vdso: work-around broken ELF toolchains in Makefile

PATCH New Will Deacon 3 participants 4 messages Jun 19, 2015 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: vdso: work-around broken ELF toolchains in Makefile

When building the kernel with a bare-metal (ELF) toolchain, the -shared option may not be passed down to collect2, resulting in silent corruption of the vDSO image (in particular, the DYNAMIC section is omitted).

The effect of this corruption is that the dynamic linker fails to find the vDSO symbols and libc is instead used for the syscalls that we intended to optimise (e.g. gettimeofday). Functionally, there is no issue as the sigreturn trampoline is still intact and located by the kernel.

This patch fixes the problem by explicitly passing -shared to the linker when building the vDSO.

---
 arch/arm64/kernel/vdso/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/kernel/vdso/Makefile +4 -0
index ff3bddea482d..f6fe17d88da5 100644
@@ -15,6 +15,10 @@ ccflags-y := -shared -fno-common -fno-builtin
 ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \
 		$(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
 
+# Workaround for bare-metal (ELF) toolchains that neglect to pass -shared
+# down to collect2, resulting in silent corruption of the vDSO image.
+ccflags-y += -Wl,-shared
+
 obj-y += vdso.o
 extra-y += vdso.lds vdso-offsets.h
 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
Signature · 1 line
2.1.4
maintainer Applied
#1 lore raw

PATCH 1/1 arm64: vdso: work-around broken ELF toolchains in Makefile

Quoted 10 lines · Will Deacon

When building the kernel with a bare-metal (ELF) toolchain, the -shared option may not be passed down to collect2, resulting in silent corruption of the vDSO image (in particular, the DYNAMIC section is omitted).

The effect of this corruption is that the dynamic linker fails to find the vDSO symbols and libc is instead used for the syscalls that we intended to optimise (e.g. gettimeofday). Functionally, there is no issue as the sigreturn trampoline is still intact and located by the kernel.

Quoted 7 lines

This patch fixes the problem by explicitly passing -shared to the linker when building the vDSO.

Queued for 4.2. Thanks.

Signature · 1 line
Catalin
#2 lore raw

PATCH 1/1 arm64: vdso: work-around broken ELF toolchains in Makefile

In reply to Will Deacon
Quoted 3 lines · Will Deacon

When building the kernel with a bare-metal (ELF) toolchain, the -shared option may not be passed down to collect2, resulting in silent corruption of the vDSO image (in particular, the DYNAMIC section is omitted).

I checked arch/arm with

arm-none-eabi-gcc (Fedora 4.9.2-3.fc21) 4.9.2

and it doesn't seem to be affected. Do you know whether the toolchain issue is aarch64-specific?

#3 lore raw

PATCH 1/1 arm64: vdso: work-around broken ELF toolchains in Makefile

Quoted 11 lines · Nathan Lynch
Quoted 3 lines · Will Deacon

When building the kernel with a bare-metal (ELF) toolchain, the -shared option may not be passed down to collect2, resulting in silent corruption of the vDSO image (in particular, the DYNAMIC section is omitted).

I checked arch/arm with

arm-none-eabi-gcc (Fedora 4.9.2-3.fc21) 4.9.2

and it doesn't seem to be affected. Do you know whether the toolchain issue is aarch64-specific?

I don't know for sure, but it seems to affect all AArch64 toolchains so from your observations, arch/arm/ should be ok.

Will