Encoding BTF information from DWARF causes "has void type" error.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

with linux kernel v6.8-rc2-RT and the following file as testcase

----->8--------

#include <linux/spinlock.h>
#include <linux/local_lock.h>

struct per_cpu_struct {
        local_lock_t lock;
        unsigned int something;
};

static DEFINE_PER_CPU(struct per_cpu_struct, per_cpu_struct) = {
        .lock = INIT_LOCAL_LOCK(lock),
};

DEFINE_GUARD(ll_lock, local_lock_t __percpu*,
             local_lock(_T),
             local_unlock(_T))

void function(void);
void function(void)
{
        struct per_cpu_struct *pcs = this_cpu_ptr(&per_cpu_struct);

        guard(ll_lock)(&per_cpu_struct.lock);
        pcs->something++;
}

-----8<--------

compiling and running pahole afterwards:
| make kernel/pahole-tc.o && pahole -J --btf_gen_floats -j --lang_exclude=rust  kernel/pahole-tc.o
|   CC      kernel/pahole-tc.o
| error: found variable 'per_cpu_struct' in CU 'kernel/pahole-tc.c' that has void type

This doesn't look good. If I swap the order of "lock" and "something"
within per_cpu_struct then it goes away.
The dwarf/die object it complains about has only DW_AT_abstract_origin
and DW_AT_location set.
At this point I am not sure if gcc wrongly created the dwarf information
or of pahole accidentally matches the internal local_lock_t member as
per_cpu_struct because it starts the same address.

>From dumpwarf the problematic entry is:
| 0x0000085b:       DW_TAG_variable
|                     DW_AT_abstract_origin       (0x0000099e "t")
|                     DW_AT_location      (DW_OP_addr 0x0, DW_OP_stack_value)

which looks slightly different in the good case:
| 0x00000852:         DW_TAG_variable
|                       DW_AT_abstract_origin     (0x00000980 "t")
|                       DW_AT_location    (0x00000040: 
|                          [0x0000000000000046, 0x000000000000005b): DW_OP_reg3 RBX
|                          [0x000000000000005b, 0x0000000000000061): DW_OP_addr 0x0, DW_OP_stack_value)
|                       DW_AT_GNU_locviews        (0x0000003c)

I made an archive with c file, the compiled version in bad and good case
(swapped the first two members), the dumpwarf output and uploaded to
	https://breakpoint.cc/pahole-tc.tar.xz

Sebastian




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux