Re: pahole treats embedded structures a holes

Arnaldo Carvalho de Melo <[email protected]> Fri, 29 May 2026 16:28:57 -0300
Newsgroups org.kernel.vger.dwarves
Message-ID <ahno-Wd92sAnRkK9@x1>
On Fri, May 29, 2026 at 06:02:10AM +0200, Christoph Hellwig wrote:
> On Thu, May 28, 2026 at 04:48:44PM -0300, Arnaldo Carvalho de Melo wrote:
> > acme@number:~$ readelf -wi git/build/allmodconfig/fs/xfs/xfs_buf.o  | grep -m1 DW_AT_producer
 
> hch@brick:~/work/xfs$ readelf -wi fs/xfs/xfs_buf.o  | grep -m1 DW_AT_producer
>     <d>   DW_AT_producer    : (indirect string, offset: 0x6012): GNU C11 15.2.0 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -m64 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -g -gdwarf-5 -O2 -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -fms-extensions -fcf-protection=branch -falign-jumps=1 -falign-loops=1 -fno-asynchronous-unwind-tables -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -fzero-init-padding-bits=all -fno-stack-clash-protection -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fstack-check=no -fconserve-stack -fno-builtin-wcslen -fno-var-tracking -femit-struct-debug-baseonly

> > then, please take a look at this sequence:

> > acme@number:~$ readelf -wi git/build/allmodconfig/fs/xfs/xfs_buf.o  | grep -w xfs_buf$ -B1 -A12
 
> hch@brick:~/work/xfs$ readelf -wi fs/xfs/xfs_buf.o  | grep -w xfs_buf$ -B1 -A12
>  <1><f1c>: Abbrev Number: 93 (DW_TAG_structure_type)
>     <f1d>   DW_AT_name        : (indirect string, offset: 0x3358): xfs_buf
>     <f21>   DW_AT_byte_size   : 344
>     <f23>   DW_AT_alignment   : 8
>     <f23>   DW_AT_decl_file   : 46
>     <f23>   DW_AT_decl_line   : 138
>     <f24>   DW_AT_decl_column : 8
>     <f24>   DW_AT_sibling     : <0x10a2>
>  <2><f28>: Abbrev Number: 39 (DW_TAG_member)
>     <f29>   DW_AT_name        : (indirect string, offset: 0x5e80): b_rhash_head
>     <f2d>   DW_AT_decl_file   : 46
>     <f2d>   DW_AT_decl_line   : 146
>     <f2e>   DW_AT_decl_column : 20
>     <f2f>   DW_AT_type        : <0x9c8>
 
> > acme@number:~$ readelf -wi git/build/allmodconfig/fs/xfs/xfs_buf.o  | grep '<5b22>' -A12
 
> hch@brick:~/work/xfs$ readelf -wi fs/xfs/xfs_buf.o  | grep '<0x9c8>' -A12

This part is the tricky one, see that the 0x isn't there inside the
<TYPE> in my grep, I guess whoever wrote readelf used this to get the
offset, not the many entries pointing to it :-)

You need to do this:

hch@brick:~/work/xfs$ readelf -wi fs/xfs/xfs_buf.o  | grep '<9c8>' -A12

Without the 0x, so that I can see what is the type for that member.

Or better, please send me your fs/xfs/xfs_buf.o, that will be easier,
I'll try it myself, and if I reproduce your results, I'll be able to fix
it and test on the same fs/xfs/xfs_buf.o file.

- Arnaldo

>     <9ce>   DW_AT_type        : <0x9c8>
>  <1><9d2>: Abbrev Number: 29 (DW_TAG_structure_type)
>     <9d3>   DW_AT_name        : (indirect string, offset: 0x303): rhlist_head
>     <9d7>   DW_AT_declaration : 1
>  <1><9d7>: Abbrev Number: 29 (DW_TAG_structure_type)
>     <9d8>   DW_AT_name        : (indirect string, offset: 0x27b4): rhashtable_compare_arg
>     <9dc>   DW_AT_declaration : 1
>  <1><9dc>: Abbrev Number: 17 (DW_TAG_pointer_type)
>     <9dd>   DW_AT_byte_size   : 8
>     <9dd>   DW_AT_type        : <0x9d7>
>  <1><9e1>: Abbrev Number: 29 (DW_TAG_structure_type)
>     <9e2>   DW_AT_name        : (indirect string, offset: 0x2ce3): rhashtable_params
>     <9e6>   DW_AT_declaration : 1
> --
>     <f2f>   DW_AT_type        : <0x9c8>
>     <f33>   DW_AT_data_member_location: 0
>  <2><f34>: Abbrev Number: 39 (DW_TAG_member)
>     <f35>   DW_AT_name        : (indirect string, offset: 0x25e): b_rhash_key
>     <f39>   DW_AT_decl_file   : 46
>     <f39>   DW_AT_decl_line   : 148
>     <f3a>   DW_AT_decl_column : 15
>     <f3b>   DW_AT_type        : <0xcb1>
>     <f3f>   DW_AT_data_member_location: 8
>  <2><f40>: Abbrev Number: 39 (DW_TAG_member)
>     <f41>   DW_AT_name        : (indirect string, offset: 0x3fbd): b_length
>     <f45>   DW_AT_decl_file   : 46
>     <f45>   DW_AT_decl_line   : 149
> --
>     <1fa9>   DW_AT_type        : <0x9c8>
>  <1><1fad>: Abbrev Number: 33 (DW_TAG_subprogram)
>     <1fae>   DW_AT_external    : 1
>     <1fae>   DW_AT_name        : (indirect string, offset: 0x5b66): __SCT__tp_func_xfs_buf_backing_vmalloc
>     <1fb2>   DW_AT_decl_file   : 3
>     <1fb3>   DW_AT_decl_line   : 793
>     <1fb5>   DW_AT_decl_column : 1
>     <1fb6>   DW_AT_prototyped  : 1
>     <1fb6>   DW_AT_type        : <0x6e>
>     <1fba>   DW_AT_declaration : 1
>     <1fba>   DW_AT_sibling     : <0x1fce>
>  <2><1fbe>: Abbrev Number: 6 (DW_TAG_formal_parameter)
>     <1fbf>   DW_AT_type        : <0x27f>
> 
> 
> > iacme@number:~$ readelf -wi git/build/allmodconfig/fs/xfs/xfs_buf.o  | grep '<5b42>' -A4
> >  <1><5b42>: Abbrev Number: 8 (DW_TAG_pointer_type)
> >     <5b43>   DW_AT_byte_size   : 8
> >     <5b43>   DW_AT_type        : <0x5b22>
> >  <1><5b47>: Abbrev Number: 30 (DW_TAG_structure_type)
> >     <5b48>   DW_AT_name        : (indirect string, offset: 0x14c84): rhlist_head
> 
> hch@brick:~/work/xfs$ readelf -wi fs/xfs/xfs_buf.o  | grep '<0x9c8>' -A4
>     <9ce>   DW_AT_type        : <0x9c8>
>  <1><9d2>: Abbrev Number: 29 (DW_TAG_structure_type)
>     <9d3>   DW_AT_name        : (indirect string, offset: 0x303): rhlist_head
>     <9d7>   DW_AT_declaration : 1
>  <1><9d7>: Abbrev Number: 29 (DW_TAG_structure_type)
> --
>     <f2f>   DW_AT_type        : <0x9c8>
>     <f33>   DW_AT_data_member_location: 0
>  <2><f34>: Abbrev Number: 39 (DW_TAG_member)
>     <f35>   DW_AT_name        : (indirect string, offset: 0x25e): b_rhash_key
>     <f39>   DW_AT_decl_file   : 46
> --
>     <1fa9>   DW_AT_type        : <0x9c8>
>  <1><1fad>: Abbrev Number: 33 (DW_TAG_subprogram)
>     <1fae>   DW_AT_external    : 1
>     <1fae>   DW_AT_name        : (indirect string, offset: 0x5b66): __SCT__tp_func_xfs_buf_backing_vmalloc
>     <1fb2>   DW_AT_decl_file   : 3