Symbols with double underscore prefix are not emitted to BTF .ksyms DATASEC

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

 



Hi,

I discovered that for the following program:

 ; cat bpf.c
extern void *__bpf_kptr_new(int, int, void *)
__attribute__((section(".ksyms")));
#define bpf_kptr_new(x) __bpf_kptr_new(x, 0, 0)

struct foo {
        int data;
};

int main(void)
{
        struct foo *f;

        f = bpf_kptr_new(0);
        return f->data;
}
--
Compiling and dumping BTF shows that the __bpf_kptr_new extern is not
added to .ksyms DATASEC.

[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

However, removing the leading double underscores fixes this:
 ; cat bpf.c
extern void *bpf_kptr_new_(int, int, void *) __attribute__((section(".ksyms")));
#define bpf_kptr_new(x) bpf_kptr_new_(x, 0, 0)

struct foo {
        int data;
};

int main(void)
{
        struct foo *f;

        f = bpf_kptr_new(0);
        return f->data;
}
--

and dumping now shows:

[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] FUNC_PROTO '(anon)' ret_type_id=5 vlen=3
        '(anon)' type_id=2
        '(anon)' type_id=2
        '(anon)' type_id=5
[5] PTR '(anon)' type_id=0
[6] FUNC 'bpf_kptr_new_' type_id=4 linkage=extern
[7] DATASEC '.ksyms' size=0 vlen=1
        type_id=6 offset=0 size=0 (FUNC 'bpf_kptr_new_')

This is on the latest clang nightly.

Thanks.



[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