Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lldb/include/lldb/lldb-private-interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ typedef size_t (*ObjectFileGetModuleSpecifications)(
lldb::offset_t data_offset, lldb::offset_t file_offset,
lldb::offset_t length, ModuleSpecList &module_specs);
typedef ObjectFile *(*ObjectFileCreateInstance)(const lldb::ModuleSP &module_sp,
lldb::DataBufferSP &data_sp,
lldb::DataBufferSP data_sp,
lldb::offset_t data_offset,
const FileSpec *file,
lldb::offset_t file_offset,
lldb::offset_t length);
typedef ObjectFile *(*ObjectFileCreateMemoryInstance)(
const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t offset);
typedef bool (*ObjectFileSaveCore)(const lldb::ProcessSP &process_sp,
const FileSpec &outfile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void ObjectFileBreakpad::Terminate() {
}

ObjectFile *ObjectFileBreakpad::CreateInstance(
const ModuleSP &module_sp, DataBufferSP &data_sp, offset_t data_offset,
const ModuleSP &module_sp, DataBufferSP data_sp, offset_t data_offset,
const FileSpec *file, offset_t file_offset, offset_t length) {
if (!data_sp) {
data_sp = MapFileData(*file, length, file_offset);
Expand All @@ -84,7 +84,7 @@ ObjectFile *ObjectFileBreakpad::CreateInstance(
}

ObjectFile *ObjectFileBreakpad::CreateMemoryInstance(
const ModuleSP &module_sp, DataBufferSP &data_sp,
const ModuleSP &module_sp, DataBufferSP data_sp,
const ProcessSP &process_sp, addr_t header_addr) {
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class ObjectFileBreakpad : public ObjectFile {
}

static ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);

static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp,
lldb::DataBufferSP &data_sp,
lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr);

Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void ObjectFileELF::Terminate() {
}

ObjectFile *ObjectFileELF::CreateInstance(const lldb::ModuleSP &module_sp,
DataBufferSP &data_sp,
DataBufferSP data_sp,
lldb::offset_t data_offset,
const lldb_private::FileSpec *file,
lldb::offset_t file_offset,
Expand Down Expand Up @@ -383,7 +383,7 @@ ObjectFile *ObjectFileELF::CreateInstance(const lldb::ModuleSP &module_sp,
}

ObjectFile *ObjectFileELF::CreateMemoryInstance(
const lldb::ModuleSP &module_sp, DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, DataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
if (data_sp && data_sp->GetByteSize() > (llvm::ELF::EI_NIDENT)) {
const uint8_t *magic = data_sp->GetBytes();
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ class ObjectFileELF : public lldb_private::ObjectFile {
}

static lldb_private::ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);

static lldb_private::ObjectFile *CreateMemoryInstance(
const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);

static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void ObjectFileJIT::Terminate() {
}

ObjectFile *ObjectFileJIT::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,
Expand All @@ -65,7 +65,7 @@ ObjectFile *ObjectFileJIT::CreateInstance(const lldb::ModuleSP &module_sp,
}

ObjectFile *ObjectFileJIT::CreateMemoryInstance(const lldb::ModuleSP &module_sp,
DataBufferSP &data_sp,
DataBufferSP data_sp,
const ProcessSP &process_sp,
lldb::addr_t header_addr) {
// JIT'ed object file is backed by the ObjectFileJITDelegate, never read from
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class ObjectFileJIT : public lldb_private::ObjectFile {
}

static lldb_private::ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);

static lldb_private::ObjectFile *CreateMemoryInstance(
const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);

static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,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,
Expand Down Expand Up @@ -870,7 +870,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(
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class ObjectFileMachO : public lldb_private::ObjectFile {
}

static lldb_private::ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const lldb_private::FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);

static lldb_private::ObjectFile *CreateMemoryInstance(
const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);

static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ void ObjectFileMinidump::Terminate() {
}

ObjectFile *ObjectFileMinidump::CreateInstance(
const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const lldb_private::FileSpec *file,
lldb::offset_t offset, lldb::offset_t length) {
return nullptr;
}

ObjectFile *ObjectFileMinidump::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) {
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class ObjectFileMinidump : public lldb_private::PluginInterface {
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }

static lldb_private::ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const lldb_private::FileSpec *file,
lldb::offset_t offset, lldb::offset_t length);

static lldb_private::ObjectFile *CreateMemoryInstance(
const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);

static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool ObjectFilePDB::initPDBFile() {
}

ObjectFile *
ObjectFilePDB::CreateInstance(const ModuleSP &module_sp, DataBufferSP &data_sp,
ObjectFilePDB::CreateInstance(const ModuleSP &module_sp, DataBufferSP data_sp,
offset_t data_offset, const FileSpec *file,
offset_t file_offset, offset_t length) {
auto objfile_up = std::make_unique<ObjectFilePDB>(
Expand All @@ -98,7 +98,7 @@ ObjectFilePDB::CreateInstance(const ModuleSP &module_sp, DataBufferSP &data_sp,
}

ObjectFile *ObjectFilePDB::CreateMemoryInstance(const ModuleSP &module_sp,
DataBufferSP &data_sp,
DataBufferSP data_sp,
const ProcessSP &process_sp,
addr_t header_addr) {
return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class ObjectFilePDB : public ObjectFile {
loadPDBFile(std::string PdbPath, llvm::BumpPtrAllocator &Allocator);

static ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);

static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp,
lldb::DataBufferSP &data_sp,
lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr);

Expand Down
12 changes: 5 additions & 7 deletions lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ llvm::StringRef ObjectFilePECOFF::GetPluginDescriptionStatic() {
"(32 and 64 bit)";
}

ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp,
DataBufferSP &data_sp,
lldb::offset_t data_offset,
const lldb_private::FileSpec *file_p,
lldb::offset_t file_offset,
lldb::offset_t length) {
ObjectFile *ObjectFilePECOFF::CreateInstance(
const lldb::ModuleSP &module_sp, DataBufferSP data_sp,
lldb::offset_t data_offset, const lldb_private::FileSpec *file_p,
lldb::offset_t file_offset, lldb::offset_t length) {
FileSpec file = file_p ? *file_p : FileSpec();
if (!data_sp) {
data_sp = MapFileData(file, length, file_offset);
Expand Down Expand Up @@ -117,7 +115,7 @@ ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp,
}

ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile {
static llvm::StringRef GetPluginDescriptionStatic();

static ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const lldb_private::FileSpec *file,
lldb::offset_t offset, lldb::offset_t length);

static lldb_private::ObjectFile *CreateMemoryInstance(
const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);

static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void ObjectFileWasm::Terminate() {
}

ObjectFile *
ObjectFileWasm::CreateInstance(const ModuleSP &module_sp, DataBufferSP &data_sp,
ObjectFileWasm::CreateInstance(const ModuleSP &module_sp, DataBufferSP data_sp,
offset_t data_offset, const FileSpec *file,
offset_t file_offset, offset_t length) {
Log *log = GetLog(LLDBLog::Object);
Expand Down Expand Up @@ -141,7 +141,7 @@ ObjectFileWasm::CreateInstance(const ModuleSP &module_sp, DataBufferSP &data_sp,
}

ObjectFile *ObjectFileWasm::CreateMemoryInstance(const ModuleSP &module_sp,
DataBufferSP &data_sp,
DataBufferSP data_sp,
const ProcessSP &process_sp,
addr_t header_addr) {
if (!ValidateModuleHeader(data_sp))
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class ObjectFileWasm : public ObjectFile {
}

static ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
lldb::offset_t data_offset, const FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length);

static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp,
lldb::DataBufferSP &data_sp,
lldb::DataBufferSP data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr);

Expand Down