当 CONFIG_IKCONFIG 设置为模块 (=m) 时,如何从内核映像文件中提取配置?

How to extract the config from a kernel image file when CONFIG_IKCONFIG is set as a module (=m)?

如何从内核映像文件中提取内核配置?

内核映像文件类型为:

/boot/kernel7.img: Linux kernel ARM boot executable zImage (little-endian)

内核已编译并启用CONFIG_IKCONFIG。然而,

scripts/extract-ikconfig /boot/kernel7.img

returns

extract-ikconfig: Cannot find kernel config.

注意:我正在尝试在不启动内核的情况下获取配置。

如果内核是用CONFIG_IKCONFIG=m编译的(注意m),配置存储在模块(configs.ko)中而不是内核本身。这就是内核映像上 运行 extract-ikconfig 失败的原因。

在这种情况下,我们可以从配置模块中提取配置:

/usr/src/$(uname -r)/scripts/extract-ikconfig \ 
   /lib/modules/$(uname -r)/kernel/kernel/configs.ko