You are not logged in.
Hello,
I need to write a module for Linux so, following a guide, I installed the linux-headers package and wrote a gnu-makefile for a test module, within it, running make on the /usr/lib/modules/6.9.5-arch1-1/build directory encountered errors, specifically with ...crypto/Kconfig, the 'source file' that was determined in that file is for an arm version of the system and not an x86 one (see line 1480). I tinkered with it a bit but did not solve the problem, one strange thing i encountered though is that solely changing the string under 'if ARM' to name an x86 directory moved the goalpost to the loongarch architecture right under it, funi.
Pls fix ![]()
Offline
Are you following building external modules? Please provide the contents of the files you have created and the commands you are using to produce the issue.
Offline
I am following this pdf: https://sysprog21.github.io/lkmpg/
I had written the makefile by hand but
"cd NEWMODULE_DIR
make -C /lib/modules/6.9.6-arch1-1/build M=$PWM"
encounters the same problem, the full error log:
make: Entering directory '/usr/lib/modules/6.9.6-arch1-1/build'
SYNC include/config/auto.conf
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTLD scripts/kconfig/conf
crypto/Kconfig:1486: can't open file "arch/arm/crypto/Kconfig"
make[3]: *** [scripts/kconfig/Makefile:85: syncconfig] Error 1
make[2]: *** [Makefile:688: syncconfig] Error 2
make[1]: *** [/usr/lib/modules/6.9.6-arch1-1/build/Makefile:789: include/config/auto.conf] Error 2
make[1]: *** [include/config/auto.conf] Deleting file 'include/generated/rustc_cfg'
make[1]: *** [include/config/auto.conf] Deleting file 'include/generated/autoconf.h'
make: *** [Makefile:240: __sub-make] Error 2
make: Leaving directory '/usr/lib/modules/6.9.6-arch1-1/build'
Sorry for the late reply, I had to check thoroughly for some stupid mistake I might have made lol
Last edited by madoka_magika0123456789 (2024-06-23 12:54:06)
Offline
make -C /lib/modules/6.9.6-arch1-1/build M=$PWM"Should be
make -C /lib/modules/6.9.6-arch1-1/build M=$PWD"Full example:
$ cat Makefile
obj-m += hello.o
PWD := $(CURDIR)
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
$ cat hello.c
/*
* hello-1.c - The simplest kernel module.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/printk.h> /* Needed for pr_info() */
int init_module(void)
{
pr_info("Hello world 1.\n");
/* A non 0 return means init_module failed; module can't be loaded. */
return 0;
}
void cleanup_module(void)
{
pr_info("Goodbye world 1.\n");
}
MODULE_LICENSE("GPL");
$ make -C /lib/modules/6.9.6-arch1-1/build M=$PWD
make: Entering directory '/usr/lib/modules/6.9.6-arch1-1/build'
CC [M] /tmp/hello-module/hello.o
/tmp/hello-module/hello.o: warning: objtool: init_module(): not an indirect call target
/tmp/hello-module/hello.o: warning: objtool: cleanup_module(): not an indirect call target
MODPOST /tmp/hello-module/Module.symvers
CC [M] /tmp/hello-module/hello.mod.o
LD [M] /tmp/hello-module/hello.ko
BTF [M] /tmp/hello-module/hello.ko
make: Leaving directory '/usr/lib/modules/6.9.6-arch1-1/build'Offline
Things are now somehow working, thank you for the help. Sorry for having made such a concerning thread title out of this lol
Offline