You are not logged in.

#1 2024-07-24 08:30:24

altoid
Member
From: Germany
Registered: 2019-09-19
Posts: 14

[Solved] Can't compile kernel due to missing BTF section.

Hello,

I am trying to compile my own kernel, following these steps:

https://wiki.archlinux.org/title/Kernel … ild_system

but even then, I can not compile the kernel.

First of all, "make prepare" is missing from the PKGBUILD, which I manually appended after make menuconfig.

In menuconfig, I simply set the timer frequency to 1000HZ, enabled full dynamic preemption, as well as all of the few security related options merged from grsecurity/PaX:

Fully randomize structure layout.
Initialize structures on the stack to zero.
Enable heap memory zeroing on allocation by default.
Enable heap memory zeroing on free by default.
Poison kernel stack before returning from syscalls.
Enable register zeroing on function exit.
Check integrity of linked list manipulation.

And under GCC plugins:

Generate some entropy during boot and runtime.

This always results in the following compilation error:

libbpf: failed to find '.BTF' ELF section in vmlinux
FAILED: load BTF from vmlinux: No data available

This is while using the kernel config pulled in from the repository, only setting my CPU family (Core 2 / newer Xeon) and the config changes mentioned above.

Is there anything I am missing?

I am compiling with latest pahole and base-devel, running the latest linux kernel (although in integrity lockdown mode) and made sure pacman had no updates to complain about.

This seems to have affected many other people, from a quick Google search, but they insist it is now fixed with the latest pahole version.

Any idea why this still happens?

Thank you,
altoid

Last edited by altoid (2024-07-28 09:34:09)

Offline

#2 2024-07-28 01:54:46

altoid
Member
From: Germany
Registered: 2019-09-19
Posts: 14

Re: [Solved] Can't compile kernel due to missing BTF section.

Quick update:

I was able to compile and boot a minimal kernel using

make localmodconfig

and this time gcc also generated BTF sections for all modules, this is after updating gcc to the latest git version.

I did not have the time to enable the hardening options, but I will see if that breaks anything.

If not, I will just continue using

make localmodconfig

and use menuconfig to enable the few extra modules that a mkinitcpio hook complained about.

Thanks.

Offline

#3 2024-07-28 08:44:27

altoid
Member
From: Germany
Registered: 2019-09-19
Posts: 14

Re: [Solved] Can't compile kernel due to missing BTF section.

Okay, I figured out the culprit:

DEBUG_INFO_BTF

can't be enabled if you enable structure randomization, thus leading up to this error.

Since I don't really need any of the BTF / BPF stuff anyway, I will just disable it completely:

CONFIG_BPF=n
CONFIG_BPF_SYSCALL=n
CONFIG_BPF_JIT=n
CONFIG_BPF_JIT_ALWAYS_ON=n
CONFIG_BPF_JIT_DEFAULT_ON=n
CONFIG_PAHOLE_HAS_BTF_TAG=n
CONFIG_DEBUG_INFO_BTF=n
CONFIG_DEBUG_INFO_BTF_MODULES=n

Hope this helps someone compiling their own kernel with the RANDSTRUCT plugin enabled.

Last edited by altoid (2024-07-28 09:33:53)

Offline

#4 2025-08-23 11:33:53

voidzero
Member
Registered: 2007-06-21
Posts: 110

Re: [Solved] Can't compile kernel due to missing BTF section.

Sorry for bumping this old thread, but I just had to thay thanks, this tip probably saved me hours of work. Couldn't resist posting my appreciation. big_smile

Offline

#5 2025-08-23 14:22:54

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,003
Website

Re: [Solved] Can't compile kernel due to missing BTF section.

Mod note: Closing this old thread.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

Board footer

Powered by FluxBB