diff options
author | Jason Molenda <jmolenda@apple.com> | 2019-01-10 00:57:54 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2019-01-10 00:57:54 +0000 |
commit | 03d0b0581b03e1f3125924df30facb386d1f47ba (patch) | |
tree | 9741b9bdc26d650acb2a69edf556ba235e14ac17 /lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp | |
parent | bed882b9e83e84e046efd42a5d0cebd4698b1e58 (diff) | |
download | bcm5719-llvm-03d0b0581b03e1f3125924df30facb386d1f47ba.tar.gz bcm5719-llvm-03d0b0581b03e1f3125924df30facb386d1f47ba.zip |
A little cleanup / commenting on locating kernel binaries while I
was working on something else.
DynamicLoaderDarwinKernel::SearchForKernelNearPC should have had
an early return if the pc value is not in high memory; add that.
The search for a kernel at 0x2000 offsets was a stopgap; it doesn't
need to be checked any longer.
llvm-svn: 350786
Diffstat (limited to 'lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp')
-rw-r--r-- | lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 024f82800f6..3a80c68dd4d 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -293,6 +293,18 @@ DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) { return LLDB_INVALID_ADDRESS; addr_t pc = thread->GetRegisterContext()->GetPC(LLDB_INVALID_ADDRESS); + // The kernel is always loaded in high memory, if the top bit is zero, + // this isn't a kernel. + if (process->GetTarget().GetArchitecture().GetAddressByteSize() == 8) { + if ((pc & (1ULL << 63)) == 0) { + return LLDB_INVALID_ADDRESS; + } + } else { + if ((pc & (1ULL << 31)) == 0) { + return LLDB_INVALID_ADDRESS; + } + } + if (pc == LLDB_INVALID_ADDRESS) return LLDB_INVALID_ADDRESS; @@ -307,12 +319,13 @@ DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) { // Search backwards 32 megabytes, looking for the start of the kernel at each // one-megabyte boundary. for (int i = 0; i < 32; i++, addr -= 0x100000) { + // x86_64 kernels are at offset 0 if (CheckForKernelImageAtAddress(addr, process).IsValid()) return addr; + // 32-bit arm kernels are at offset 0x1000 (one 4k page) if (CheckForKernelImageAtAddress(addr + 0x1000, process).IsValid()) return addr + 0x1000; - if (CheckForKernelImageAtAddress(addr + 0x2000, process).IsValid()) - return addr + 0x2000; + // 64-bit arm kernels are at offset 0x4000 (one 16k page) if (CheckForKernelImageAtAddress(addr + 0x4000, process).IsValid()) return addr + 0x4000; } @@ -351,12 +364,13 @@ lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelViaExhaustiveSearch( addr_t addr = kernel_range_low; while (addr >= kernel_range_low && addr < kernel_range_high) { + // x86_64 kernels are at offset 0 if (CheckForKernelImageAtAddress(addr, process).IsValid()) return addr; + // 32-bit arm kernels are at offset 0x1000 (one 4k page) if (CheckForKernelImageAtAddress(addr + 0x1000, process).IsValid()) return addr + 0x1000; - if (CheckForKernelImageAtAddress(addr + 0x2000, process).IsValid()) - return addr + 0x2000; + // 64-bit arm kernels are at offset 0x4000 (one 16k page) if (CheckForKernelImageAtAddress(addr + 0x4000, process).IsValid()) return addr + 0x4000; addr += 0x100000; |