pwnlib.elf.config — Kernel Config Parsing

Kernel-specific ELF functionality

pwnlib.elf.config.parse_kconfig(data)[source]

Parses configuration data from a kernel .config.

Parameters

data (str) – Configuration contents.

Returns

A dict mapping configuration options. “Not set” is converted into None, y and n are converted into bool. Numbers are converted into int. All other values are as-is. Each key has CONFIG_ stripped from the beginning.

Examples

>>> parse_kconfig('FOO=3')
{'FOO': 3}
>>> parse_kconfig('FOO=y')
{'FOO': True}
>>> parse_kconfig('FOO=n')
{'FOO': False}
>>> parse_kconfig('FOO=bar')
{'FOO': 'bar'}
>>> parse_kconfig('# FOO is not set')
{'FOO': None}