mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zheng Yejian <zhengyejian1@huawei.com>
To: Peter Zijlstra <peterz@infradead.org>
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 17:36:47 +0800	[thread overview]
Message-ID: <d0743ed8-d26c-3471-ed5d-66ec9e46db5e@huawei.com> (raw)
In-Reply-To: <20240611092157.GU40213@noisy.programming.kicks-ass.net>

On 2024/6/11 17:21, Peter Zijlstra wrote:
> 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.

Thanks for your suggestions, I'll try it soon.

--

Thanks,
ZYJ

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

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 11:52 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
2024-06-11  9:36       ` Zheng Yejian [this message]
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=d0743ed8-d26c-3471-ed5d-66ec9e46db5e@huawei.com \
    --to=zhengyejian1@huawei.com \
    --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=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /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

all inboxes | Powered by JetHome®