我正在使用自定义驱动程序构建内核。在成功构建之后,我发现了许多build-in.o文件。任何人都可以详细说明这些文件是如何结束的。我只能怀疑这些与更高级别的makefile有关。
答案 0 :(得分:4)
built-in.o文件是内核的每个目录目标的编译产品,不是作为模块构建的。
请参阅Documentation / kbuild / makefiles.txt
每个子目录都有一个kbuild Makefile,它执行从上面传递的命令。 kbuild Makefile使用信息 从.config文件中构造kbuild使用的各种文件列表 构建任何内置或模块化目标。
--- 3.1目标定义
Goal definitions are the main part (heart) of the kbuild Makefile. These lines define the files to be built, any special compilation options, and any subdirectories to be entered recursively. The most simple kbuild makefile contains one line: Example: obj-y += foo.o This tells kbuild that there is one object in that directory, named foo.o. foo.o will be built from foo.c or foo.S. If foo.o shall be built as a module, the variable obj-m is used. Therefore the following pattern is often used: Example: obj-$(CONFIG_FOO) += foo.o $(CONFIG_FOO) evaluates to either y (for built-in) or m (for module). If CONFIG_FOO is neither y nor m, then the file will not be compiled nor linked.
--- 3.2内置对象目标 - obj-y
The kbuild Makefile specifies object files for vmlinux in the $(obj-y) lists. These lists depend on the kernel configuration. Kbuild compiles all the $(obj-y) files. It then calls "$(LD) -r" to merge these files into one built-in.o file. built-in.o is later linked into vmlinux by the parent Makefile.