Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 687116 - sys-kernel/gentoo-sources-5.1.6 with ld.gold: Invalid absolute R_X86_64_32S relocation: _etext
Summary: sys-kernel/gentoo-sources-5.1.6 with ld.gold: Invalid absolute R_X86_64_32S r...
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
: 687330 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-06-01 06:21 UTC by Michael Mair-Keimberger (iamnr3)
Modified: 2019-10-10 12:16 UTC (History)
9 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
kernel.config (kernel.config,110.07 KB, text/plain)
2019-06-01 06:21 UTC, Michael Mair-Keimberger (iamnr3)
Details
emerge --info (emerge-info.txt,6.89 KB, text/plain)
2019-06-01 07:34 UTC, Marien Zwart
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Mair-Keimberger (iamnr3) 2019-06-01 06:21:45 UTC
Created attachment 578240 [details]
kernel.config

Hi,

I cannot compile the latest kernel because of following error:

  LD      vmlinux.o
  MODPOST vmlinux.o
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  CC      arch/x86/boot/a20.o
  AS      arch/x86/boot/bioscall.o
  CC      arch/x86/boot/cmdline.o
  AS      arch/x86/boot/copy.o
  HOSTCC  arch/x86/boot/mkcpustr
  CPUSTR  arch/x86/boot/cpustr.h
  CC      arch/x86/boot/cpu.o
  CC      arch/x86/boot/cpuflags.o
  CC      arch/x86/boot/cpucheck.o
  CC      arch/x86/boot/early_serial_console.o
  CC      arch/x86/boot/edd.o
  LDS     arch/x86/boot/compressed/vmlinux.lds
  AS      arch/x86/boot/compressed/head_64.o
  VOFFSET arch/x86/boot/compressed/../voffset.h
  CC      arch/x86/boot/compressed/misc.o
  CC      arch/x86/boot/compressed/string.o
  CC      arch/x86/boot/compressed/cmdline.o
  CC      arch/x86/boot/compressed/error.o
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  RELOCS  arch/x86/boot/compressed/vmlinux.relocs
Invalid absolute R_X86_64_32S relocation: _etext
make[2]: *** [arch/x86/boot/compressed/Makefile:130: arch/x86/boot/compressed/vmlinux.relocs] Error 1
make[2]: *** Deleting file 'arch/x86/boot/compressed/vmlinux.relocs'
make[1]: *** [arch/x86/boot/Makefile:112: arch/x86/boot/compressed/vmlinux] Error 2
make: *** [arch/x86/Makefile:283: bzImage] Error 2



emerge --info:
Portage 2.3.67 (python 3.6.8-final-0, default/linux/amd64/17.1, gcc-9.1.0, glibc-2.29-r2, 5.1.4-gentoo x86_64)
=================================================================
System uname: Linux-5.1.4-gentoo-x86_64-AMD_FX-tm-8350_Eight-Core_Processor-with-gentoo-2.6
KiB Mem:    16410700 total,   9881560 free
KiB Swap:    8388604 total,   7946532 free
Timestamp of repository gentoo: Fri, 31 May 2019 17:04:40 +0000
Head commit of repository gentoo: aaa7486539a341dacd9a3140473aed80681ad7a8

Head commit of repository local: 823c6c1d3092c720717eb377426b1a04b3ab5c32

Timestamp of repository steam-overlay: Fri, 24 May 2019 22:43:51 +0000
Head commit of repository steam-overlay: d1e03db68b34cb28d87ac5595e7eaaa3c77d3bf6

sh bash 5.0_p7
ld GNU gold (Gentoo 2.32 p2 2.32.0) 1.16
app-shells/bash:          5.0_p7::gentoo
dev-lang/perl:            5.30.0::gentoo
dev-lang/python:          2.7.16::gentoo, 3.6.8::gentoo
dev-util/cmake:           3.14.4::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/openrc:          0.41.2::gentoo
sys-apps/sandbox:         2.17::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.32-r1::gentoo
sys-devel/gcc:            9.1.0::gentoo
sys-devel/gcc-config:     2.0::gentoo
sys-devel/libtool:        2.4.6-r5::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.0-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.29-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo.git
    priority: -1000

local
    location: /var/db/repos/local
    sync-type: git
    sync-uri: git@s2:local
    masters: gentoo

steam-overlay
    location: /var/db/repos/steam-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/steam-overlay.git
    masters: gentoo

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=bdver2 -mprefer-avx128"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0 /usr/share/themes/oxygen-gtk/gtk-3.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=bdver2 -mprefer-avx128"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=8 --load-average 8"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_AT.UTF-8"
LC_ALL="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en"
MAKEOPTS="-j9"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--info=progress2,name0,del0"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="aac acl alsa amd64 berkdb bzip2 cli crypt cxx dbus dri elogind exif flac fortran gdbm gif iconv ipv6 jpeg kde ldap libtirpc lzma mad mp3 mp4 multilib ncurses nls nptl openal opengl openmp opus pam pcre png python readline sdl seccomp ssl svg tcpd threads tiff truetype udev unicode vaapi vdpau vim-syntax vorbis vpx wayland webp x264 xattr xml zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="krita sheets words karbon" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx fma3 fma4 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 xop" CURL_SSL="gnutls" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="evdev libinput" KERNEL="linux" L10N="en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-1" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" QEMU_SOFTMMU_TARGETS="arm x86_64" QEMU_USER_TARGETS="arm x86_64" RUBY_TARGETS="ruby26 ruby25" USERLAND="GNU" VIDEO_CARDS="radeon radeonsi amdgpu" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS
Comment 1 Marien Zwart 2019-06-01 07:33:43 UTC
Same here. It looks like the problem involves gold: we're both using that as linker, and if I build with LD=/usr/bin/ld.bfd the problem goes away.

Someone reported the same failure to lkml (see https://lore.kernel.org/lkml/20190516135606.GA25602@probook/), but for them it went away after a distclean. That doesn't help for me: I still see it after "make clean" + manually removing everything other than my .config, and I also see it on a fresh build from "make defconfig".

Reverting the commit referenced on that thread or building with LD=/usr/bin/ld.bfd fixes things for me (and "make clean" + building without LD set breaks again).

I'm on ~amd64, same toolchain versions you have (will attach emerge --info).

I'm not familiar with linkers/relocations, so I probably won't make much headway actually debugging this.
Comment 2 Marien Zwart 2019-06-01 07:34:54 UTC
Created attachment 578304 [details]
emerge --info
Comment 3 Perfect Gentleman 2019-06-01 10:24:11 UTC
confirm. the same problem on all my 3 PCs
Comment 4 Andy Pettinger 2019-06-01 10:30:39 UTC
Confirmed https://forums.gentoo.org/viewtopic-p-8340054.html?sid=83a6a4058e0cfee90cbf40e2a33a46a7#8340054

Alas adding gentoo-sources to my no-gold.config  does not solve the problem.
Comment 5 Marien Zwart 2019-06-01 14:56:46 UTC
(In reply to Andy Pettinger from comment #4)
> Alas adding gentoo-sources to my no-gold.config  does not solve the problem.

Can you clarify what that config is / how you're building the kernel? Using something like /etc/portage/package.env to change LD when installing gentoo-sources won't help: the ebuild is only installing the source, not building it (nor saving the preferred linker into the source tree).

I normally build the kernel by running "make", I changed that to "make LD=/usr/bin/ld.bfd" to get the kernel to link without gold.
Comment 6 Andy Pettinger 2019-06-01 16:19:11 UTC
(In reply to Marien Zwart from comment #5)
> (In reply to Andy Pettinger from comment #4)
> > Alas adding gentoo-sources to my no-gold.config  does not solve the problem.
> 
> Can you clarify what that config is / how you're building the kernel? Using
> something like /etc/portage/package.env to change LD when installing
> gentoo-sources won't help: the ebuild is only installing the source, not
> building it (nor saving the preferred linker into the source tree).
> 
> I normally build the kernel by running "make", I changed that to "make
> LD=/usr/bin/ld.bfd" to get the kernel to link without gold.

Yes you’re right of course ! I did as you said after make distclean I managed to build the kernel. Pity that gold doesn’t work any more :(
Comment 7 Maxim Britov 2019-06-02 07:52:19 UTC
With KASRL OFF 5.1.6 builds fine for me
CONFIG_RANDOMIZE_BASE=n (Randomize the address of the kernel image (KASLR)
Comment 8 Marien Zwart 2019-06-02 14:47:23 UTC
https://lore.kernel.org/lkml/tip-a29dba161ad1a01bbfbc80aa184b089ddd169a4e@git.kernel.org/ is interesting: not just does it fix the same error for a different symbol, it involves a list of symbols that confuse the linker that are "typically defined outside any section in the linker script", and the change that triggered this build failure moved _etext out of the .text section in the linker script.

I've confirmed that adding _etext to that list in arch/x86/tools/relocs.c makes it build, but as I really have no idea what I'm doing I haven't tried to boot the resulting kernel.
Comment 9 Raymond Jennings 2019-06-04 19:14:49 UTC
*** Bug 687330 has been marked as a duplicate of this bug. ***
Comment 10 Raymond Jennings 2019-06-04 19:16:37 UTC
I just filed another bug on this at 687330, should I go ahead and respond to the upstream lkml thread referred to by chithanh in comment 4 of that bug?
Comment 11 Chí-Thanh Christopher Nguyễn gentoo-dev 2019-06-04 20:17:15 UTC
Reverting this makes the problem go away:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=392bef709659abea614abfe53cf228e7a59876a4

Upstream discussion:
https://lkml.org/lkml/2019/5/14/330
Comment 12 Luigi 'Comio' Mantellini 2019-06-05 16:20:45 UTC
Same issue with 5.1.7.
The only way to make is to add _etext to arch/x86/tools/relocs.c as already said by Marien Zwart.

ciao

luigi
Comment 13 Marien Zwart 2019-06-06 10:46:19 UTC
Reverting the commit from comment #11 (same one mentioned in comment #2) or falling back to ld.bfd is the safest fix here (assuming you're not building with Clang LTO + CFI).

I've confirmed the change from comment #8 boots for me, and it might be the right fix. But I really don't know what I'm doing with linkers, so I wouldn't recommend others to apply it. Glad to hear it worked for someone else, though :)
Comment 14 Luigi 'Comio' Mantellini 2019-06-10 10:32:11 UTC
Fixed on mainline 5.1.8:


commit 474ec2dcfbcf268a4124145b5e08847595f67a4c
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Jun 5 20:40:30 2019 +0200

    Revert "x86/build: Move _etext to actual end of .text"
    
    This reverts commit 392bef709659abea614abfe53cf228e7a59876a4.
    
    It seems to cause lots of problems when using the gold linker, and no
    one really needs this at the moment, so just revert it from the stable
    trees.
    
    Cc: Sami Tolvanen <samitolvanen@google.com>
    Reported-by: Kees Cook <keescook@chromium.org>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Reported-by: Alec Ari <neotheuser@gmail.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Comment 15 Mike Pagano gentoo-dev 2019-06-10 19:24:48 UTC
Thanks for reporting the fix in 5.1.8.
Comment 16 Bernd 2019-07-12 12:11:32 UTC
I have a regression on this bug for gentoo-sources-5.2.0. Passing LD=/usr/bin/ld.bfd to make lets build the kernel again. The patch included in comment #14 worked until 5.1.16, the latest kernel I had installed.
Comment 17 Michael Mair-Keimberger (iamnr3) 2019-07-12 14:35:46 UTC
I'm reopening this bug. I've also hit this problem again when trying to build gentoo-sources-5.2
Comment 18 Marien Zwart 2019-07-15 10:45:51 UTC
5.2.0 broke it again, 5.2.1 fixes it again (commit 7ce6dfc897ac018c6370370dff1cd03c330c4815 in https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.2.1). gentoo-sources-5.2.1 builds ok with ld.gold here.

Looks like the 5.1.x revert only went to the stable tree, the 5.2.x revert is a backport of a revert in Linus' tree, so it'll probably stay fixed this time.
Comment 19 Bernd 2019-07-15 18:25:05 UTC
5.2.1 worked again for me too.
Comment 20 Liam Shepherd 2019-08-06 13:40:05 UTC
A commit has been added to the linux-build tree that will fail the build if gold is detected: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=for-next&id=cbcbb02867d1eee5e00b954028227e344bead469

Full conversation here: https://lore.kernel.org/lkml/alpine.DEB.2.21.1907161434260.1767@nanos.tec.linutronix.de/#t

So if you use the mainline kernel, you should probably expect this to stop working again in the future.
Comment 21 Mike Pagano gentoo-dev 2019-10-10 12:16:49 UTC
As someone else noted, the gold linker is not supported by upstream and will now explicitly fail when discovered.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=75959d44f9dc