[lldb] Prevent object file plugins from changing the data buffer

The current design allows that the object file contents could be mapped
by one object file plugin and then used by another. Presumably the idea
here was to avoid mapping the same file twice.

This becomes an issue when one object file plugin wants to map the file
differently from the others. For example, ObjectFileELF needs to map its
memory as writable while others likeObjectFileMachO needs it to be
mapped read-only.

This patch prevents plugins from changing the buffer by passing them is
by value rather than by reference.

Differential revision: https://reviews.llvm.org/D122944
This commit is contained in:
Jonas Devlieghere
2022-04-04 09:17:01 -07:00
parent b08ede4374
commit c69307e5ee
17 changed files with 37 additions and 39 deletions

View File

@@ -817,7 +817,7 @@ void ObjectFileMachO::Terminate() {
}
ObjectFile *ObjectFileMachO::CreateInstance(const lldb::ModuleSP &module_sp,
DataBufferSP &data_sp,
DataBufferSP data_sp,
lldb::offset_t data_offset,
const FileSpec *file,
lldb::offset_t file_offset,
@@ -848,7 +848,7 @@ ObjectFile *ObjectFileMachO::CreateInstance(const lldb::ModuleSP &module_sp,
}
ObjectFile *ObjectFileMachO::CreateMemoryInstance(
const lldb::ModuleSP &module_sp, DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, DataBufferSP data_sp,
const ProcessSP &process_sp, lldb::addr_t header_addr) {
if (ObjectFileMachO::MagicBytesMatch(data_sp, 0, data_sp->GetByteSize())) {
std::unique_ptr<ObjectFile> objfile_up(