Hi everyone,
I'm going to build a little kernel module for Alpine, but get some problems.
Host: Ubuntu 16.04LTS 64bit
Guest : Alpine-vanilla-3.7.0-x86(kernel version 4.9.65) in qemu
It looks like there is no build environment for a kernel module natively in Alpine, so I tried to use cross-compiler to build it in the host.
I first get an i686-linux-musl-gcc cross-compiler from https://github.com/richfelker/musl-cross-make <https://github.com/richfelker/musl-cross-make> . It works fine since a compiled Hello_World.c runs perfectly in the guest.
Right now, I'm trying to build a kernel module hello_kernel.c. I download linux kernel 4.9.65 first from kernel.org <http://kernel.org/> (e.g. in /home/yuxing/linux 4.9.65 ), and compile it with the cross-compiler mentioned above. Next, I use the build environment in /home/yuxing/linux 4.9.65 with the cross compiler to build the hello_kernel.ko . It looks fine since no errors come out.
But when I insmod hello_kernel.ko in Alpine, the error
Can someone please give me some advices to figure this problem or how to build a kernel module for Alpine. Thanks in advance.
Regards,
Yuxing
IIRC to build a kernel module natively on Alpine you first need to do:
# apk add linux-hardened-dev alpine-sdk
This doesn't seem to be documented anywhere.
I tried to build a module a while ago and succeeded, but I saw a lot
of linker warnings such as
warning: objtool: init_fp() can't find starting instruction
2018-01-02 14:24 GMT-03:00 Vanish <yuxing.fan.tubs@gmail.com>:
> Hi everyone,
>
> I'm going to build a little kernel module for Alpine, but get some problems.
>
> Host: Ubuntu 16.04LTS 64bit
> Guest : Alpine-vanilla-3.7.0-x86(kernel version 4.9.65) in qemu
>
> It looks like there is no build environment for a kernel module natively in
> Alpine, so I tried to use cross-compiler to build it in the host.
> I first get an i686-linux-musl-gcc cross-compiler from
> https://github.com/richfelker/musl-cross-make . It works fine since a
> compiled Hello_World.c runs perfectly in the guest.
> Right now, I'm trying to build a kernel module hello_kernel.c. I download
> linux kernel 4.9.65 first from kernel.org (e.g. in /home/yuxing/linux 4.9.65
> ), and compile it with the cross-compiler mentioned above. Next, I use the
> build environment in /home/yuxing/linux 4.9.65 with the cross compiler to
> build the hello_kernel.ko . It looks fine since no errors come out.
> But when I insmod hello_kernel.ko in Alpine, the error
>
> Can someone please give me some advices to figure this problem or how to
> build a kernel module for Alpine. Thanks in advance.
>
> Regards,
> Yuxing
>
>
---
Unsubscribe: alpine-user+unsubscribe@lists.alpinelinux.org
Help: alpine-user+help@lists.alpinelinux.org
---