[LLDB] [PECOFF] Make sure to set the address byte size in m_data after parsing headers
authorMartin Storsjö <martin@martin.st>
Fri, 6 Dec 2019 11:25:38 +0000 (13:25 +0200)
committerMartin Storsjö <martin@martin.st>
Tue, 10 Dec 2019 11:55:38 +0000 (13:55 +0200)
If not set, the address byte size was implied to be the one of the
host process.

This allows reverting the functional change from 31087b2ae9154, since
now PECOFF does the same as ELF and MachO wrt setting both byte order
and address size on m_data within ParseHeader.

Differential Revision: https://reviews.llvm.org/D71108

lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Symbol/ObjectFile.cpp

index b0ce967..2e62e32 100644 (file)
@@ -315,6 +315,7 @@ bool ObjectFilePECOFF::ParseHeader() {
           ParseCOFFOptionalHeader(&offset);
         ParseSectionHeaders(offset);
       }
+      m_data.SetAddressByteSize(GetAddressByteSize());
       return true;
     }
   }
index 812c6de..4f6d74b 100644 (file)
@@ -477,13 +477,7 @@ size_t ObjectFile::GetData(lldb::offset_t offset, size_t length,
                            DataExtractor &data) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,