0

How can I display the absolute file path of ../linux/init.h that the linker deemed resolvable? IE, ! found init.h @ /foo/bar/linux/init.h

I tried make VERBOSE=1, it didn't seem to do anything. Do I need to somehow pass a verbose linker argument to make?

#include <linux/init.h>

static int hello_init(void)
{
    printk(KERN_ALERT "Hello, world\n");
    return 0;
}

[/home/user/dev/kernel-sandbox/Makefile]

obj-m += lkm.o
all:
    sudo make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
    sudo make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
  • 1
    Well, first the linker doesn't look for header files, so it will never print that info. In C/C++, it's the preprocessor that resolves header file locations; the preprocessor is run as part of the compiler (or by itself), not the linker. If you want to know the path to the header files, you can use the -E option to the compiler which will get it to print the output of the preprocessor rather than compiling it. Usually the preprocessor will leave notes in the output about where each header was found and the macros, etc. – MadScientist Oct 29 '17 at 20:25
  • Some makefiles support a rule to build `%.i` which is the output of the preprocessor. E.g., if you have a file `lkm.c` you can run `make lkm.i` and it will create `lkm.i` which is the preprocessor output. I don't know if the Linux kernel makefiles support that. – MadScientist Oct 29 '17 at 20:26
  • Try adding `-H` to `CFLAGS` (the compiler is responsible for it, not the linker). – n. m. could be an AI Oct 29 '17 at 21:02
  • From https://stackoverflow.com/questions/18478859/is-it-possible-to-set-cflags-to-a-linux-kernel-module-makefile, adding "CFLAGS_lkm.o := -H" seemed to give me the -H output, however, I still don't know which file it chose for the resolution –  Oct 29 '17 at 21:53

0 Answers0