I'm trying to compile a simple kernel module, but the compilation fails due to a wrong argument passed by make
to gcc
.
This is the Makefile
:
obj-m += test.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) test
Running make
produces the following errors:
$ make
make -C /lib/modules/3.16.0-33-generic/build M=/home/user/test test
make[1]: Entering directory `/usr/src/linux-headers-3.16.0-33-generic'
gcc -m elf_x86_64 /home/user/test/test.c -o test
gcc: error: elf_x86_64: No such file or directory
gcc: error: unrecognized command line option ‘-m’
make[1]: *** [test] Error 1
make[1]: Leaving directory `/usr/src/linux-headers-3.16.0-33-generic'
make: *** [all] Error 2
This answer doesn't help: I've searched all files within /usr
for those containing -m elf_x86
using grep -rnw '/usr' -e "-m elf_x86"
and no file matches, so I have no idea about which file I need to edit to redefine make
's behavior.