summaryrefslogtreecommitdiff
path: root/source/Plugins/DynamicLoader
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/DynamicLoader')
-rw-r--r--source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp12
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp4
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp5
-rw-r--r--source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp44
4 files changed, 55 insertions, 10 deletions
diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index a82b3fe267b3f..a81a0306671e1 100644
--- a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -1229,6 +1229,16 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries(
break;
}
}
+ // If this "kext" entry is actually an alias for the kernel --
+ // the kext was compiled into the kernel or something -- then
+ // we don't want to load the kernel's text section at a different
+ // address. Ignore this kext entry.
+ if (kext_summaries[new_kext].GetUUID().IsValid()
+ && m_kernel.GetUUID().IsValid()
+ && kext_summaries[new_kext].GetUUID() == m_kernel.GetUUID()) {
+ to_be_added[new_kext] = false;
+ break;
+ }
if (add_this_one) {
number_of_new_kexts_being_added++;
}
@@ -1397,7 +1407,7 @@ bool DynamicLoaderDarwinKernel::ReadAllKextSummaries() {
void DynamicLoaderDarwinKernel::KextImageInfo::PutToLog(Log *log) const {
if (log == NULL)
return;
- const uint8_t *u = (uint8_t *)m_uuid.GetBytes();
+ const uint8_t *u = static_cast<const uint8_t *>(m_uuid.GetBytes());
if (m_load_address == LLDB_INVALID_ADDRESS) {
if (u) {
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index 1ef1be5d0adb3..c49cdc2f11b1e 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index c1986976b0fc4..e601d64f0d8d0 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
@@ -18,6 +14,7 @@
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
index c381326ebf4fe..6502d7a7a58ce 100644
--- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -11,8 +11,11 @@
#include "DynamicLoaderWindowsDYLD.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/ThreadPlanStepInstruction.h"
#include "llvm/ADT/Triple.h"
@@ -72,5 +75,44 @@ uint32_t DynamicLoaderWindowsDYLD::GetPluginVersion() { return 1; }
ThreadPlanSP
DynamicLoaderWindowsDYLD::GetStepThroughTrampolinePlan(Thread &thread,
bool stop) {
- return ThreadPlanSP();
+ auto arch = m_process->GetTarget().GetArchitecture();
+ if (arch.GetMachine() != llvm::Triple::x86) {
+ return ThreadPlanSP();
+ }
+
+ uint64_t pc = thread.GetRegisterContext()->GetPC();
+ // Max size of an instruction in x86 is 15 bytes.
+ AddressRange range(pc, 2 * 15);
+
+ ExecutionContext exe_ctx(m_process->GetTarget());
+ DisassemblerSP disassembler_sp = Disassembler::DisassembleRange(
+ arch, nullptr, nullptr, exe_ctx, range, true);
+ if (!disassembler_sp) {
+ return ThreadPlanSP();
+ }
+
+ InstructionList *insn_list = &disassembler_sp->GetInstructionList();
+ if (insn_list == nullptr) {
+ return ThreadPlanSP();
+ }
+
+ // First instruction in a x86 Windows trampoline is going to be an indirect
+ // jump through the IAT and the next one will be a nop (usually there for
+ // alignment purposes). e.g.:
+ // 0x70ff4cfc <+956>: jmpl *0x7100c2a8
+ // 0x70ff4d02 <+962>: nop
+
+ auto first_insn = insn_list->GetInstructionAtIndex(0);
+ auto second_insn = insn_list->GetInstructionAtIndex(1);
+
+ if (first_insn == nullptr || second_insn == nullptr ||
+ strcmp(first_insn->GetMnemonic(&exe_ctx), "jmpl") != 0 ||
+ strcmp(second_insn->GetMnemonic(&exe_ctx), "nop") != 0) {
+ return ThreadPlanSP();
+ }
+
+ assert(first_insn->DoesBranch() && !second_insn->DoesBranch());
+
+ return ThreadPlanSP(new ThreadPlanStepInstruction(
+ thread, false, false, eVoteNoOpinion, eVoteNoOpinion));
}