[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1651252324.js9790ngjg.naveen@linux.ibm.com>
Date: Fri, 29 Apr 2022 23:09:19 +0530
From: "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
llvm@...ts.linux.dev, Michael Ellerman <mpe@...erman.id.au>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>
Subject: Re: [PATCH v2 2/2] ftrace: recordmcount: Handle sections with no
non-weak symbols
Steven Rostedt wrote:
> On Thu, 28 Apr 2022 22:49:52 +0530
> "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com> wrote:
>
>> But, with ppc64 elf abi v1 which only supports the old -pg flag, mcount
>> location can differ between the weak and non-weak variants of a
>> function. In such scenarios, one of the two mcount entries will be
>> invalid. Such architectures need to validate mcount locations by
>> ensuring that the instruction(s) at those locations are as expected. On
>> powerpc, this can be a simple check to ensure that the instruction is a
>> 'bl'. This check can be further tightened as necessary.
>
> I was thinking about this more, and I was thinking that we could create
> another section; Perhaps __mcount_loc_weak. And place these in that
> section. That way, we could check if these symbols to see if there's
> already a symbol for it, and if there is, then drop it.
If I'm understanding your suggestion right:
- we now create a new section in each object file: __mcount_loc_weak,
and capture such relocations using weak symbols there.
- we then ask the linker to put these separately between, say,
__start_mcount_loc_weak and __stop_mcount_loc_weak
- on ftrace init, we go through entries in this range, but discard those
that belong to functions that also have an entry between
__start_mcount_loc and __stop_mcount loc.
The primary issue I see here is that the mcount locations within the new
weak section will end up being offsets from a different function in
vmlinux, since the linker does not create a symbol for the weak
functions that were over-ridden.
As an example, in the issue described in this patch set, if powerpc
starts over-riding kexec_arch_apply_relocations(), then the current weak
implementation in kexec_file.o gets carried over to the final vmlinux,
but the instructions will instead appear under the previous function in
kexec_file.o: crash_prepare_elf64_headers(). This function may or may
not be traced to begin with, so we won't be able to figure out if this
is valid or not.
- Naveen
Powered by blists - more mailing lists