diff options
| author | Greg Clayton <gclayton@fb.com> | 2025-03-07 15:34:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-07 15:34:27 -0800 |
| commit | 8ac359ba0d7ec1f1e7334a50405f0f20983b997a (patch) | |
| tree | afcb0da491e9f2e65b05c13bd523c43a34b01bdc /lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp | |
| parent | 0ea52234fc3510463df2d8718404cede874e9b5e (diff) | |
Add complete ObjectFileJSON support for sections. (#129916)
Sections now support specifying:
- user IDs
- file offset/size
- alignment
- flags
- bool values for fake, encrypted and thread specific sections
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp')
| -rw-r--r-- | lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp b/lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp index 0f9676b836b5..cb8ba05d461d 100644 --- a/lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp +++ b/lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp @@ -179,39 +179,35 @@ void ObjectFileJSON::CreateSections(SectionList &unified_section_list) { return; m_sections_up = std::make_unique<SectionList>(); - lldb::user_id_t id = 1; + lldb::user_id_t id = 0; for (const auto &json_section : m_sections) { auto make_section = [this, &id](const JSONSection §ion, SectionSP parent_section_sp = nullptr) -> SectionSP { SectionSP section_sp; + auto sect_id = section.user_id.value_or(id + 1); + if (!section.user_id.has_value()) + ++id; + const auto name = ConstString(section.name); + const auto sect_type = section.type.value_or(eSectionTypeCode); + const auto vm_addr = section.address.value_or(0); + const auto vm_size = section.size.value_or(0); + const auto file_offset = section.file_offset.value_or(0); + const auto file_size = section.file_size.value_or(0); + const auto log2align = section.log2align.value_or(0); + const auto flags = section.flags.value_or(0); if (parent_section_sp) { section_sp = std::make_shared<Section>( - parent_section_sp, GetModule(), this, - /*sect_id=*/id++, - /*name=*/ConstString(section.name), - /*sect_type=*/section.type.value_or(eSectionTypeCode), - /*file_vm_addr=*/section.address.value_or(0) - - parent_section_sp->GetFileAddress(), - /*vm_size=*/section.size.value_or(0), - /*file_offset=*/0, - /*file_size=*/0, - /*log2align=*/0, - /*flags=*/0); + parent_section_sp, GetModule(), this, sect_id, name, sect_type, + vm_addr - parent_section_sp->GetFileAddress(), vm_size, file_offset, + file_size, log2align, flags); } else { section_sp = std::make_shared<Section>( - GetModule(), this, - /*sect_id=*/id++, - /*name=*/ConstString(section.name), - /*sect_type=*/section.type.value_or(eSectionTypeCode), - /*file_vm_addr=*/section.address.value_or(0), - /*vm_size=*/section.size.value_or(0), - /*file_offset=*/0, - /*file_size=*/0, - /*log2align=*/0, - /*flags=*/0); + GetModule(), this, sect_id, name, sect_type, vm_addr, vm_size, + file_offset, file_size, log2align, flags); } + // Set permissions uint32_t permissions = 0; if (section.read.value_or(0)) permissions |= lldb::ePermissionsReadable; @@ -221,6 +217,9 @@ void ObjectFileJSON::CreateSections(SectionList &unified_section_list) { permissions |= lldb::ePermissionsExecutable; if (permissions) section_sp->SetPermissions(permissions); + section_sp->SetIsFake(section.fake.value_or(false)); + section_sp->SetIsEncrypted(section.encrypted.value_or(false)); + section_sp->SetIsThreadSpecific(section.thread_specific.value_or(false)); return section_sp; }; auto section_sp = make_section(json_section); |
