On Wed Jun 18, 2025 at 6:28 PM CEST, Alexei Starovoitov wrote: > On Wed, Jun 18, 2025 at 8:02 AM Alexis Lothoré > <alexis.lothore@xxxxxxxxxxx> wrote: >> >> - those attributes are not reliably encoded by compilers in DWARF info > > What would be an example of unreliability? > Maybe they're reliable enough for cases we're concerned about ? The example I had in mind is around the fact that there is no explicit dwarf attribute stating that a struct is packed. It may be deduced in some cases by taking a look at the DW_TAG_byte_size and checking if it matches the expected size of locations of all its members, but there are cases in which the packed attribute does not change the struct size, while still altering its alignment (but more below) > >> + >> + if (param_idx >= cu->nr_register_params) { >> + if(dwarf_attr(die, DW_AT_type, &attr)){ >> + Dwarf_Die type_die; >> + if (dwarf_formref_die(&attr, &type_die) && >> + dwarf_tag(&type_die) == DW_TAG_structure_type) { >> + parm->uncertain_loc = 1; >> + } >> + } >> + return parm; > > This is too pessimistic. > In > bpf_testmod_test_struct_arg_9(u64 a, void *b, short c, int d, void *e, char f, > short g, struct bpf_testmod_struct_arg_5 > h, long i) > > struct bpf_testmod_struct_arg_5 { > char a; > short b; > int c; > long d; > }; > > though it's passed on the stack it fits into normal calling convention. > It doesn't have align or packed attributes, so no need to exclude it ? I went for the simplest solution, assuming that there were cases involving packing/alignent customization that we would not be able to detect (eg: the packed attr that does not change size but reduce alignment). But thinking more about it, those cases need really specific conditions thay may not exist currently in the kernel (eg: having some __int128 embedded in a struct). I see that pahole already has some logic to check if a struct is altered (eg class__infer_packed_attributes), I'll check if I can come with something more selective. Alexis -- Alexis Lothoré, Bootlin Embedded Linux and Kernel engineering https://bootlin.com