KALLYSYMS base relative heuristic decision incorrect for some boot images
Roguebantha opened this issue · 1 comments
I discovered yesterday that at least some boot images will not properly get kallsyms parsed into the vmlinux image due to CONFIG_KALLSYMS_BASE_RELATIVE being turned off in the kernel. While there appears to be some sort of minor heuristic detection based off kernel version, later kernel versions with this option turned off (for whatever reason) will not get parsed correctly - or at least, mine won't.
I fudged this by forcibly setting has_base_relative = False, but ideally there's a less hacky solution. Perhaps just exposing a new command-line option to the user to ask vmlinux_to_elf to assume one way or another, or perhaps a more aggressive heuristic (e.g. parsing config.gz and looking for the CONFIG flag) would be effective as well.
Here's an example boot image where this is currently failing.
It's kind of difficult as the code explicitly tries to make no assumptions about the contents, though all the samples I've seen are in order or reverse order. The way I handled this when porting to Java was to check has_base_relative = False first, and if the addresses are not monotonous try has_base_relative = True. I assume there are kernels out there that this doesn't work for though since it's not implemented that way.
My other idea was to simply try both and compare the number of null addresses as correct offsets generally have considerably fewer in the samples I have. Not a perfect solution either.
I really like the idea of pulling config.gz when available though, even if it's not so much a solution by itself.