Skip to content

Commit 65438cd

Browse files
committed
[CHERIoT] Teach LLDB to read CHERI & CHERIoT features from ELF files.
1 parent 8896e09 commit 65438cd

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

lldb/include/lldb/Utility/ArchSpec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ class ArchSpec {
9999
eRISCV_float_abi_mask = 0x00000006,
100100
eRISCV_rve = 0x00000008, /// RVE, +e
101101
eRISCV_tso = 0x00000010, /// RVTSO (total store ordering)
102+
eRISCV_cheri_abi = 0x10000000,
103+
eRISCV_cap_mode = 0x20000000,
104+
eRISCV_cheriot = 0x40000000,
102105
};
103106

104107
enum RISCVSubType {

lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,12 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
15771577
if ((arch_flags & ArchSpec::eRISCV_float_abi_quad) ==
15781578
ArchSpec::eRISCV_float_abi_quad)
15791579
features_str += "+f,+d,+q,";
1580+
if ((arch_flags & ArchSpec::eRISCV_cheri_abi) == ArchSpec::eRISCV_cheri_abi)
1581+
features_str += "+xcheri,";
1582+
if ((arch_flags & ArchSpec::eRISCV_cap_mode) == ArchSpec::eRISCV_cap_mode)
1583+
features_str += "+cap-mode,";
1584+
if ((arch_flags & ArchSpec::eRISCV_cheriot) == ArchSpec::eRISCV_cheriot)
1585+
features_str += "+xcheriot,";
15801586
// FIXME: how do we detect features such as `+a`, `+m`?
15811587
// Turn them on by default now, since everyone seems to use them
15821588
features_str += "+a,+m,";

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,16 @@ size_t ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
14331433
llvm::ELF::EF_RISCV_FLOAT_ABI_QUAD)
14341434
flags |= ArchSpec::eRISCV_float_abi_quad;
14351435

1436+
if ((header.e_flags & llvm::ELF::EF_RISCV_CHERIABI) ==
1437+
llvm::ELF::EF_RISCV_CHERIABI)
1438+
flags |= ArchSpec::eRISCV_cheri_abi;
1439+
if ((header.e_flags & llvm::ELF::EF_RISCV_CAP_MODE) ==
1440+
llvm::ELF::EF_RISCV_CAP_MODE)
1441+
flags |= ArchSpec::eRISCV_cap_mode;
1442+
if ((header.e_flags & llvm::ELF::EF_RISCV_CHERIOT) ==
1443+
llvm::ELF::EF_RISCV_CHERIOT)
1444+
flags |= ArchSpec::eRISCV_cheriot;
1445+
14361446
arch_spec.SetFlags(flags);
14371447
}
14381448

0 commit comments

Comments
 (0)