diff options
| author | Pavel Labath <labath@google.com> | 2018-02-27 22:14:33 +0000 |
|---|---|---|
| committer | Pavel Labath <labath@google.com> | 2018-02-27 22:14:33 +0000 |
| commit | 029fb693722ee87cf0aebc75ba823d4ed020215a (patch) | |
| tree | f6939628eacb5ebb1c58b6f97662c6f3521625d2 /lldb/source/Symbol/ObjectFile.cpp | |
| parent | 3acdc6773444b0dea84a69e99024e07ebabc0c98 (diff) | |
| download | bcm5719-llvm-029fb693722ee87cf0aebc75ba823d4ed020215a.tar.gz bcm5719-llvm-029fb693722ee87cf0aebc75ba823d4ed020215a.zip | |
[lldb] Use vFlash commands when writing to target's flash memory regions
Summary:
When writing an object file over gdb-remote, use the vFlashErase, vFlashWrite, and vFlashDone commands if the write address is in a flash memory region. A bare metal target may have this kind of setup.
- Update ObjectFileELF to set load addresses using physical addresses. A typical case may be a data section with a physical address in ROM and a virtual address in RAM, which should be loaded to the ROM address.
- Add support for querying the target's qXfer:memory-map, which contains information about flash memory regions, leveraging MemoryRegionInfo data structures with minor modifications
- Update ProcessGDBRemote to use vFlash commands in DoWriteMemory when the target address is in a flash region
Original discussion at http://lists.llvm.org/pipermail/lldb-dev/2018-January/013093.html
Reviewers: clayborg, labath
Reviewed By: labath
Subscribers: arichardson, emaste, mgorny, lldb-commits
Differential Revision: https://reviews.llvm.org/D42145
Patch by Owen Shaw <llvm@owenpshaw.net>
llvm-svn: 326261
Diffstat (limited to 'lldb/source/Symbol/ObjectFile.cpp')
| -rw-r--r-- | lldb/source/Symbol/ObjectFile.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index 2129a4463cd..ce8f04a9ff1 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -659,22 +659,31 @@ Status ObjectFile::LoadInMemory(Target &target, bool set_pc) { SectionList *section_list = GetSectionList(); if (!section_list) return Status("No section in object file"); + + std::vector<Process::WriteEntry> writeEntries; + + // Create a list of write entries from loadable sections size_t section_count = section_list->GetNumSections(0); for (size_t i = 0; i < section_count; ++i) { + Process::WriteEntry entry; SectionSP section_sp = section_list->GetSectionAtIndex(i); - addr_t addr = target.GetSectionLoadList().GetSectionLoadAddress(section_sp); - if (addr != LLDB_INVALID_ADDRESS) { - DataExtractor section_data; - // We can skip sections like bss - if (section_sp->GetFileSize() == 0) - continue; - section_sp->GetSectionData(section_data); - lldb::offset_t written = process->WriteMemory( - addr, section_data.GetDataStart(), section_data.GetByteSize(), error); - if (written != section_data.GetByteSize()) - return error; - } + entry.Dest = target.GetSectionLoadList().GetSectionLoadAddress(section_sp); + if (entry.Dest == LLDB_INVALID_ADDRESS) + continue; + // We can skip sections like bss + if (section_sp->GetFileSize() == 0) + continue; + DataExtractor section_data; + section_sp->GetSectionData(section_data); + entry.Contents = llvm::ArrayRef<uint8_t>(section_data.GetDataStart(), + section_data.GetByteSize()); + writeEntries.push_back(entry); } + + error = process->WriteObjectFile(std::move(writeEntries)); + if (!error.Success()) + return error; + if (set_pc) { ThreadList &thread_list = process->GetThreadList(); ThreadSP curr_thread(thread_list.GetSelectedThread()); |

