aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Forissier <jerome@forissier.org>2020-07-31 11:05:52 +0200
committerJérôme Forissier <jerome@forissier.org>2020-08-03 13:10:36 +0200
commit0c33be7a1240bcb4b2418f6ef16e193496fc38ea (patch)
treeb8e65eeb80f048d36d90744c6d7499665be904e6
parent9efcd73b9cffc2c50868cb1488c85eb50114ce84 (diff)
ldelf: arm: fix the unwind stack failure with __no_return function
Similar fix to commit 19b3fe6c5a72 ("core: arm: fix the unwind stack failure with __no_return function") for user space. Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
-rw-r--r--ldelf/unwind_arm32.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ldelf/unwind_arm32.c b/ldelf/unwind_arm32.c
index 24c28976..0914466f 100644
--- a/ldelf/unwind_arm32.c
+++ b/ldelf/unwind_arm32.c
@@ -404,8 +404,13 @@ static bool unwind_stack_arm32(struct unwind_state_arm32 *state,
/* The pc value is correct and will be overwritten, save it */
state->start_pc = state->registers[PC];
- /* Find the item to run */
- index = find_index(state->start_pc);
+ /*
+ * Find the item to run. Subtract 2 from PC to make sure that we're
+ * still inside the calling function in case a __no_return function
+ * (typically panic()) is called unconditionally and may cause LR and
+ * thus this PC to point into the next and entirely unrelated function.
+ */
+ index = find_index(state->start_pc - 2);
if (!index)
return false;