[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <AAAA7852-EBCA-47A3-B74E-A425023468C6@jrtc27.com>
Date: Wed, 19 Jan 2022 19:05:13 +0000
From: Jessica Clarke <jrtc27@...c27.com>
To: Andreas Schwab <schwab@...ux-m68k.org>
Cc: Changbin Du <changbin.du@...il.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
linux-riscv <linux-riscv@...ts.infradead.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] riscv: eliminate unreliable __builtin_frame_address(1)
On 19 Jan 2022, at 10:58, Andreas Schwab <schwab@...ux-m68k.org> wrote:
>
> On Jan 17 2022, Jessica Clarke wrote:
>
>> Yes, this is a bug, that is always wrong. LLVM gets this right.
>
> Is that an ABI requirement? In case of a leaf function, gcc saves the
> caller's frame pointer in the first slot, not the second (it doesn't
> save the return address).
Leaf functions by definition don’t have callees that are trying to read
their frame pointer so aren’t relevant here. The stack frame layout
isn’t specified by the ABI, only that the in-memory outgoing arguments
be at the bottom when calling other functions. However, GCC knows what
layout it uses, so it should be consistent and follow that layout for
walking back up frames. Especially for __builtin_frame_address(1), that
just pertains to the current function’s frame, which it clearly knows
without a doubt, so there’s no reason to get that wrong. Accessing
0(s0) is just straight up wrong, that’s accessing past the top of the
stack frame, which is never going to make any sense.
Jess
Powered by blists - more mailing lists