Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KALLYSYMS base relative heuristic decision incorrect for some boot images #54

Open
Roguebantha opened this issue Jul 28, 2023 · 1 comment

Comments

@Roguebantha
Copy link

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.

@worstperson
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants