BPF List
 help / color / mirror / Atom feed
* Enum relocations against zero values
@ 2021-02-26 17:47 Lorenz Bauer
  2021-02-26 18:08 ` Yonghong Song
  0 siblings, 1 reply; 7+ messages in thread
From: Lorenz Bauer @ 2021-02-26 17:47 UTC (permalink / raw)
  To: bpf, Andrii Nakryiko, Yonghong Song

Hi Andrii and Yonghong,

I'm playing around with enum CO-RE relocations, and hit the following snag:

    enum e { TWO };
    bpf_core_enum_value_exists(enum e, TWO);

Compiling this with clang-12
(12.0.0-++20210225092616+e0e6b1e39e7e-1~exp1~20210225083321.50) gives
me the following:

internal/btf/testdata/relocs.c:66:2: error:
__builtin_preserve_enum_value argument 1 invalid
        enum_value_exists(enum e, TWO);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
internal/btf/testdata/relocs.c:53:8: note: expanded from macro
'enum_value_exists'
                if (!bpf_core_enum_value_exists(t, v)) { \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
internal/btf/testdata/bpf_core_read.h:168:32: note: expanded from
macro 'bpf_core_enum_value_exists'
        __builtin_preserve_enum_value(*(typeof(enum_type)
*)enum_value, BPF_ENUMVAL_EXISTS)
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Changing the definition of the enum to

    enum e { TWO = 1 }

compiles successfully. I get the same result for any enum value that
is zero. Is this expected?

Best
Lorenz

-- 
Lorenz Bauer  |  Systems Engineer
6th Floor, County Hall/The Riverside Building, SE1 7PB, UK

www.cloudflare.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-02 10:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-26 17:47 Enum relocations against zero values Lorenz Bauer
2021-02-26 18:08 ` Yonghong Song
2021-02-26 20:43   ` Andrii Nakryiko
2021-02-27  3:31     ` Yonghong Song
2021-03-02  4:19       ` Yonghong Song
2021-03-02  5:08         ` Andrii Nakryiko
2021-03-02  9:51         ` Lorenz Bauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox