Re: [PATCH v2 dwarves 2/5] btf_encoder: Add true_signature feature support for "."-suffixed functions
Alan Maguire <[email protected]>
| Newsgroups | org.kernel.vger.dwarves,org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On 26/01/2026 11:18, Matt Bobrowski wrote: > On Mon, Jan 26, 2026 at 10:49:00AM +0000, Alan Maguire wrote: >> On 26/01/2026 09:52, Matt Bobrowski wrote: >>> On Fri, Jan 23, 2026 at 05:26:47PM +0000, Alan Maguire wrote: >>>> Currently we collate function information by name and add functions >>>> provided there are no inconsistencies across various representations. >>>> >>>> For true_signature support - where we wish to add the real signature >>>> of a function even if it differs from source level - we need to do >>>> a few things: >>>> >>>> 1. For "."-suffixed functions, we need to match from DWARF->ELF; >>>> we can do this via the address associated with the function. >>>> In doing this, we can then be confident that the debug info >>>> for foo.isra.0 is the right info for the function at that >>>> address. >>>> >>>> 2. When adding saved functions we need to look for such cases >>>> and provided they do not violate other constraints around BTF >>>> representation - unexpected reg usage for function, uncertain >>>> parameter location or ambiguous address - we add them with >>>> their "."-suffixed name. The latter can be used as a signal >>>> that the function is transformed from the original. >>>> >>>> Doing this adds 500 functions to BTF. These are traceable with >>>> their "."-suffix names and because we have excluded ambiguous >>>> address cases we know exactly which function address they refer >>>> to. >>>> >>>> Signed-off-by: Alan Maguire <[email protected]> >>> >>> Some minor nits, but apart from that it looks OK to me. >>> >>> Acked-by: Matt Bobrowski <[email protected]> >>> >>>> --- >>>> btf_encoder.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++----- >>>> dwarves.h | 1 + >>>> pahole.c | 1 + >>>> 3 files changed, 71 insertions(+), 7 deletions(-) >>>> >>>> diff --git a/btf_encoder.c b/btf_encoder.c >>>> index 9a567e4..c1002c3 100644 >>>> --- a/btf_encoder.c >>>> +++ b/btf_encoder.c >>>> @@ -77,9 +77,16 @@ struct btf_encoder_func_annot { >>>> int16_t component_idx; >>>> }; >>>> >>>> +struct elf_function_sym { >>>> + const char *name; >>>> + uint64_t addr; >>>> +}; >>>> + >>>> /* state used to do later encoding of saved functions */ >>>> struct btf_encoder_func_state { >>>> struct elf_function *elf; >>>> + struct elf_function_sym *sym; >>>> + uint64_t addr; >>> ^ >>> This appears to have leaked into wrong commit? >>> This member should've been introduced within patch >>> 5/5. >>> >> >> It's used here too though; specifically in btf_encoder__save_func() >> below. We need to use addresses to map between a DWARF representation >> and the associated ELF function to ensure we're using debug info >> for the correct "."-suffixed function. We need to do this because >> the late DWARF generated after optimizations are applied uses >> the original name ("foo" rather than "foo.isra.0"). > > Sorry, I thought I only saw usage of member "addr" within > btf_encoder__save_func() against fn->lenblock.ip.addr which maps to > member "addr" within struct ip_tag and func->syms[i].addr which maps > to member "addr" within struct elf_function_sym. Member "addr" within > struct btf_encoder_func_state remains unused until patch 5/5 where we > assign it the value returned from function__addr(). > > With that said, within btf_encoder__save_func() why don't you do the > following instead: > > state->addr = function__addr(fn); > > ... > > if (encoder->true_signature && state->addr) { > if (state->addr != func->syms[i].addr) { > ... > } > } > > There's no need to open code fn->lexblock.ip.addr everywhere as it > deminishes readability. > yep, good suggestion, will do this for v3 which should be ready shortly..