31

I have a Linux kernel image in elf format and I want to find out what .config file was used to build this kernel. When I do an objdump of the image, I see a section called kernel_config_data that contains text but does not look like the config file. Is there a way to retrieve this information?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
user2050283
  • 562
  • 1
  • 4
  • 9

2 Answers2

46

Assuming your kernel was built with the IKCONFIG option, you can use the scripts/extract-ikconfig tool to extract the original .config file.

Alternately, you can boot that kernel and find the embedded configuration in /proc/config.gz.

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
  • 7
    And how to check if it was built w/ IKCONFIG ? I guess if ikconfig just fail : like scripts/extract-ikconfig $file extract-ikconfig: Cannot find kernel config. – RzR Jan 05 '14 at 19:35
  • @Frederic Hamidi I have some `.img` files which are `arm-eabi-gcc` cross compiled and I want to get the `.config` file of that images. Is it possible to do so? – GShaik Aug 25 '16 at 13:03
3

You can zcat /proc/config.gz, for example:

zcat /proc/config.gz | grep 'CONFIG_PRINTK_TIME'

To dump this into the .config used in the kernel build process:

zcat /proc/config.gz > .config
AStopher
  • 4,207
  • 11
  • 50
  • 75
a.saurabh
  • 1,163
  • 10
  • 15