summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2023-08-07 18:51:24 +0100
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2023-08-08 18:00:05 +0000
commit6c6876c2642990f14400945b35a9ec95179d81e3 (patch)
tree9abf067ac79c3aab1d0a015715a5ac1463c1813c
parent973cc9325dcf47edd233db95a00b99c36e0c54e3 (diff)
Add RISCV to CFI checker
The LLVM tooling have been fixed to generate the correct code offsets in DWARF and CFI. This means we can enable the CFI checker for RISCV. Test: check_cfi.py passes for RISCV Change-Id: I2fc8084e25decd650eb416d672ad32d136248f1e
-rw-r--r--runtime/interpreter/mterp/riscv64/main.S9
-rwxr-xr-xtools/check_cfi.py7
2 files changed, 12 insertions, 4 deletions
diff --git a/runtime/interpreter/mterp/riscv64/main.S b/runtime/interpreter/mterp/riscv64/main.S
index a908612a1e..d8538b5015 100644
--- a/runtime/interpreter/mterp/riscv64/main.S
+++ b/runtime/interpreter/mterp/riscv64/main.S
@@ -388,7 +388,9 @@ END \name
*/
OAT_ENTRY ExecuteNterpWithClinitImpl, EndExecuteNterpWithClinitImpl
+ .cfi_startproc
unimp
+ .cfi_endproc
EndExecuteNterpWithClinitImpl:
OAT_ENTRY ExecuteNterpImpl, EndExecuteNterpImpl
@@ -432,9 +434,6 @@ OAT_ENTRY ExecuteNterpImpl, EndExecuteNterpImpl
// Enclose all code below in a symbol (which gets printed in backtraces).
NAME_START nterp_helper
-// This is the logical end of ExecuteNterpImpl, where the frame info applies.
-.cfi_endproc
-NAME_END nterp_helper
common_errDivideByZero:
EXPORT_PC
@@ -449,6 +448,10 @@ common_errDivideByZero:
.global EndExecuteNterpImpl
EndExecuteNterpImpl:
+// This is the logical end of ExecuteNterpImpl, where the frame info applies.
+.cfi_endproc
+NAME_END nterp_helper
+
// Entrypoints into runtime.
NTERP_TRAMPOLINE nterp_hot_method, NterpHotMethod
diff --git a/tools/check_cfi.py b/tools/check_cfi.py
index 36c96d7ea0..274e377e4f 100755
--- a/tools/check_cfi.py
+++ b/tools/check_cfi.py
@@ -39,7 +39,7 @@ IGNORE : Dict[str, List[str]] = {
# Starts with non-zero offset at the start of the method.
"art_quick_throw_null_pointer_exception_from_signal": ["arm", "aarch64", "i386", "x86_64"],
# Pops stack without static control flow past the opcode.
- "nterp_op_return": ["arm", "aarch64", "i386", "x86_64"],
+ "nterp_op_return": ["arm", "aarch64", "i386", "x86_64", "riscv64"],
}
SP = {"arm": "SP", "aarch64": "WSP", "i386": "ESP", "x86_64": "RSP", "riscv64": "X2"}
@@ -73,6 +73,10 @@ def get_inst_semantics(arch: str) -> List[Any]:
add(r"v?pop(?:\.w)? \{([\w+, ]*)\}", lambda m: -4 * len(m[1].split(",")))
add(r"cb\w* \w+, (0x\w+).*", adjust_pc=lambda m: int(m[1], 0))
add(r"(?:b|bl|b\w\w) (0x\w+).*", adjust_pc=lambda m: int(m[1], 0))
+ if arch in ["riscv64"]:
+ add(r"addi sp, sp, (-?\w+)", lambda m: -int(m[1], 0))
+ add(r"b\w* (?:\w+, )+(0x\w+).*", adjust_pc=lambda m: int(m[1], 0))
+ add(r"(?:j|jal) (?:\w+, )?(0x\w+).*", adjust_pc=lambda m: int(m[1], 0))
return rexprs
@dataclass(frozen=True)
@@ -244,6 +248,7 @@ def check_lib(lib: pathlib.Path) -> int:
srcs = {src.pc: src.file + ":" + src.line for src in get_src(lib)}
seen = set() # Used to verify the we have covered all assembly source lines.
fail = 0
+ assert srcs, "No sources found"
for fde in fdes:
if fde.pc not in srcs: