[Lldb-commits] [lldb] ede7c02 - [lldb/COFF] Remove strtab zeroing hack

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 17 04:25:53 PDT 2020


Author: Pavel Labath
Date: 2020-07-17T13:24:59+02:00
New Revision: ede7c02b38c0c3adf7fb9ee308bd0f6d92a0eb4e

URL: https://github.com/llvm/llvm-project/commit/ede7c02b38c0c3adf7fb9ee308bd0f6d92a0eb4e
DIFF: https://github.com/llvm/llvm-project/commit/ede7c02b38c0c3adf7fb9ee308bd0f6d92a0eb4e.diff

LOG: [lldb/COFF] Remove strtab zeroing hack

Summary:
This code (recently responsible for a unaligned access sanitizer
failure) claims that the string table offset zero should result in an
empty string.

I cannot find any mention of this detail in the Microsoft COFF
documentation, and the llvm COFF parser also does not handle offset zero
specially. This code was introduced in 0076e7159, which also does not go
into specifics, citing "various bugfixes".

Given that this is obviously a hack, and does not cause tests to fail, I
think we should just delete it.

Reviewers: amccarth, markmentovai

Subscribers: lldb-commits

Tags: #lldb

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

Added: 
    

Modified: 
    lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index d606b49130c4..5feec8167186 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -543,12 +543,6 @@ DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
   if (m_data.ValidOffsetForDataOfSize(offset, size))
     return DataExtractor(m_data, offset, size);
 
-  if (m_file) {
-    // A bit of a hack, but we intend to write to this buffer, so we can't
-    // mmap it.
-    auto buffer_sp = MapFileData(m_file, size, offset);
-    return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
-  }
   ProcessSP process_sp(m_process_wp.lock());
   DataExtractor data;
   if (process_sp) {
@@ -652,12 +646,6 @@ Symtab *ObjectFilePECOFF::GetSymtab() {
           DataExtractor strtab_data = ReadImageData(
               m_coff_header.symoff + symbol_data_size, strtab_size);
 
-          // First 4 bytes should be zeroed after strtab_size has been read,
-          // because it is used as offset 0 to encode a NULL string.
-          uint32_t *strtab_data_start = const_cast<uint32_t *>(
-              reinterpret_cast<const uint32_t *>(strtab_data.GetDataStart()));
-          ::memset(&strtab_data_start[0], 0, sizeof(uint32_t));
-
           offset = 0;
           std::string symbol_name;
           Symbol *symbols = m_symtab_up->Resize(num_syms);


        


More information about the lldb-commits mailing list