summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorTamas Berghammer <tberghammer@google.com>2015-08-24 10:21:55 +0000
committerTamas Berghammer <tberghammer@google.com>2015-08-24 10:21:55 +0000
commit42ecef3b15e9b74fe6bf8dca6bae76650e095726 (patch)
treea4592ace7d88f818a589866232d7b724ece2c053 /lldb/source/Core
parent71ad47f81fb33bbbf0a0713006691ed0c0550b3f (diff)
downloadbcm5719-llvm-42ecef3b15e9b74fe6bf8dca6bae76650e095726.tar.gz
bcm5719-llvm-42ecef3b15e9b74fe6bf8dca6bae76650e095726.zip
Add absolute load address support for the DynamicLoader plugins
The POSIX linker generally reports the load bias for the loaded libraries but in some case it is useful to handle a library based on absolute load address. Example usecases: * Windows linker uses absolute addresses * Library list came from different source (e.g. /proc/<pid>/maps) Differential revision: http://reviews.llvm.org/D12233 llvm-svn: 245834
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/DynamicLoader.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp
index ffd7425f523..4d2824c5f33 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -119,16 +119,20 @@ DynamicLoader::GetTargetExecutable()
}
void
-DynamicLoader::UpdateLoadedSections(ModuleSP module, addr_t link_map_addr, addr_t base_addr)
+DynamicLoader::UpdateLoadedSections(ModuleSP module,
+ addr_t link_map_addr,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
- UpdateLoadedSectionsCommon(module, base_addr);
+ UpdateLoadedSectionsCommon(module, base_addr, base_addr_is_offset);
}
void
-DynamicLoader::UpdateLoadedSectionsCommon(ModuleSP module, addr_t base_addr)
+DynamicLoader::UpdateLoadedSectionsCommon(ModuleSP module,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
bool changed;
- const bool base_addr_is_offset = true;
module->SetLoadAddress(m_process->GetTarget(), base_addr, base_addr_is_offset, changed);
}
@@ -171,7 +175,10 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP module) const
}
ModuleSP
-DynamicLoader::LoadModuleAtAddress(const FileSpec &file, addr_t link_map_addr, addr_t base_addr)
+DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
+ addr_t link_map_addr,
+ addr_t base_addr,
+ bool base_addr_is_offset)
{
Target &target = m_process->GetTarget();
ModuleList &modules = target.GetImages();
@@ -180,27 +187,28 @@ DynamicLoader::LoadModuleAtAddress(const FileSpec &file, addr_t link_map_addr, a
ModuleSpec module_spec (file, target.GetArchitecture());
if ((module_sp = modules.FindFirstModule (module_spec)))
{
- UpdateLoadedSections(module_sp, link_map_addr, base_addr);
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr, base_addr_is_offset);
}
else if ((module_sp = target.GetSharedModule(module_spec)))
{
- UpdateLoadedSections(module_sp, link_map_addr, base_addr);
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr, base_addr_is_offset);
}
else
{
- // Try to fetch the load address of the file from the process. It can be different from the
- // address reported by the linker in case of a file with fixed load address because the
- // linker reports the bias between the load address specified in the file and the actual
- // load address it loaded the file.
- bool is_loaded;
- lldb::addr_t load_addr;
- Error error = m_process->GetFileLoadAddress(file, is_loaded, load_addr);
- if (error.Fail() || !is_loaded)
- load_addr = base_addr;
-
- if ((module_sp = m_process->ReadModuleFromMemory(file, load_addr)))
+ if (base_addr_is_offset)
{
- UpdateLoadedSections(module_sp, link_map_addr, base_addr);
+ // Try to fetch the load address of the file from the process as we need absolute load
+ // address to read the file out of the memory instead of a load bias.
+ bool is_loaded;
+ lldb::addr_t load_addr;
+ Error error = m_process->GetFileLoadAddress(file, is_loaded, load_addr);
+ if (error.Success() && is_loaded)
+ base_addr = load_addr;
+ }
+
+ if ((module_sp = m_process->ReadModuleFromMemory(file, base_addr)))
+ {
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr, false);
target.GetImages().AppendIfNeeded(module_sp);
}
}
OpenPOWER on IntegriCloud