summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
diff options
context:
space:
mode:
authorVirgile Bello <virgile.bello@gmail.com>2014-03-08 17:17:20 +0000
committerVirgile Bello <virgile.bello@gmail.com>2014-03-08 17:17:20 +0000
commit2756adf377c24a22b36f85c90e2983684c86c7ca (patch)
tree59a421550a08937e58c17e460d5e53b31bbf9602 /lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
parentffeba256526f5baa0685f4f8a21d7c7949eac691 (diff)
downloadbcm5719-llvm-2756adf377c24a22b36f85c90e2983684c86c7ca.tar.gz
bcm5719-llvm-2756adf377c24a22b36f85c90e2983684c86c7ca.zip
Implement ObjectFilePECOFF::SetLoadAddress().
llvm-svn: 203350
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp')
-rw-r--r--lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index a4752342e9b..3414e98c8fb 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -24,6 +24,8 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/UUID.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/Target.h"
#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
#define IMAGE_NT_SIGNATURE 0x00004550 // PE00
@@ -173,6 +175,43 @@ ObjectFilePECOFF::ParseHeader ()
return false;
}
+bool
+ObjectFilePECOFF::SetLoadAddress(Target &target, addr_t value, bool value_is_offset)
+{
+ bool changed = false;
+ ModuleSP module_sp = GetModule();
+ if (module_sp)
+ {
+ size_t num_loaded_sections = 0;
+ SectionList *section_list = GetSectionList ();
+ if (section_list)
+ {
+ if (!value_is_offset)
+ {
+ value -= m_image_base;
+ }
+
+ 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 (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress() + value))
+ ++num_loaded_sections;
+ }
+ }
+ changed = num_loaded_sections > 0;
+ return num_loaded_sections > 0;
+ }
+ }
+ return changed;
+}
+
ByteOrder
ObjectFilePECOFF::GetByteOrder () const
@@ -351,6 +390,9 @@ ObjectFilePECOFF::ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr)
m_coff_header_opt.data_dirs[i].vmaddr = m_data.GetU32(offset_ptr);
m_coff_header_opt.data_dirs[i].vmsize = m_data.GetU32(offset_ptr);
}
+
+ m_file_offset = m_coff_header_opt.image_base;
+ m_image_base = m_coff_header_opt.image_base;
}
}
}
OpenPOWER on IntegriCloud