I am developing a kernel module and need to compile it for an older version of Gentoo that I don't have the headers for. The Linux kernel version is 4.14.34 and I have the source for that, with the output from uname -r being 4.14.34-gentoo-x64. However, when I compiled the module using that source and tried to insmod the module it create it output insmod: ERROR: could not insert module module.ko: Invalid module format.
I have access to the system and could potentially pull some headers from that but I'm not entirely sure where to get them from since the normal directories that I would pull the headers from (/usr/src/linux-x64 or /lib/modules/4.14.34-gentoo-x64/build) don't exist. I've looked around and haven't been able to find the Gentoo 4.14.34 source anywhere.
I'm fairly new to kernel module development, so I may be missing something obvious, but what are the minimum required files to compile for a specific kernel version? Alternatively, is the source for Gentoo 4.14.34 available?
Linux 4.14 is still in the portage tree. The headers from a more recent patch should do just fine - you (probably) don't need the older patch version.
With the 4.14.251 being 'stable' aka well tested.
The corresponding 4.14 headers package is also still available.
YOu can find the download location for the headers by looking at the ebuild (package definition):
You can download the package like this:
The output should tell you where it lands. If in doubt, use
$ emerge --info | grep DIST, which produces the output:on my system (I don't remember where the default download location is). So the headers are available in:
You want the "base" archve.
Hopefully that answers your question.
Pro tip:
join #gentoo on libera irc network and ask your questions there.