[Lldb-commits] [PATCH] D39337: Implement a simple GetAddressClass for PECOFF

Stephane Sezer via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 26 10:50:04 PDT 2017


sas created this revision.

This function apparently is called only by addresses that are valid.
We mainly need to use the ISA class whenever is needed.

Depends on https://reviews.llvm.org/D39315.

Change by Walter Erquinigo <wallace at fb.com>


https://reviews.llvm.org/D39337

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
@@ -102,8 +102,7 @@
 
   uint32_t GetAddressByteSize() const override;
 
-  //    virtual lldb_private::AddressClass
-  //    GetAddressClass (lldb::addr_t file_addr);
+  lldb::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
 
   lldb_private::Symtab *GetSymtab() override;
 
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -678,6 +678,23 @@
   return false;
 }
 
+lldb::AddressClass ObjectFilePECOFF::GetAddressClass(lldb::addr_t file_addr) {
+  auto address_class = ObjectFile::GetAddressClass(file_addr);
+  // Some addresses (e.g. from trampolines) are marked as eAddressClassUnknown.
+  if (address_class == eAddressClassCode ||
+      address_class == eAddressClassUnknown) {
+    ArchSpec header_arch;
+    GetArchitecture(header_arch);
+    if (header_arch.GetMachine() == llvm::Triple::arm) {
+      // The only PECOFF/ARM target we support, Windows Phone, requires all
+      // user code to be Thumb, so we can always return
+      // eAddressClassCodeAlternateISA.
+      return eAddressClassCodeAlternateISA;
+    }
+  }
+  return address_class;
+}
+
 void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
   if (!m_sections_ap.get()) {
     m_sections_ap.reset(new SectionList());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39337.120451.patch
Type: text/x-patch
Size: 1670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171026/1ac97851/attachment.bin>


More information about the lldb-commits mailing list