[Lldb-commits] [lldb] r123496 - in /lldb/trunk/source/Plugins/ObjectFile/ELF: ObjectFileELF.cpp ObjectFileELF.h
Stephen Wilson
wilsons at start.ca
Fri Jan 14 16:08:44 PST 2011
Author: wilsons
Date: Fri Jan 14 18:08:44 2011
New Revision: 123496
URL: http://llvm.org/viewvc/llvm-project?rev=123496&view=rev
Log:
Implement GetEntryPoint, GetImageInfoAddress and GetArchitecture for ObjectFileELF.
Modified:
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=123496&r1=123495&r2=123496&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Jan 14 18:08:44 2011
@@ -12,6 +12,7 @@
#include <cassert>
#include <algorithm>
+#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/FileSpecList.h"
@@ -70,9 +71,10 @@
unsigned address_size = ELFHeader::AddressSizeInBytes(magic);
if (address_size == 4 || address_size == 8)
{
- std::auto_ptr<ObjectFile> objfile_ap(
+ std::auto_ptr<ObjectFileELF> objfile_ap(
new ObjectFileELF(module, data_sp, file, offset, length));
- if (objfile_ap->ParseHeader())
+ ArchSpec spec = objfile_ap->GetArchitecture();
+ if (spec.IsValid() && objfile_ap->SetModulesArchitecture(spec))
return objfile_ap.release();
}
}
@@ -80,6 +82,15 @@
return NULL;
}
+ArchSpec
+ObjectFileELF::GetArchitecture()
+{
+ if (!ParseHeader())
+ return ArchSpec();
+
+ return ArchSpec(eArchTypeELF, m_header.e_machine, m_header.e_flags);
+}
+
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
@@ -151,6 +162,15 @@
return m_header.e_type == ET_EXEC;
}
+Address
+ObjectFileELF::GetEntryPoint() const
+{
+ if (m_header.e_entry)
+ return Address(NULL, m_header.e_entry);
+ else
+ return Address();
+}
+
ByteOrder
ObjectFileELF::GetByteOrder() const
{
@@ -208,6 +228,60 @@
return num_specs;
}
+Address
+ObjectFileELF::GetImageInfoAddress()
+{
+ if (!ParseSectionHeaders())
+ return Address();
+
+ user_id_t dynsym_id = 0;
+ for (SectionHeaderCollIter sh_pos = m_section_headers.begin();
+ sh_pos != m_section_headers.end(); ++sh_pos)
+ {
+ if (sh_pos->sh_type == SHT_DYNAMIC)
+ {
+ dynsym_id = SectionIndex(sh_pos);
+ break;
+ }
+ }
+
+ if (!dynsym_id)
+ return Address();
+
+ SectionList *section_list = GetSectionList();
+ if (!section_list)
+ return Address();
+
+ // Resolve the dynamic table entries.
+ Section *dynsym = section_list->FindSectionByID(dynsym_id).get();
+ if (!dynsym)
+ return Address();
+
+ DataExtractor dynsym_data;
+ if (dynsym->ReadSectionDataFromObjectFile(this, dynsym_data))
+ {
+ ELFDynamic symbol;
+ const unsigned section_size = dynsym_data.GetByteSize();
+ unsigned offset = 0;
+ unsigned cursor = 0;
+
+ // Look for a DT_DEBUG entry.
+ while (cursor < section_size)
+ {
+ offset = cursor;
+ if (!symbol.Parse(dynsym_data, &cursor))
+ break;
+
+ if (symbol.d_tag != DT_DEBUG)
+ continue;
+
+ return Address(dynsym, offset + sizeof(symbol.d_tag));
+ }
+ }
+
+ return Address();
+}
+
//----------------------------------------------------------------------
// ParseDependentModules
//----------------------------------------------------------------------
Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h?rev=123496&r1=123495&r2=123496&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Fri Jan 14 18:08:44 2011
@@ -89,6 +89,9 @@
virtual bool
IsExecutable () const;
+ virtual lldb_private::Address
+ GetEntryPoint() const;
+
virtual size_t
GetAddressByteSize() const;
@@ -110,6 +113,12 @@
virtual uint32_t
GetDependentModules(lldb_private::FileSpecList& files);
+ virtual lldb_private::Address
+ GetImageInfoAddress();
+
+ lldb_private::ArchSpec
+ GetArchitecture();
+
private:
ObjectFileELF(lldb_private::Module* module,
lldb::DataBufferSP& dataSP,
More information about the lldb-commits
mailing list