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

Override relative #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TheBitshifter
Copy link

When analyzing a kernel recently, this tool was reporting relative offsets in the kallsyms table when actually they were absolute addresses. This pull-request adds a switch to force absolute addresses and also adds some heuristics to suggest when to use that switch.

Note the base address that is going into created kernel elf.  Seeing the
actual address can help determine if something wonky is going on.
Add a switch to override discovery of relative offsets in the kallsyms
table.  If the binary under analysis has an absolute base in the upper
half of the virtual address range, all the addresses appear to be
negative numbers.  For 64-bit systems a 50-50 split would put kernel
addresses at 0x80000000-00000000 and for 32 bit systems with a 3G/1G
split, the kernel addresses start at 0xC0000000
When looking for relative addresses, perform heuristic checks for
absolute addresses.  The original heuristic was just looking for
negative numbers to be the offsets.  This is insufficient because a
kernel virtual address for a kernel loaded at an absolute address will
almost certainly be in the top half of the virtual address space which
would be a negative number.

2 heuristics have been added.  The first is to check the top 3 nybbles
are 0xFFF.  True negative numbers are unlikely to be *THAT* negative.
The kernel will be on the order of a few 10s of MB

The second heuristic is to check for zeros in the top byte using the
mask 0x3F.  This assumes the kernel is loaded near the bottom of the
kernel address space and will catch the 3G/1G split.  Strictly speaking
the second heuristic should never trip if the first one doesn't.
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

Successfully merging this pull request may close these issues.

1 participant