Commit e2f27392 authored by Jinyang He's avatar Jinyang He Committed by Huacai Chen
Browse files

LoongArch: Adjust PC value when unwind next frame in unwinder



When state->first is not set, the PC is a return address in the previous
frame. We need to adjust its value in case overflow to the next symbol.

Signed-off-by: default avatarJinyang He <hejinyang@loongson.cn>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent 3200983f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ static bool unwind_by_prologue(struct unwind_state *state)
{
	long frame_ra = -1;
	unsigned long frame_size = 0;
	unsigned long size, offset, pc = state->pc;
	unsigned long size, offset, pc;
	struct pt_regs *regs;
	struct stack_info *info = &state->stack_info;
	union loongarch_instruction *ip, *ip_end;
@@ -78,6 +78,11 @@ static bool unwind_by_prologue(struct unwind_state *state)
		return true;
	}

	/*
	 * When first is not set, the PC is a return address in the previous frame.
	 * We need to adjust its value in case overflow to the next symbol.
	 */
	pc = state->pc - (state->first ? 0 : LOONGARCH_INSN_SIZE);
	if (!kallsyms_lookup_size_offset(pc, &size, &offset))
		return false;