Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
binutils:2.31 amd64 corrupted my 4.14 kernels [solved]
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1101

PostPosted: Sat Apr 13, 2019 10:00 pm    Post subject: Reply with quote

Snippet from my kernel build bash script:
Code:
make CC="gcc -fuse-ld=bfd -Wl,-fuse-ld=bfd" LDFLAGS="-fuse-ld=bfd" -j3 -l3 all

These bfd things are remains from a former period where gold was default.

Thks 4 ur attention, interest & support.
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3929
Location: Dallas area

PostPosted: Sat Apr 13, 2019 10:25 pm    Post subject: Reply with quote

Those are kernel build flags, what I was talking about is what you have set up for the rest of the portage binaries (make.conf)

You may be building binaries (especially toolchain ones) that are causing the problem rather than the kernel itself.

Build a proper elfutils, binutils, etc and then see if the problems of the kernel go away.
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1101

PostPosted: Tue Apr 30, 2019 4:51 pm    Post subject: Reply with quote

Hi,
It so happens, I've been compiling kernel via a script for a couple of years now, culprit snippet here
Code:
make CC="gcc -fuse-ld=bfd -Wl,-fuse-ld=bfd" LDFLAGS="-fuse-ld=bfd" -j3 -l3 all
which forces the use of ld.bfd when ld.gold might be the default.
I've removed the ld.bfd cruff, as I don't ld.gold anymore.
AFAIK,
Code:
-Wl,--enable-new-dtags
has been set as default in Gentoo for quite a while now.
I think I added it to be remembered this gentoo specific.
I'm keeping it active for now.

Thks 4 ur attention, interest & support.
Back to top
View user's profile Send private message
hoegger
n00b
n00b


Joined: 06 Apr 2008
Posts: 8

PostPosted: Thu May 02, 2019 1:56 pm    Post subject: Reply with quote

Hi!

Sorry for hijacking this thread but since my issue seems to be related to the same bug I am posting it here.

After upgrading to binutils-2.31.1-r4 I am not able to build a working kernel. There is no error message, just instant reboot as soon as the system tries to execute the kernel.

Also the nvidia-drivers compile without error msg but fail on load.

After switching to binutils-2.30 everything is fine.

Xeon E3-1231 v3
kernel-4.9.34
binutils-2.31.1-r4
elfutils-0.173-r1
glibc-2.28-r6
gcc-8.2.0-r6
libtool-2.4.6-r3
llvm-6.0.1

I tried make clean —> no success
emerge -e @system —> no success
binutils-config 2.30 && . /etc/profile —> works

Should I again build @system since it is (re)built with binutils-2.31.1-r4 ?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13831

PostPosted: Fri May 03, 2019 2:06 am    Post subject: Reply with quote

hoegger: what kernel version(s) have you tried with binutils-2.31? Does a 5.0.x series kernel also fail this way?
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3929
Location: Dallas area

PostPosted: Fri May 03, 2019 9:49 am    Post subject: Reply with quote

Hmm https://www.fclose.com/linux-kernels/324105/x86-boot-64-verify-alignment-of-the-load-segment-linux-4-9-91/

The link mentions that it was applied to different kernels, link for those at link above.

Not sure if this is the problem or just part of it when combined with other parts of the toolchain.
But it is where the "alignment ... 2mb" message is being generated.

I haven't tried to recompile the kernel yet (kernel 4.14.62, gcc 8.2, glibc 2.27 and binutils 3.21) to see if it bites me.

Edit to add: and this commit
Code:
commit faf470583a5701c286c62f0dfaaa06964a8c4ed8
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Mar 19 13:57:46 2018 -0700

    x86/build/64: Force the linker to use 2MB page size
   
    commit e3d03598e8ae7d195af5d3d049596dec336f569f upstream.
   
    Binutils 2.31 will enable -z separate-code by default for x86 to avoid
    mixing code pages with data to improve cache performance as well as
    security.  To reduce x86-64 executable and shared object sizes, the
    maximum page size is reduced from 2MB to 4KB.  But x86-64 kernel must
    be aligned to 2MB.  Pass -z max-page-size=0x200000 to linker to force
    2MB page size regardless of the default page size used by linker.
   
    Tested with Linux kernel 4.15.6 on x86-64.


I mention because it specifically mentions binutils 2.31.

ETA2: Not sure what to make of things, looking at my kernel sources, -z max-page-size=0x200000, is being passed when building the kernel, so it shouldn't see a problem. Not sure if modules built outside of the kernel build pick up this parm though.
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3929
Location: Dallas area

PostPosted: Fri May 03, 2019 12:04 pm    Post subject: Reply with quote

CaptainBlood wrote:
Snippet from my kernel build bash script:
Code:
make CC="gcc -fuse-ld=bfd -Wl,-fuse-ld=bfd" LDFLAGS="-fuse-ld=bfd" -j3 -l3 all

These bfd things are remains from a former period where gold was default.


I think this might be your problem, as you're overriding the LDFLAGS from inside the makefile, you're not adding to them, you're replacing them.

I did a test,

make -n CC="gcc -fuse-ld=bfd -Wl,-fuse-ld=bfd" LDFLAGS="-fuse-ld=bfd" >/tmp/lookat 2>&1

then grep max-page /tmp/lookat (total output listed)
Code:
set -e;  echo '  VDSO    arch/x86/entry/vdso/vdso64.so.dbg'; gcc -fuse-ld=bfd -Wl,-fuse-ld=bfd -nostdlib -o arch/x86/entry/vdso/vdso64.so.dbg -fPIC -shared  -Wl,--hash-style=both  -Wl,--build-id -Wl,-Bsymbolic  -m64 -Wl,-soname=linux-vdso.so.1 -Wl,--no-undefined -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096  -Wl,-T,arch/x86/entry/vdso/vdso.lds arch/x86/entry/vdso/vdso-note.o arch/x86/entry/vdso/vclock_gettime.o arch/x86/entry/vdso/vgetcpu.o && sh ./arch/x86/entry/vdso/checkundef.sh 'nm' 'arch/x86/entry/vdso/vdso64.so.dbg'; printf '%s\n' 'cmd_arch/x86/entry/vdso/vdso64.so.dbg := gcc -fuse-ld=bfd -Wl,-fuse-ld=bfd -nostdlib -o arch/x86/entry/vdso/vdso64.so.dbg -fPIC -shared  -Wl,--hash-style=both  -Wl,--build-id -Wl,-Bsymbolic  -m64 -Wl,-soname=linux-vdso.so.1 -Wl,--no-undefined -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096  -Wl,-T,arch/x86/entry/vdso/vdso.lds arch/x86/entry/vdso/vdso-note.o arch/x86/entry/vdso/vclock_gettime.o arch/x86/entry/vdso/vgetcpu.o && sh ./arch/x86/entry/vdso/checkundef.sh '\''nm'\'' '\''arch/x86/entry/vdso/vdso64.so.dbg'\''' > arch/x86/entry/vdso/.vdso64.so.dbg.cmd


then did
make -n >/tmp/lookat2 2>&1 (no LDFLAGS, etc)

then grep max-page /tmp/lookat2 (only showing a snippet, but shows what the problem is)
Code:
set -e;  echo '  VDSO    arch/x86/entry/vdso/vdso64.so.dbg'; gcc -nostdlib -o arch/x86/entry/vdso/vdso64.so.dbg -fPIC -s
hared  -Wl,--hash-style=both  -Wl,--build-id -Wl,-Bsymbolic  -m64 -Wl,-soname=linux-vdso.so.1 -Wl,--no-undefined -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096  -Wl,-T,arch/x86/entry/vdso/vdso.lds arch/x86/entry/vdso/vdso-note.o arch/x86/entry/vdso/vclock_gettime.o arch/x86/entry/vdso/vgetcpu.o && sh ./arch/x86/entry/vdso/checkundef.sh 'nm' 'arch/x86/entry/vdso/vdso64.so.dbg'; printf '%s\n' 'cmd_arch/x86/entry/vdso/vdso64.so.dbg := gcc -nostdlib -o arch/x86/entry/vdso/vdso64.so.dbg -fPIC -shared  -Wl,--hash-style=both  -Wl,--build-id -Wl,-Bsymbolic  -m64 -Wl,-soname=linux-vdso.so.1 -Wl,--no-undefined -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096  -Wl,-T,arch/x86/entry/vdso/vdso.lds arch/x86/entry/vdso/vdso-note.o arch/x86/entry/vdso/vclock_gettime.o arch/x86/entry/vdso/vgetcpu.o && sh ./arch/x86/entry/vdso/checkundef.sh '\''nm'\'' '\''arch/x86/entry/vdso/vdso64.so.dbg'\''' > arch/x86/entry/vdso/.vdso64.so.dbg.cmd
set -e;  echo '  LD [M]  arch/x86/kvm/kvm.o'; ld -m elf_x86_64  -z max-page-size=0x200000   -r -o arch/x86/kvm/kvm.o arch/x86/kvm/../../../virt/kvm/kvm_main.o arch/x86/kvm/../../../virt/kvm/coalesced_mmio.o arch/x86/kvm/../../../virt/kvm/eventfd.o arch/x86/kvm/../../../virt/kvm/irqchip.o arch/x86/kvm/../../../virt/kvm/vfio.o arch/x86/kvm/../../../virt/kvm/async_pf.o arch/x86/kvm/x86.o arch/x86/kvm/mmu.o arch/x86/kvm/emulate.o arch/x86/kvm/i8259.o arch/x86/kvm/irq.o arch/x86/kvm/lapic.o arch/x86/kvm/i8254.o arch/x86/kvm/ioapic.o arch/x86/kvm/irq_comm.o arch/x86/kvm/cpuid.o arch/x86/kvm/pmu.o arch/x86/kvm/mtrr.o arch/x86/kvm/hyperv.o arch/x86/kvm/page_track.o arch/x86/kvm/debugfs.o ; printf '%s\n' 'cmd_arch/x86/kvm/kvm.o := ld -m elf_x86_64  -z max-page-size=0x200000   -r -o arch/x86/kvm/kvm.o arch/x86/kvm/../../../virt/kvm/kvm_main.o arch/x86/kvm/../../../virt/kvm/coalesced_mmio.o arch/x86/kvm/../../../virt/kvm/eventfd.o arch/x86/kvm/../../../virt/kvm/irqchip.o arch/x86/kvm/../../../virt/kvm/vfio.o arch/x86/kvm/../../../virt/kvm/async_pf.o arch/x86/kvm/x86.o arch/x86/kvm/mmu.o arch/x86/kvm/emulate.o arch/x86/kvm/i8259.o arch/x86/kvm/irq.o arch/x86/kvm/lapic.o arch/x86/kvm/i8254.o arch/x86/kvm/ioapic.o arch/x86/kvm/irq_comm.o arch/x86/kvm/cpuid.o arch/x86/kvm/pmu.o arch/x86/kvm/mtrr.o arch/x86/kvm/hyperv.o arch/x86/kvm/page_track.o arch/x86/kvm/debugfs.o ' > arch/x86/kvm/.kvm.o.cmd
set -e;  echo '  LD [M]  arch/x86/kvm/kvm-amd.o'; ld -m elf_x86_64  -z max-page-size=0x200000   -r -o arch/x86/kvm/kvm-amd.o arch/x86/kvm/svm.o arch/x86/kvm/pmu_amd.o ; printf '%s\n' 'cmd_arch/x86/kvm/kvm-amd.o := ld -m elf_x86_64  -z max-page-size=0x200000   -r -o arch/x86/kvm/kvm-amd.o arch/x86/kvm/svm.o arch/x86/kvm/pmu_amd.o ' > arch/x86/kvm/.kvm-amd.o.cmd


And given that binutils 2.31 does things different, when you remove, -z max-page-size=0x200000, from the LDFLAGS, you cause problems.
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
hoegger
n00b
n00b


Joined: 06 Apr 2008
Posts: 8

PostPosted: Mon May 06, 2019 9:55 pm    Post subject: Reply with quote

Hu wrote:
hoegger: what kernel version(s) have you tried with binutils-2.31? Does a 5.0.x series kernel also fail this way?


I did not try 5.0.x. Meanwhile i switched to binutils-2.30-r4 and did an emerge -e @system and emerge -e @world. Also I graded up from kernel 4.9.34 to 4.19.27-r1. Since firefox was complaining about clang:7 and clang:8 not found is also installed clang:7/8 and dependencies.

While previously trying to compile the old kernel (4.9.34) with binutils-2.31.1-r4 i noticed the size of the (unusable) binary was about 2M smaller as it was with 2.30-r4.
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3929
Location: Dallas area

PostPosted: Tue May 07, 2019 12:28 am    Post subject: Reply with quote

binutils 2.31 should work with at least these kernels (min version for old kernels)

4.1.52
4.4.125
4.9.91
4.14.31

Not sure if all the 4.19 series is ok, but from 4.19.27 on it should be fine.
and all of the 5.* series.

The key to working with binutils 2.31 as mentioned above is the ld flag "-z max-page-size=0x200000" if the kernel is not built with it, it won't work when trying to load.
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
CaptainBlood
Veteran
Veteran


Joined: 24 Jan 2010
Posts: 1101

PostPosted: Tue May 07, 2019 3:16 am    Post subject: Reply with quote

hoegger wrote:
While previously trying to compile the old kernel (4.9.34) with binutils-2.31.1-r4 i noticed the size of the (unusable) binary was about 2M smaller as it was with 2.30-r4.

Just the symptom with my faulty make command.
No idea what to point you to...

Thks 4 ur attention, interest & support.
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3929
Location: Dallas area

PostPosted: Tue May 07, 2019 9:31 am    Post subject: Reply with quote

CaptainBlood wrote:
hoegger wrote:
While previously trying to compile the old kernel (4.9.34) with binutils-2.31.1-r4 i noticed the size of the (unusable) binary was about 2M smaller as it was with 2.30-r4.

Just the symptom with my faulty make command.
No idea what to point you to...

Thks 4 ur attention, interest & support.


For you, get rid of your make "script" that overrides CC and LD flags.

For hoegger, use a kernel where they put the fix in that applies to binutils 2.31
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
hoegger
n00b
n00b


Joined: 06 Apr 2008
Posts: 8

PostPosted: Mon May 13, 2019 12:30 am    Post subject: Reply with quote

Anon-E-moose wrote:
CaptainBlood wrote:
hoegger wrote:
While previously trying to compile the old kernel (4.9.34) with binutils-2.31.1-r4 i noticed the size of the (unusable) binary was about 2M smaller as it was with 2.30-r4.

Just the symptom with my faulty make command.
No idea what to point you to...

Thks 4 ur attention, interest & support.


For you, get rid of your make "script" that overrides CC and LD flags.

For hoegger, use a kernel where they put the fix in that applies to binutils 2.31


So i will give it a shot as soon as an update for nvidia-drivers is available in portage. I already placed a sticky note to remember myself.

Thank you very much!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum