dwarf_loader: Store the DW_AT_alignment if available
DWARF got a DW_AT_alignment as described in: http://dwarfstd.org/ShowIssue.php?issue=140528.1 This appeared first in DWARF5: http://dwarfstd.org/doc/DWARF5.pdf In: ---------------------------------------------------------------------- Chapter 2. General Description 2.24 Alignment A debugging information entry may have a DW_AT_alignment attribute whose value of class constant is a positive, non-zero, integer describing the alignment of the entity. For example, an alignment attribute whose value is 8 indicates that the entity to which it applies occurs at an address that is a multiple of eight (not a multiple of 8 or 256) ---------------------------------------------------------------------- Use it on a struct present in the running kernel, i.e. not specifying which ELF file to look for the DWARF info to use: $ pahole -C inet_timewait_death_row struct inet_timewait_death_row { atomic_t tw_count; /* 0 4 */ /* XXX 60 bytes hole, try to pack */ /* --- cacheline 1 boundary (64 bytes) --- */ struct inet_hashinfo * hashinfo __attribute__((__aligned__(64)); /* 64 8 */ int sysctl_max_tw_buckets; /* 72 4 */ /* size: 128, cachelines: 2, members: 3 */ /* sum members: 16, holes: 1, sum holes: 60 */ /* padding: 52 */ }; $ Now to do some tweaking to get that "__attribute..." part nicely, hum, aligned in the pahole output :-) BTW: the original struct is in the kernel sources: include/net/netns/ipv4.h struct inet_timewait_death_row { atomic_t tw_count; struct inet_hashinfo *hashinfo ____cacheline_aligned_in_smp; int sysctl_max_tw_buckets; }; Reported-by: Mark Wielaard <mark@klomp.org> Cc: Alexei Starovoitov <ast@fb.com> Cc: Andrii Nakryiko <andriin@fb.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Yonghong Song <yhs@fb.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
c002873c44
commit
f31ea292e3
|
@ -747,6 +747,7 @@ static struct class_member *class_member__new(Dwarf_Die *die, struct cu *cu,
|
|||
member->name = strings__add(strings, attr_string(die, DW_AT_name));
|
||||
member->is_static = !in_union && !dwarf_hasattr(die, DW_AT_data_member_location);
|
||||
member->const_value = attr_numeric(die, DW_AT_const_value);
|
||||
member->alignment = attr_numeric(die, DW_AT_alignment);
|
||||
member->byte_offset = attr_offset(die, DW_AT_data_member_location);
|
||||
/*
|
||||
* Bit offset calculated here is valid only for byte-aligned
|
||||
|
|
|
@ -774,6 +774,9 @@ static size_t class_member__fprintf(struct class_member *member, bool union_memb
|
|||
printed += fprintf(fp, ":%u", member->bitfield_size);
|
||||
}
|
||||
|
||||
if (member->alignment != 0)
|
||||
printed += fprintf(fp, " __attribute__((__aligned__(%u))", member->alignment);
|
||||
|
||||
fputc(';', fp);
|
||||
++printed;
|
||||
|
||||
|
|
Loading…
Reference in New Issue