[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d0743ed8-d26c-3471-ed5d-66ec9e46db5e@huawei.com>
Date: Tue, 11 Jun 2024 17:36:47 +0800
From: Zheng Yejian <zhengyejian1@...wei.com>
To: Peter Zijlstra <peterz@...radead.org>
CC: <rostedt@...dmis.org>, <mcgrof@...nel.org>, <mhiramat@...nel.org>,
<mark.rutland@....com>, <mathieu.desnoyers@...icios.com>,
<jpoimboe@...nel.org>, <linux-modules@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-trace-kernel@...r.kernel.org>,
<bpf@...r.kernel.org>
Subject: Re: [RFC PATCH] ftrace: Skip __fentry__ location of overridden weak
functions
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
Powered by blists - more mailing lists