[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1c132209a612e2e8953f0b458fc01853120db9a9.camel@xry111.site>
Date: Thu, 06 Jun 2024 03:05:41 +0800
From: Xi Ruoyao <xry111@...111.site>
To: Jinyang He <hejinyang@...ngson.cn>, Nathan Chancellor
<nathan@...nel.org>, Peter Zijlstra <peterz@...radead.org>
Cc: Huacai Chen <chenhuacai@...nel.org>, WANG Xuerui <kernel@...0n.name>,
Tiezhu Yang <yangtiezhu@...ngson.cn>, Nick Desaulniers
<ndesaulniers@...gle.com>, Bill Wendling <morbo@...gle.com>, Justin Stitt
<justinstitt@...gle.com>, Youling Tang <tangyouling@...inos.cn>,
loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev, mengqinggang@...ngson.cn, cailulu@...ngson.cn,
wanglei@...ngson.cn, luweining@...ngson.cn, Yujie Liu
<yujie.liu@...el.com>, Heng Qi <hengqi@...ux.alibaba.com>, Tejun Heo
<tj@...nel.org>
Subject: Re: [PATCH] loongarch: Only select HAVE_OBJTOOL and allow ORC
unwinder if the inline assembler supports R_LARCH_{32,64}_PCREL
On Wed, 2024-06-05 at 23:47 +0800, Jinyang He wrote:
> In our 419 repo this func has been renamed arch_update_insn_state (, now it
> should be arch_update_cfi_state) and give some actions to deal with the
> frame pointer case. If we support it we may deal with some case but for
> clang...
>
> .global test
> .type test,@function
> test:
>
> addi.d $sp,$sp,-448
> st.d $ra,$sp,440
> st.d $fp,$sp,432
> addi.d $fp,$sp,448
>
> # do something <- not change $sp
This is simplified. In the real code $sp is changed, something like:
bstrins.d $sp, $zero, 5, 0
$fp is needed to allow restoring $sp after realigning $sp for some local
over-aligned variables, as demonstrated by this example:
struct x { _Alignas(64) char buf[128]; };
void f(struct x *p);
void g()
{
struct x x = { .buf = "1145141919810" };
f(&x);
}
GCC does not align $sp, it produces the aligned address for x from an
unaligned $sp instead:
addi.d $a0, $sp, 63
srli.d $a0, $a0, 6
slli.d $a0, $a0, 6
thus there's no need to use $fp.
/* snip */
> <- restore regs from non-cfa ?
> ld.d $ra, $sp, 8 # 8-byte Folded Reload
/* snip */
> Maybe Clang have anything wrong?
I don't think we must restore regs based on $fp just because CFA is
based on $fp. The .cfi directives only provides *one* possible way to
restore the regs. This way is convenient to the unwinder, but not
necessarily convenient to the CPU thus the real instruction sequence can
use a different way. They only need to be "equivalent", not necessarily
"exactly same."
Also note that .cfi_* directives are completely irrelevant for objtool.
THe objtool synthesizes the ORC unwind info from the machine
instructions, not the DWARF unwind info coded with .cfi_*.
The entire point of ORC is avoiding DWARF. It's even named ORC because
ORC and DWARF are sworn enemies in some tales.
--
Xi Ruoyao <xry111@...111.site>
School of Aerospace Science and Technology, Xidian University
Powered by blists - more mailing lists