summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile
diff options
context:
space:
mode:
authorSteve Pucci <spucci@google.com>2014-02-06 19:02:19 +0000
committerSteve Pucci <spucci@google.com>2014-02-06 19:02:19 +0000
commit9e02dacddf24c649b256d476f0121c1ce52be8ff (patch)
treea47093c6a69eb4c831aaa81d6d37cabec8443cf5 /lldb/source/Plugins/ObjectFile
parent9b9a8d330c142f1c445446ab7053a5bb1bf581c1 (diff)
downloadbcm5719-llvm-9e02dacddf24c649b256d476f0121c1ce52be8ff.tar.gz
bcm5719-llvm-9e02dacddf24c649b256d476f0121c1ce52be8ff.zip
Factor some methods that were in DynamicLoaderPOSIXDYLD.
Move some code that was in DynamicLoaderPOSIXDLYD into the base class DynamicLoader. In the case of UpdateLoadedSections(), the test to see whether a file is loadable (its address is zero) is not generally applicable so that test is changed to a more universally applicable check for the SHF_ALLOC flag on the section. Also make it explicit that the reading of the module_id in DynamicLoaderPOSIXDYLD::GetThreadLocalData() is using a hardcoded size (of module_id) of 4, which might not be appropriate on big-endian 64-bit systems, leaving a FIXME comment in place. llvm-svn: 200939
Diffstat (limited to 'lldb/source/Plugins/ObjectFile')
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp33
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h3
2 files changed, 36 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 7bdacfe14cd..2f3cd8b78cf 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -24,6 +24,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Host/Host.h"
@@ -462,6 +463,38 @@ ObjectFileELF::IsExecutable() const
return m_header.e_entry != 0;
}
+bool
+ObjectFileELF::SetLoadAddress(Target &target, addr_t base_addr)
+{
+ bool changed = false;
+ ModuleSP module_sp = GetModule();
+ if (module_sp)
+ {
+ size_t num_loaded_sections = 0;
+ SectionList *section_list = GetSectionList ();
+ if (section_list)
+ {
+ const size_t num_sections = section_list->GetSize();
+ size_t sect_idx = 0;
+ for (sect_idx = 0; sect_idx < num_sections; ++sect_idx)
+ {
+ // Iterate through the object file sections to find all
+ // of the sections that have SHF_ALLOC in their flag bits.
+ SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
+ // if (section_sp && !section_sp->IsThreadSpecific())
+ if (section_sp && section_sp->Test(SHF_ALLOC))
+ {
+ if (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress() + base_addr))
+ ++num_loaded_sections;
+ }
+ }
+ }
+ changed = num_loaded_sections > 0;
+ return num_loaded_sections > 0;
+ }
+ return changed;
+}
+
ByteOrder
ObjectFileELF::GetByteOrder() const
{
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
index a2ab9b8f370..4fb0250108a 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -118,6 +118,9 @@ public:
virtual bool
ParseHeader();
+ virtual bool
+ SetLoadAddress(lldb_private::Target &target, lldb::addr_t base_addr);
+
virtual lldb::ByteOrder
GetByteOrder() const;
OpenPOWER on IntegriCloud