diff options
author | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2017-01-24 23:07:27 +0000 |
---|---|---|
committer | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2017-01-24 23:07:27 +0000 |
commit | b10fb96541bc45aea71c8652bb1786899826f7ad (patch) | |
tree | e8e96808bc8afa6246afa5d880daf41ec14534bc /lldb/source/Symbol/ObjectFile.cpp | |
parent | 8c6ed0f3a081fee5f6e1372c39dbbcec07969ab9 (diff) | |
download | bcm5719-llvm-b10fb96541bc45aea71c8652bb1786899826f7ad.tar.gz bcm5719-llvm-b10fb96541bc45aea71c8652bb1786899826f7ad.zip |
Provide option to set pc of the file loaded in memory.
Summary: This commit adds an option to set PC to the entry point of the file loaded using "target module load" command. In D28804, Greg asked me to separate this part under a different option.
Reviewers: clayborg
Reviewed By: clayborg
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D28944
llvm-svn: 292989
Diffstat (limited to 'lldb/source/Symbol/ObjectFile.cpp')
-rw-r--r-- | lldb/source/Symbol/ObjectFile.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index ecae78e3954..c5f0b477a91 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -652,11 +652,13 @@ ConstString ObjectFile::GetNextSyntheticSymbolName() { return ConstString(ss.GetString()); } -Error ObjectFile::LoadInMemory(Target &target) { +Error ObjectFile::LoadInMemory(Target &target, bool set_pc) { Error error; ProcessSP process = target.CalculateProcess(); if (!process) return Error("No Process"); + if (set_pc && !GetEntryPointAddress().IsValid()) + return Error("No entry address in object file"); SectionList *section_list = GetSectionList(); if (!section_list) @@ -677,5 +679,12 @@ Error ObjectFile::LoadInMemory(Target &target) { return error; } } + if (set_pc) { + ThreadList &thread_list = process->GetThreadList(); + ThreadSP curr_thread(thread_list.GetSelectedThread()); + RegisterContextSP reg_context(curr_thread->GetRegisterContext()); + Address file_entry = GetEntryPointAddress(); + reg_context->SetPC(file_entry.GetLoadAddress(&target)); + } return error; } |