[Lldb-commits] [PATCH] D17970: Implement ObjectFilePECOFF::GetEntryPointAddress.

Stephane Sezer via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 17 14:40:56 PDT 2016


sas updated this revision to Diff 50978.
sas added a comment.

Change implementation according to @clayborg's comments.


http://reviews.llvm.org/D17970

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===================================================================
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -144,8 +144,8 @@
     uint32_t
     GetDependentModules(lldb_private::FileSpecList& files) override;
     
-//    virtual lldb_private::Address
-//    GetEntryPointAddress ();
+    virtual lldb_private::Address
+    GetEntryPointAddress () override;
     
     ObjectFile::Type
     CalculateType() override;
@@ -301,6 +301,7 @@
 	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_
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -192,7 +192,8 @@
     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));
@@ -814,6 +815,25 @@
     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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17970.50978.patch
Type: text/x-patch
Size: 1977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160317/71fd6d46/attachment.bin>


More information about the lldb-commits mailing list