Skip to content

Commit

Permalink
[lldb/COFF] Remove strtab zeroing hack
Browse files Browse the repository at this point in the history
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 0076e71, 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
  • Loading branch information
labath committed Jul 17, 2020
1 parent 6c348e4 commit ede7c02
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ede7c02

Please sign in to comment.