Possible bugs in generated DATASEC BTF

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

 



Hi,
For the following example:

kkd@Legion ~/src/linux
 ; cat bpf.c
#define tag __attribute__((btf_decl_tag("tag")))

int a tag;
int b tag;

int main() {
        return a + b;
}

--

When I compile using:
clang -target bpf -O2 -g -c bpf.c

For the BTF dump, I see:
[1] FUNC_PROTO '(anon)' ret_type_id=2 vlen=0
[2] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[3] FUNC 'main' type_id=1 linkage=global
[4] VAR 'a' type_id=2, linkage=global
[5] DECL_TAG 'tag' type_id=4 component_idx=-1
[6] VAR 'b' type_id=2, linkage=global
[7] DECL_TAG 'tag' type_id=6 component_idx=-1
[8] DATASEC '.bss' size=0 vlen=2
        type_id=4 offset=0 size=4 (VAR 'a')
        type_id=6 offset=0 size=4 (VAR 'b')

There are two issues that I hit:

1. The component_idx=-1 makes it a little inconvenient to correlate
the tag applied to a VAR in a DATASEC. In case of structs the index
can be matched with component_idx, in case of DATASEC we have to match
VAR's type_id. So the code has to be different. If it also had
component_idx set it would be possible to make the code same for both
inside the kernel's field parsing routine.

2. The second issue is that the offset is always 0 for DATASEC VARs.
That makes it difficult to ensure proper alignment of the variables.

I would like to know if these are expected behaviors or bugs?
Thanks
--
 ; clang --version
Ubuntu clang version
16.0.0-++20220813052912+eaf0aa1f1fbd-1~exp1~20220813173018.344



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux