Bug 187841 - x32 VDSO fails to build (relocation overflow) when Gold is the system default linker
Summary: x32 VDSO fails to build (relocation overflow) when Gold is the system default...
Status: NEW
Alias: None
Product: Platform Specific/Hardware
Classification: Unclassified
Component: x86-64 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: platform_x86_64@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-16 09:40 UTC by Matt Whitlock
Modified: 2019-02-17 18:35 UTC (History)
6 users (show)

See Also:
Kernel Version: 4.8.8-gentoo
Tree: Mainline
Regression: No


Attachments

Description Matt Whitlock 2016-11-16 09:40:26 UTC
While executing the recipe for arch/x86/entry/vdso/vdsox32.so:

  gcc -nostdlib -o arch/x86/entry/vdso/vdsox32.so.dbg -fPIC -shared  -Wl,--hash-style=both  -Wl,--build-id -Wl,-Bsymbolic  -Wl,-m,elf32_x86_64 -Wl,-soname=linux-vdso.so.1 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 -Wl,-T,arch/x86/entry/vdso/vdsox32.lds arch/x86/entry/vdso/vdso-note-x32.o arch/x86/entry/vdso/vclock_gettime-x32.o arch/x86/entry/vdso/vgetcpu-x32.o && sh ./arch/x86/entry/vdso/checkundef.sh 'nm' 'arch/x86/entry/vdso/vdsox32.so.dbg'

arch/x86/entry/vdso/vclock_gettime-x32.o:vclock_gettime.c:function __vdso_clock_gettime: error: relocation overflow: reference to 'vvar_vsyscall_gtod_data'
arch/x86/entry/vdso/vclock_gettime-x32.o:vclock_gettime.c:function __vdso_gettimeofday: error: relocation overflow: reference to 'vvar_vsyscall_gtod_data'
arch/x86/entry/vdso/vclock_gettime-x32.o:vclock_gettime.c:function __vdso_time: error: relocation overflow: reference to 'vvar_vsyscall_gtod_data'
collect2: error: ld returned 1 exit status

This error causes the subsequent call to objcopy to fail, thus aborting the build.

  objcopy -S  arch/x86/entry/vdso/vdsox32.so.dbg arch/x86/entry/vdso/vdsox32.so
objcopy: 'arch/x86/entry/vdso/vdsox32.so.dbg': No such file
make[3]: *** [arch/x86/entry/vdso/Makefile:124: arch/x86/entry/vdso/vdsox32.so] Error 1


$ ld --version | head -n1
GNU gold (Gentoo 2.27 p1.0 2.27) 1.12


A workaround is to force usage of the BFD linker when linking the x32 VDSO:

--- arch/x86/entry/vdso/Makefile~	2016-10-02 23:24:33.000000000 +0000
+++ arch/x86/entry/vdso/Makefile	2016-11-16 09:35:13.406216597 +0000
@@ -97,6 +97,7 @@
 
 CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
 VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \
+			   -fuse-ld=bfd \
 			   -Wl,-soname=linux-vdso.so.1 \
 			   -Wl,-z,max-page-size=4096 \
 			   -Wl,-z,common-page-size=4096

Then vdsox32.so.dbg links without error.

This problem just started happening upon upgrading from binutils 2.26.1 to 2.27.
Comment 1 Markus Trippelsdorf 2017-03-07 16:33:28 UTC
See: https://sourceware.org/bugzilla/show_bug.cgi?id=20833
Comment 2 Rion 2018-07-22 16:34:36 UTC
same problem. same solution
gentoo-sources-4.14.56
Comment 3 Matt Whitlock 2018-10-25 00:43:34 UTC
The workaround in Comment #0 is no longer sufficient as of Linux 4.19. Now I additionally must specify "LD=ld.bfd" on the 'make' command line.
Comment 4 seirra blake 2018-12-27 23:41:04 UTC
with 4.20 i couldn't even do that, i had to temporarily change default linker

Note You need to log in before you can comment on or make changes to this bug.