llvm-project
d6652c18 - [lldb] Fix data buffer regression in ObjectFile (#177724)

Commit
11 days ago
[lldb] Fix data buffer regression in ObjectFile (#177724) This fixes a regression in `ObjectFile` and `ObjectFileELF` introduced by #171574. The original code created a `DataBuffer` using `MapFileDataWritable`. ``` data_sp = MapFileDataWritable(*file, length, file_offset); if (!data_sp) return nullptr; data_offset = 0; ``` The new code requires converting the `DataBuffer` to a `DataExtractor`: ``` DataBufferSP buffer_sp = MapFileDataWritable(*file, length, file_offset); if (!buffer_sp) return nullptr; extractor_sp = std::make_shared<DataExtractor>(); extractor_sp->SetData(buffer_sp, data_offset, buffer_sp->GetByteSize()); data_offset = 0; ``` The issue is that once we get a data buffer back from MapFileDataWritable, we don't have to adjust for the `data_offset` again when calling `SetData` as the `DataBuffer` is already normalized to have a zero start offset. A similar issue exists in `ObjectFile`. rdar://168317174
Author
Parents
Loading