Skip to content

Commit

Permalink
Implement ObjectFilePECOFF::GetEntryPointAddress.
Browse files Browse the repository at this point in the history
Reviewers: zturner, clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D17970

llvm-svn: 264173
  • Loading branch information
sas committed Mar 23, 2016
1 parent e82f3a0 commit 8e38c66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 21 additions & 1 deletion lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
Expand Up @@ -192,7 +192,8 @@ ObjectFilePECOFF::ObjectFilePECOFF (const lldb::ModuleSP &module_sp,
m_dos_header (),
m_coff_header (),
m_coff_header_opt (),
m_sect_headers ()
m_sect_headers (),
m_entry_point_address ()
{
::memset (&m_dos_header, 0, sizeof(m_dos_header));
::memset (&m_coff_header, 0, sizeof(m_coff_header));
Expand Down Expand Up @@ -814,6 +815,25 @@ ObjectFilePECOFF::GetDependentModules (FileSpecList& files)
return 0;
}

lldb_private::Address
ObjectFilePECOFF::GetEntryPointAddress ()
{
if (m_entry_point_address.IsValid())
return m_entry_point_address;

if (!ParseHeader() || !IsExecutable())
return m_entry_point_address;

SectionList *section_list = GetSectionList();
addr_t offset = m_coff_header_opt.entry;

if (!section_list)
m_entry_point_address.SetOffset(offset);
else
m_entry_point_address.ResolveAddressUsingFileSections(offset, section_list);
return m_entry_point_address;
}


//----------------------------------------------------------------------
// Dump
Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
Expand Up @@ -144,8 +144,8 @@ class ObjectFilePECOFF :
uint32_t
GetDependentModules(lldb_private::FileSpecList& files) override;

// virtual lldb_private::Address
// GetEntryPointAddress ();
virtual lldb_private::Address
GetEntryPointAddress () override;

ObjectFile::Type
CalculateType() override;
Expand Down Expand Up @@ -301,6 +301,7 @@ class ObjectFilePECOFF :
coff_opt_header_t m_coff_header_opt;
SectionHeaderColl m_sect_headers;
lldb::addr_t m_image_base;
lldb_private::Address m_entry_point_address;
};

#endif // liblldb_ObjectFilePECOFF_h_

0 comments on commit 8e38c66

Please sign in to comment.