diff options
| author | Ed Maste <emaste@FreeBSD.org> | 2015-02-09 01:44:09 +0000 |
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2015-02-09 01:44:09 +0000 |
| commit | 12bd4897ff0678fa663e09d78ebc22dd255ceb86 (patch) | |
| tree | a8f4b3abea3e6937e60728991c736e6e3d322fc1 /source/Plugins/DynamicLoader | |
| parent | 205afe679855a4ce8149cdaa94d3f0868ce796dc (diff) | |
Notes
Diffstat (limited to 'source/Plugins/DynamicLoader')
3 files changed, 32 insertions, 6 deletions
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp index d8279e44e14a..a504e801daac 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp @@ -19,6 +19,8 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" +#include "llvm/Support/Path.h" + #include "DYLDRendezvous.h" using namespace lldb; @@ -238,9 +240,7 @@ DYLDRendezvous::UpdateSOEntriesForAddition() return false; // Only add shared libraries and not the executable. - // On Linux this is indicated by an empty path in the entry. - // On FreeBSD it is the name of the executable. - if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0) + if (SOEntryIsMainExecutable(entry)) continue; pos = std::find(m_soentries.begin(), m_soentries.end(), entry); @@ -277,6 +277,28 @@ DYLDRendezvous::UpdateSOEntriesForDeletion() } bool +DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry) +{ + // On Linux the executable is indicated by an empty path in the entry. On + // FreeBSD it is the full path to the executable. On Android, it is the + // basename of the executable. + + auto triple = m_process->GetTarget().GetArchitecture().GetTriple(); + auto os_type = triple.getOS(); + auto env_type = triple.getEnvironment(); + + switch (os_type) { + case llvm::Triple::FreeBSD: + return ::strcmp(entry.path.c_str(), m_exe_path) == 0; + case llvm::Triple::Linux: + return entry.path.empty() || (env_type == llvm::Triple::Android && + llvm::sys::path::filename(m_exe_path) == entry.path); + default: + return false; + } +} + +bool DYLDRendezvous::TakeSnapshot(SOEntryList &entry_list) { SOEntry entry; @@ -290,9 +312,7 @@ DYLDRendezvous::TakeSnapshot(SOEntryList &entry_list) return false; // Only add shared libraries and not the executable. - // On Linux this is indicated by an empty path in the entry. - // On FreeBSD it is the name of the executable. - if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0) + if (SOEntryIsMainExecutable(entry)) continue; entry_list.push_back(entry); diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h index ca0089317998..51fcd9b7d397 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h @@ -247,6 +247,9 @@ protected: bool UpdateSOEntriesForDeletion(); + bool + SOEntryIsMainExecutable(const SOEntry &entry); + /// Reads the current list of shared objects according to the link map /// supplied by the runtime linker. bool diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 6b0b6f5cc8b8..fdef1026f3c6 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -542,6 +542,9 @@ DynamicLoaderPOSIXDYLD::ComputeLoadOffset() return LLDB_INVALID_ADDRESS; ObjectFile *exe = module->GetObjectFile(); + if (!exe) + return LLDB_INVALID_ADDRESS; + Address file_entry = exe->GetEntryPointAddress(); if (!file_entry.IsValid()) |
