linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Zheng Yejian <zhengyejian1@huawei.com>
Cc: rostedt@goodmis.org, mcgrof@kernel.org, mhiramat@kernel.org,
	mark.rutland@arm.com, mathieu.desnoyers@efficios.com,
	jpoimboe@kernel.org, linux-modules@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [RFC PATCH] ftrace: Skip __fentry__ location of overridden weak functions
Date: Tue, 11 Jun 2024 11:21:57 +0200	[thread overview]
Message-ID: <20240611092157.GU40213@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <57e499a4-e26d-148f-317d-233e873d11b4@huawei.com>

On Tue, Jun 11, 2024 at 09:56:51AM +0800, Zheng Yejian wrote:
> On 2024/6/7 23:02, Peter Zijlstra wrote:

> > Oh gawd, sodding weak functions again.
> > 
> > I would suggest changing scipts/kallsyms.c to emit readily identifiable
> > symbol names for all the weak junk, eg:
> > 
> >    __weak_junk_NNNNN
> > 
> 
> Sorry for the late reply, I just had a long noon holiday :>
> 
> scripts/kallsyms.c is compiled and used to handle symbols in vmlinux.o
> or vmlinux.a, see kallsyms_step() in scripts/link-vmlinux.sh, those
> overridden weak symbols has been removed from symbol table of vmlinux.o
> or vmlinux.a. But we can found those symbols from original xx/xx.o file,
> for example, the weak free_initmem() in in init/main.c is overridden,
> its symbol is not in vmlinx but is still in init/main.o .
> 
> How about traversing all origin xx/xx.o and finding all weak junk symbols ?

You don't need to. ELF symbl tables have an entry size for FUNC type
objects, this means that you can readily find holes in the text and fill
them with a symbol.

Specifically, you can check the mcount locations against the symbol
table and for every one that falls in a hole, generate a new junk
symbol.

Also see 4adb23686795 where objtool adds these holes to the
ignore/unreachable code check.


The lack of size for kallsyms is in a large part what is causing the
problems.

  reply	other threads:[~2024-06-11  9:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 11:52 [RFC PATCH] ftrace: Skip __fentry__ location of overridden weak functions Zheng Yejian
2024-06-07 15:02 ` Peter Zijlstra
2024-06-07 15:39   ` Steven Rostedt
2024-06-11  1:56   ` Zheng Yejian
2024-06-11  9:21     ` Peter Zijlstra [this message]
2024-06-11  9:36       ` Zheng Yejian
2024-11-13  7:32 ` Dropify

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240611092157.GU40213@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bpf@vger.kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mcgrof@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=zhengyejian1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).