diff options
author | Jim Ingham <jingham@apple.com> | 2011-03-07 23:44:08 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2011-03-07 23:44:08 +0000 |
commit | 672e6f59c5e487b83b81c8b13ce162dfda7fdddf (patch) | |
tree | 9172f417067f8fa5c3591dc80174639e99a5685b /lldb/source/Plugins/ObjectFile/ELF | |
parent | 77ad1dc56dcd64faa3fe718cb4133242ead2f5b0 (diff) | |
download | bcm5719-llvm-672e6f59c5e487b83b81c8b13ce162dfda7fdddf.tar.gz bcm5719-llvm-672e6f59c5e487b83b81c8b13ce162dfda7fdddf.zip |
Add a method "GetEntryPoint" to the ObjectFile class, and implement it on MachO & ELF - though the ELF implementation is probably a little weak. Then use this method in place of directly looking for "start" in the ThreadPlanCallFunction constructor to find the stopping point for our function evaluation.
llvm-svn: 127194
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 28 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h | 6 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 8793cfac93e..546dc7840d2 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -16,9 +16,11 @@ #include "lldb/Core/DataBuffer.h" #include "lldb/Core/Error.h" #include "lldb/Core/FileSpecList.h" +#include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" #include "lldb/Core/Stream.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Host/Host.h" #define CASE_AND_STREAM(s, def, width) \ @@ -276,6 +278,32 @@ ObjectFileELF::GetImageInfoAddress() return Address(); } +lldb_private::Address +ObjectFileELF::GetEntryPointAddress () +{ + // If the object file is not an executable it can't hold the entry point. m_entry_point_address + // is initialized to an invalid address, so we can just return that. + // If m_entry_point_address is valid it means we've found it already, so return the cached value. + + if (!IsExecutable() || m_entry_point_address.IsValid()) + return m_entry_point_address; + + // FIXME: This is just looking for the "start" symbol, but that will fail if "start" is stripped. + // There's probably a better way in ELF to find the start address of an executable module. + + SymbolContextList contexts; + SymbolContext context; + if (!m_module->FindSymbolsWithNameAndType(ConstString ("start"), lldb::eSymbolTypeCode, contexts)) + return m_entry_point_address; + + contexts.GetContextAtIndex(0, context); + + m_entry_point_address = context.symbol->GetValue(); + + return m_entry_point_address; + +} + //---------------------------------------------------------------------- // ParseDependentModules //---------------------------------------------------------------------- diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h index 5de0a8aa83a..2b78da5436b 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h @@ -115,6 +115,9 @@ public: virtual lldb_private::Address GetImageInfoAddress(); + + virtual lldb_private::Address + GetEntryPointAddress (); private: ObjectFileELF(lldb_private::Module* module, @@ -156,6 +159,9 @@ private: /// Data extractor holding the string table used to resolve section names. lldb_private::DataExtractor m_shstr_data; + /// Cached value of the entry point for this module. + lldb_private::Address m_entry_point_address; + /// Returns a 1 based index of the given section header. unsigned SectionIndex(const SectionHeaderCollIter &I); |