[llvm] [RFC] Emit dwarf data for signature-changed or new functions (PR #157349)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 09:36:12 PDT 2025


yonghong-song wrote:

Okay, I think I found the pahole issue which prevents linux kernel build.
The pahole fix likes below:
```
diff --git a/btf_encoder.c b/btf_encoder.c
index 0bc2334..18f0162 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -2652,6 +2652,8 @@ int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu, struct co
                 */
                if (fn->declaration)
                        continue;
+               if (function__inlined(fn))
+                       continue;
                if (!ftype__has_arg_names(&fn->proto))
                        continue;
                if (funcs->cnt) {
```
Basically if the 'fn' is inlined, we should not add this 'fn' into the  elf function list.

For this particular func, my unpublished RFC code generates the following dwarf (from vmlinux.o):

```
0x01c2660a:   DW_TAG_subprogram
                DW_AT_name      ("bpf_lsm_socket_getpeersec_stream")
                DW_AT_decl_file ("/home/yhs/work/bpf-next/include/linux/lsm_hook_defs.h")
                DW_AT_decl_line (344)
                DW_AT_prototyped        (true)    
                DW_AT_type      (0x01c0a7db "int")
                DW_AT_external  (true)
                DW_AT_inline    (DW_INL_inlined)

0x01c26614:     DW_TAG_formal_parameter
                  DW_AT_name    ("sock")  
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/include/linux/lsm_hook_defs.h")
                  DW_AT_decl_line       (344)     
                  DW_AT_type    (0x01c1b4e0 "socket *")

0x01c2661e:     DW_TAG_formal_parameter
                  DW_AT_name    ("optval")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/include/linux/lsm_hook_defs.h")
                  DW_AT_decl_line       (344)     
                  DW_AT_type    (0x01c1429d "sockptr_t")

0x01c26628:     DW_TAG_formal_parameter
                  DW_AT_name    ("optlen")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/include/linux/lsm_hook_defs.h")
                  DW_AT_decl_line       (344)     
                  DW_AT_type    (0x01c1429d "sockptr_t")

0x01c26632:     DW_TAG_formal_parameter
                  DW_AT_name    ("len")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/include/linux/lsm_hook_defs.h")
                  DW_AT_decl_line       (344)
                  DW_AT_type    (0x01c0aa01 "unsigned int")

0x01c2663b:     NULL

0x01c2663c:   DW_TAG_subprogram
                DW_AT_low_pc    (0x000000000077bfb0)
                DW_AT_high_pc   (0x000000000077bfc4)
                DW_AT_frame_base        (DW_OP_reg7 RSP)
                DW_AT_linkage_name      ("bpf_lsm_socket_getpeersec_stream")
                DW_AT_name      ("bpf_lsm_socket_getpeersec_stream")
                DW_AT_decl_file ("/home/yhs/work/bpf-next/kernel/bpf/bpf_lsm.c")
                DW_AT_decl_line (344)
                DW_AT_type      (0x01c0a7db "int")
                DW_AT_external  (true)

0x01c26650:     DW_TAG_formal_parameter
                  DW_AT_location        (DW_OP_reg5 RDI)
                  DW_AT_name    ("sock")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/kernel/bpf/bpf_lsm.c")
                  DW_AT_decl_line       (344)
                  DW_AT_type    (0x01c1b4e0 "socket *")

0x01c2665c:     DW_TAG_formal_parameter
                  DW_AT_location        (DW_OP_reg4 RSI)
                  DW_AT_name    ("optval.coerce0")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/kernel/bpf/bpf_lsm.c")
                  DW_AT_decl_line       (344)
                  DW_AT_type    (0x01c2790e "structure  *")

0x01c26668:     DW_TAG_formal_parameter
                  DW_AT_location        (DW_OP_reg1 RDX)
                  DW_AT_name    ("optval.coerce1")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/kernel/bpf/bpf_lsm.c")
                  DW_AT_decl_line       (344)
                  DW_AT_type    (0x01c27913 "int8")

0x01c26674:     DW_TAG_formal_parameter
                  DW_AT_location        (DW_OP_reg2 RCX)
                  DW_AT_name    ("optlen.coerce0")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/kernel/bpf/bpf_lsm.c")
                  DW_AT_decl_line       (344)
                  DW_AT_type    (0x01c2790e "structure  *")

0x01c26680:     DW_TAG_formal_parameter
                  DW_AT_location        (DW_OP_reg8 R8)
                  DW_AT_name    ("optlen.coerce1")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/kernel/bpf/bpf_lsm.c")
                  DW_AT_decl_line       (344)
                  DW_AT_type    (0x01c27913 "int8")

0x01c2668c:     DW_TAG_formal_parameter
                  DW_AT_location        (DW_OP_reg9 R9)
                  DW_AT_name    ("len")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/kernel/bpf/bpf_lsm.c")
                  DW_AT_decl_line       (344)
                  DW_AT_type    (0x01c0aa01 "unsigned int")

0x01c26697:     DW_TAG_inlined_subroutine
                  DW_AT_abstract_origin (0x01c2660a "bpf_lsm_socket_getpeersec_stream")
                  DW_AT_low_pc  (0x000000000077bfb9)
                  DW_AT_high_pc (0x000000000077bfc4)
                  DW_AT_call_file       ("/home/yhs/work/bpf-next/kernel/bpf/bpf_lsm.c")
                  DW_AT_call_line       (0)

0x01c266a4:       DW_TAG_formal_parameter
                    DW_AT_location      (DW_OP_reg5 RDI)
                    DW_AT_abstract_origin       (0x01c26614 "sock")

0x01c266ab:       DW_TAG_formal_parameter
                    DW_AT_location      (indexed (0x0) loclist = 0x003f0aad:
                       [0x000000000077bfb9, 0x000000000077bfc4): DW_OP_reg4 RSI, DW_OP_piece 0x8, DW_OP_reg1 RDX, DW_OP_piece 0x1)
                    DW_AT_abstract_origin       (0x01c2661e "optval")

0x01c266b1:       DW_TAG_formal_parameter
                    DW_AT_location      (indexed (0x1) loclist = 0x003f0aba:
                       [0x000000000077bfb9, 0x000000000077bfc4): DW_OP_reg2 RCX, DW_OP_piece 0x8, DW_OP_reg8 R8, DW_OP_piece 0x1)
                    DW_AT_abstract_origin       (0x01c26628 "optlen")

0x01c266b7:       DW_TAG_formal_parameter
                    DW_AT_location      (DW_OP_reg9 R9)
                    DW_AT_abstract_origin       (0x01c26632 "len")

0x01c266be:       NULL

0x01c266bf:     NULL

===========

0x01c1429d:   DW_TAG_typedef
                DW_AT_type      (0x01c142a6 "structure ")
                DW_AT_name      ("sockptr_t")
                DW_AT_decl_file ("/home/yhs/work/bpf-next/include/linux/sockptr.h")
                DW_AT_decl_line (20)

0x01c142a6:   DW_TAG_structure_type
                DW_AT_byte_size (0x10)
                DW_AT_decl_file ("/home/yhs/work/bpf-next/include/linux/sockptr.h")
                DW_AT_decl_line (14)

0x01c142aa:     DW_TAG_member
                  DW_AT_type    (0x01c142b2 "structure ::union ")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/include/linux/sockptr.h")
                  DW_AT_decl_line       (15)
                  DW_AT_data_member_location    (0x00)
              
0x01c142b2:     DW_TAG_union_type       
                  DW_AT_byte_size       (0x08)
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/include/linux/sockptr.h")
                  DW_AT_decl_line       (15)
                
0x01c142b6:       DW_TAG_member
                    DW_AT_name  ("kernel")
                    DW_AT_type  (0x01c0b2da "void *")
                    DW_AT_decl_file     ("/home/yhs/work/bpf-next/include/linux/sockptr.h")
                    DW_AT_decl_line     (16)
                    DW_AT_data_member_location  (0x00)

0x01c142c0:       DW_TAG_member
                    DW_AT_name  ("user")
                    DW_AT_type  (0x01c142d7 "void *")
                    DW_AT_decl_file     ("/home/yhs/work/bpf-next/include/linux/sockptr.h")
                    DW_AT_decl_line     (17)
                    DW_AT_data_member_location  (0x00)

0x01c142ca:       NULL

0x01c142cb:     DW_TAG_member
                  DW_AT_name    ("is_kernel")
                  DW_AT_type    (0x01c0b09a "bool")
                  DW_AT_decl_file       ("/home/yhs/work/bpf-next/include/linux/sockptr.h")
                  DW_AT_decl_line       (19)
                  DW_AT_bit_size        (0x01)
                  DW_AT_data_bit_offset (0x40)

0x01c142d6:     NULL
```
Could you help check whether the above format is expected or not?

Running bpf selftests, I found additional failures. Mostly likely additional pahole change is needed. I am debugging those now.


https://github.com/llvm/llvm-project/pull/157349


More information about the llvm-commits mailing list