summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
diff options
context:
space:
mode:
authorMichael Sartain <mikesart@valvesoftware.com>2013-05-17 00:20:21 +0000
committerMichael Sartain <mikesart@valvesoftware.com>2013-05-17 00:20:21 +0000
commit9f0013d86776236b4c18e6cf20f7ac2e78f5f11c (patch)
tree7d5cf121d1f102443739a3d56de3409ca9b7cf68 /lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
parentb9931496f511d7a026507f90610f0c8fff5091fd (diff)
downloadbcm5719-llvm-9f0013d86776236b4c18e6cf20f7ac2e78f5f11c.tar.gz
bcm5719-llvm-9f0013d86776236b4c18e6cf20f7ac2e78f5f11c.zip
Implement ObjectFileELF::GetModuleSpecifications(), and add PlatformLinux code to deal with unknown arch properties.
CR: Greg Clayton llvm-svn: 182065
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp')
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 73bbb111b02..ec3e184df63 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -222,6 +222,18 @@ ObjectFileELF::CreateMemoryInstance (const lldb::ModuleSP &module_sp,
return NULL;
}
+bool
+ObjectFileELF::MagicBytesMatch (DataBufferSP& data_sp,
+ lldb::addr_t data_offset,
+ lldb::addr_t data_length)
+{
+ if (data_sp && data_sp->GetByteSize() > (llvm::ELF::EI_NIDENT + data_offset))
+ {
+ const uint8_t *magic = data_sp->GetBytes() + data_offset;
+ return ELFHeader::MagicBytesMatch(magic);
+ }
+ return false;
+}
size_t
ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file,
@@ -231,7 +243,33 @@ ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file,
lldb::offset_t length,
lldb_private::ModuleSpecList &specs)
{
- return 0;
+ const size_t initial_count = specs.GetSize();
+
+ if (ObjectFileELF::MagicBytesMatch(data_sp, 0, data_sp->GetByteSize()))
+ {
+ DataExtractor data;
+ data.SetData(data_sp);
+ elf::ELFHeader header;
+ if (header.Parse(data, &data_offset))
+ {
+ if (data_sp)
+ {
+ ModuleSpec spec;
+ spec.GetFileSpec() = file;
+ spec.GetArchitecture().SetArchitecture(eArchTypeELF,
+ header.e_machine,
+ LLDB_INVALID_CPUTYPE);
+ if (spec.GetArchitecture().IsValid())
+ {
+ // ObjectFileMachO adds the UUID here also, but that isn't in the elf header
+ // so we'd have to read the entire file in and calculate the md5sum.
+ // That'd be bad for this routine...
+ specs.Append(spec);
+ }
+ }
+ }
+ }
+ return specs.GetSize() - initial_count;
}
//------------------------------------------------------------------
OpenPOWER on IntegriCloud