================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to