summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/DynamicLoader
diff options
context:
space:
mode:
authorStephane Sezer <sas@cd80.net>2015-02-03 22:48:34 +0000
committerStephane Sezer <sas@cd80.net>2015-02-03 22:48:34 +0000
commit765fcc0d5b8f7eafae0898ccde4075eea6295d70 (patch)
treef0ed051c01e90641a5ae6a0526c42eb0141d0760 /lldb/source/Plugins/DynamicLoader
parent5add5d9d858832aa43c2c1b42f4b8cbd1c60b845 (diff)
downloadbcm5719-llvm-765fcc0d5b8f7eafae0898ccde4075eea6295d70.tar.gz
bcm5719-llvm-765fcc0d5b8f7eafae0898ccde4075eea6295d70.zip
Use basename of main executable in POSIX-DYLD on Android.
Summary: The Android dynamic linker reports only the basename of each SO entry, so for the above check to be successful, we need to compare it to the basename of the main executable. This also has a nasty side-effect when working with older version of Android (verified on platform version 16), and debugging PIE executables: the dynamic linker has a bug and reports the load address of the main executable (which is a shared object, because PIE) to be 0. We then try to update the list of loaded sections for all shared objects, including the main executable, and set the load address to 0, which breaks everything that relies on resolving addresses in the main executable (breakpoints, stepping, etc). This commit also fixes that broken behavior when debugging on older Androids. This bug doesn't happen on newer Android versions (verified for Android L). Test Plan: Run test suite on linux. Reviewers: clayborg, tfiala, richard.mitton Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7188 llvm-svn: 228057
Diffstat (limited to 'lldb/source/Plugins/DynamicLoader')
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp32
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h3
2 files changed, 29 insertions, 6 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index d8279e44e14..a504e801daa 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/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/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
index ca008931799..51fcd9b7d39 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
+++ b/lldb/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
OpenPOWER on IntegriCloud