[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 8 06:18:11 PDT 2025
================
@@ -1284,6 +1285,54 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
return error;
}
+void ObjectFileELF::ParseRISCVAttributes(DataExtractor &data, uint64_t length,
+ ArchSpec &arch_spec) {
+ lldb::offset_t offset = 0;
+
+ uint8_t format_version = data.GetU8(&offset);
+ if (format_version != llvm::ELFAttrs::Format_Version)
+ return;
+
+ offset = offset + sizeof(uint32_t); // Section Length
+ llvm::StringRef vendor_name = data.GetCStr(&offset);
+
+ if (vendor_name != "riscv")
+ return;
+
+ llvm::StringRef attr = "";
+
+ while (offset < length) {
+ uint8_t Tag = data.GetU8(&offset);
+ uint32_t Size = data.GetU32(&offset);
+
+ if (Tag != llvm::ELFAttrs::File || Size == 0)
+ continue;
+
+ while (offset < length) {
+ uint64_t Tag = data.GetULEB128(&offset);
+ if (Tag == llvm::RISCVAttrs::ARCH) {
+ attr = data.GetCStr(&offset);
+ break;
+ } else {
+ data.GetULEB128(&offset);
+ }
+ }
+ }
+
+ // List of RISC-V architecture extensions to detect from ELF.
+ // These extensions are extracted from the ".riscv.attributes" section.
+ // New extensions can be added to this list for detection without
+ // modifying the core logic.
+ std::vector<std::string> riscv_extensions = {"xqci"};
----------------
DavidSpickett wrote:
Why do we need this allowlist?
Are you expecting RISC-V binaries to have extension names not recognised by LLVM? Which could happen, but it is not evident from the comment here.
https://github.com/llvm/llvm-project/pull/147990
More information about the lldb-commits
mailing list