[llvm-branch-commits] [lldb] [lldb][RISCV] update RISCV target features in disassembler (PR #173047)
David Spickett via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Feb 3 08:06:30 PST 2026
================
@@ -0,0 +1,71 @@
+"""
+Tests that LLDB can correctly set up a disassembler using extensions from the .riscv.attributes section.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestDisassembler(TestBase):
+ expected_zbb_instrs = ["andn", "orn", "xnor", "rol", "ror", "ret"]
+
+ def _get_llvm_tool(self, tool):
+ clang = self.getCompiler()
+ bindir = os.path.dirname(clang)
+ candidate = os.path.join(bindir, tool)
+ if os.path.exists(candidate):
+ return candidate
+ return lldbutil.which(tool)
+
+ def _strip_riscv_attributes(self):
+ """
+ Strips the .riscv.attributes section.
+ """
+ exe = self.getBuildArtifact("a.out")
+ stripped = self.getBuildArtifact("stripped.out")
+
+ objcopy_path = self._get_llvm_tool("llvm-objcopy")
+ self.assertTrue(objcopy_path, "llvm-objcopy not found")
+
+ out = subprocess.run(
+ [objcopy_path, "--remove-section=.riscv.attributes", exe, stripped],
+ check=True,
+ )
----------------
DavidSpickett wrote:
There is a test TestCTF.py that uses makefile commands to do this. It has a skip if there is no objcopy, which you could do here as well. You can `self.skip(<reason>)`.
In practice I expect it'll always be there.
https://github.com/llvm/llvm-project/pull/173047
More information about the llvm-branch-commits
mailing list