[CodeGen] Use Register/MCRegister::isPhysical. NFC
[llvm-project.git] / lldb / source / Plugins / ObjectFile / Placeholder / ObjectFilePlaceholder.cpp
blobe8745d6dd6b83c5d44527b46180150f2f2773886
1 //===-- ObjectFilePlaceholder.cpp----------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "ObjectFilePlaceholder.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/ModuleSpec.h"
13 #include "lldb/Core/PluginManager.h"
14 #include "lldb/Core/Section.h"
15 #include "lldb/Target/SectionLoadList.h"
16 #include "lldb/Target/Target.h"
18 #include <memory>
20 using namespace lldb;
21 using namespace lldb_private;
23 LLDB_PLUGIN_DEFINE(ObjectFilePlaceholder)
25 ObjectFilePlaceholder::ObjectFilePlaceholder(
26 const lldb::ModuleSP &module_sp,
27 const lldb_private::ModuleSpec &module_spec, lldb::addr_t base,
28 lldb::addr_t size)
29 : ObjectFile(module_sp, &module_spec.GetFileSpec(), /*file_offset*/ 0,
30 /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0),
31 m_arch(module_spec.GetArchitecture()), m_uuid(module_spec.GetUUID()),
32 m_base(base), m_size(size) {
33 m_symtab_up = std::make_unique<lldb_private::Symtab>(this);
36 void ObjectFilePlaceholder::CreateSections(
37 lldb_private::SectionList &unified_section_list) {
38 m_sections_up = std::make_unique<lldb_private::SectionList>();
39 auto section_sp = std::make_shared<lldb_private::Section>(
40 GetModule(), this, /*sect_id*/ 0,
41 lldb_private::ConstString(".module_image"), eSectionTypeOther, m_base,
42 m_size, /*file_offset*/ 0, /*file_size*/ 0,
43 /*log2align*/ 0, /*flags*/ 0);
44 section_sp->SetPermissions(ePermissionsReadable | ePermissionsExecutable);
45 m_sections_up->AddSection(section_sp);
46 unified_section_list.AddSection(std::move(section_sp));
49 lldb_private::Address ObjectFilePlaceholder::GetBaseAddress() {
50 return lldb_private::Address(m_sections_up->GetSectionAtIndex(0), 0);
53 bool ObjectFilePlaceholder::SetLoadAddress(Target &target, addr_t value,
54 bool value_is_offset) {
55 assert(!value_is_offset);
56 assert(value == m_base);
58 // Create sections if they haven't been created already.
59 GetModule()->GetSectionList();
60 assert(m_sections_up->GetNumSections(0) == 1);
62 target.SetSectionLoadAddress(m_sections_up->GetSectionAtIndex(0), m_base);
63 return true;
66 void ObjectFilePlaceholder::Dump(lldb_private::Stream *s) {
67 s->Format("Placeholder object file for {0} loaded at [{1:x}-{2:x})\n",
68 GetFileSpec(), m_base, m_base + m_size);