aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2024-05-21 21:07:04 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-05-21 21:07:04 +0000
commitb7e98953b081a9809f335b4c883ef5e9bb06e817 (patch)
tree99069b5bfb119590b81769d6079c83030d2b05d9
parent021cd6d2ca52a0b15f902f9fa4ab7925d5701783 (diff)
parentccc4dbf135cf06fd9d3d82cd341142c31b365081 (diff)
downloadbionic-b7e98953b081a9809f335b4c883ef5e9bb06e817.tar.gz
Merge "execinfo.cpp: Add a __riscv case." into main
-rw-r--r--libc/bionic/execinfo.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/bionic/execinfo.cpp b/libc/bionic/execinfo.cpp
index d129f7cae..e53a0377c 100644
--- a/libc/bionic/execinfo.cpp
+++ b/libc/bionic/execinfo.cpp
@@ -73,6 +73,11 @@ static _Unwind_Reason_Code TraceFunction(_Unwind_Context* context, void* arg) {
#elif defined(__aarch64__)
// All instructions are 4 bytes long, skip back one instruction.
ip -= 4;
+#elif defined(__riscv)
+ // C instructions are the shortest at 2 bytes long. (Unlike thumb, it's
+ // non-trivial to recognize C instructions when going backwards in the
+ // instruction stream.)
+ ip -= 2;
#elif defined(__i386__) || defined(__x86_64__)
// It's difficult to decode exactly where the previous instruction is,
// so subtract 1 to estimate where the instruction lives.