Hi Ihor,

On Wed Jun 4, 2025 at 7:31 PM CEST, Ihor Solodrai wrote:
> On 6/4/25 2:02 AM, Alexis Lothoré wrote:

[...]

>> Could I be missing something obvious ? Or did I misunderstand the actual
>> attribute encoding feature ?
>
> Hi Alexis.
>
> The changes recently landed in pahole and libbpf re attributes had a 
> very narrow goal: passing through particular attributes for some BPF 
> kfuncs from the kernel source to vmlinux.h
>
> BTF now has a way of encoding any attribute (as opposed to only bpf 
> type/decl tags) by setting type/decl tag kind flag [1]. So it is 
> possible to represent attributes like packed and aligned in BTF.
>
> However, the BTF tags need to be generated by something, in case of 
> vmlinux by pahole. Pahole generates BTF by parsing DWARF. And, as far as 
> I understand, attributes are not (can not be?) represented in DWARF in a 
> generic way, it really depends on specifics of the attribute.
>
> In order to support packed/aligned, pahole needs to know how to figure 
> them out from DWARF input and add the tags to BTF. And this does not 
> happen right now, which is why you don't see anything in bpftool output.
>
> [1] 
> https://lore.kernel.org/bpf/20250130201239.1429648-1-ihor.solod...@linux.dev/

Thanks for the details ! I have missed this possibility, as I have been
assuming that DWARF info was exposing the needed info. I'll take a look at
it, but if those attributes can not be represented by DWARF, I'll have to
find another way of getting those packing/alignment modifications on data
type (eg: re-use/share btf__align_of from libbpf, as suggested by Andrii,
but it may not able to cover all cases).

Thanks,

Alexis

-- 
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


Reply via email to