Merge "rename SEC() to SECTION()" am: bc8df444d1
am: bab48348a4
am: 453f93e9db
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1895607 Change-Id: Ic84ea528924826a79c7e885eb73041b415c658bc
This commit is contained in:
commit
458b630552
4 changed files with 21 additions and 18 deletions
|
@ -81,10 +81,13 @@ typedef struct {
|
|||
|
||||
/*
|
||||
* Map section name prefixes to program types, the section name will be:
|
||||
* SEC(<prefix>/<name-of-program>)
|
||||
* SECTION(<prefix>/<name-of-program>)
|
||||
* For example:
|
||||
* SEC("tracepoint/sched_switch_func") where sched_switch_funcs
|
||||
* SECTION("tracepoint/sched_switch_func") where sched_switch_funcs
|
||||
* is the name of the program, and tracepoint is the type.
|
||||
*
|
||||
* However, be aware that you should not be directly using the SECTION() macro.
|
||||
* Instead use the DEFINE_(BPF|XDP)_(PROG|MAP)... & LICENSE/CRITICAL macros.
|
||||
*/
|
||||
sectionType sectionNameTypes[] = {
|
||||
{"kprobe", BPF_PROG_TYPE_KPROBE},
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* *
|
||||
* THIS WILL LIKELY RESULT IN BRICKED DEVICES AT SOME ARBITRARY FUTURE TIME *
|
||||
* *
|
||||
* THAT GOES ESPECIALLY FOR THE 'SEC' 'LICENSE' AND 'CRITICAL' MACRO DEFINES *
|
||||
* THAT GOES ESPECIALLY FOR THE 'SECTION' 'LICENSE' AND 'CRITICAL' MACROS *
|
||||
* *
|
||||
* We strongly suggest that if you need changes to bpfloader functionality *
|
||||
* you get your changes reviewed and accepted into aosp/master. *
|
||||
|
@ -20,7 +20,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
/* place things in different elf sections */
|
||||
#define SEC(NAME) __attribute__((section(NAME), used))
|
||||
#define SECTION(NAME) __attribute__((section(NAME), used))
|
||||
|
||||
/* Must be present in every program, example usage:
|
||||
* LICENSE("GPL"); or LICENSE("Apache 2.0");
|
||||
|
@ -41,18 +41,18 @@
|
|||
* If missing, bpfloader_{min/max}_ver default to 0/0x10000 ie. [v0.0, v1.0),
|
||||
* while size_of_bpf_{map/prog}_def default to 32/20 which are the v0.0 sizes.
|
||||
*/
|
||||
#define LICENSE(NAME) \
|
||||
unsigned int _bpfloader_min_ver SEC("bpfloader_min_ver") = DEFAULT_BPFLOADER_MIN_VER; \
|
||||
unsigned int _bpfloader_max_ver SEC("bpfloader_max_ver") = DEFAULT_BPFLOADER_MAX_VER; \
|
||||
size_t _size_of_bpf_map_def SEC("size_of_bpf_map_def") = sizeof(struct bpf_map_def); \
|
||||
size_t _size_of_bpf_prog_def SEC("size_of_bpf_prog_def") = sizeof(struct bpf_prog_def); \
|
||||
char _license[] SEC("license") = (NAME)
|
||||
#define LICENSE(NAME) \
|
||||
unsigned int _bpfloader_min_ver SECTION("bpfloader_min_ver") = DEFAULT_BPFLOADER_MIN_VER; \
|
||||
unsigned int _bpfloader_max_ver SECTION("bpfloader_max_ver") = DEFAULT_BPFLOADER_MAX_VER; \
|
||||
size_t _size_of_bpf_map_def SECTION("size_of_bpf_map_def") = sizeof(struct bpf_map_def); \
|
||||
size_t _size_of_bpf_prog_def SECTION("size_of_bpf_prog_def") = sizeof(struct bpf_prog_def); \
|
||||
char _license[] SECTION("license") = (NAME)
|
||||
|
||||
/* flag the resulting bpf .o file as critical to system functionality,
|
||||
* loading all kernel version appropriate programs in it must succeed
|
||||
* for bpfloader success
|
||||
*/
|
||||
#define CRITICAL(REASON) char _critical[] SEC("critical") = (REASON)
|
||||
#define CRITICAL(REASON) char _critical[] SECTION("critical") = (REASON)
|
||||
|
||||
/*
|
||||
* Helper functions called from eBPF programs written in C. These are
|
||||
|
@ -103,7 +103,7 @@ static int (*bpf_map_delete_elem_unsafe)(const struct bpf_map_def* map,
|
|||
|
||||
/* type safe macro to declare a map and related accessor functions */
|
||||
#define DEFINE_BPF_MAP_UGM(the_map, TYPE, TypeOfKey, TypeOfValue, num_entries, usr, grp, md) \
|
||||
const struct bpf_map_def SEC("maps") the_map = { \
|
||||
const struct bpf_map_def SECTION("maps") the_map = { \
|
||||
.type = BPF_MAP_TYPE_##TYPE, \
|
||||
.key_size = sizeof(TypeOfKey), \
|
||||
.value_size = sizeof(TypeOfValue), \
|
||||
|
@ -155,7 +155,7 @@ static unsigned long long (*bpf_get_smp_processor_id)(void) = (void*) BPF_FUNC_g
|
|||
|
||||
#define DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, \
|
||||
opt) \
|
||||
const struct bpf_prog_def SEC("progs") the_prog##_def = { \
|
||||
const struct bpf_prog_def SECTION("progs") the_prog##_def = { \
|
||||
.uid = (prog_uid), \
|
||||
.gid = (prog_gid), \
|
||||
.min_kver = (min_kv), \
|
||||
|
@ -164,7 +164,7 @@ static unsigned long long (*bpf_get_smp_processor_id)(void) = (void*) BPF_FUNC_g
|
|||
.bpfloader_min_ver = DEFAULT_BPFLOADER_MIN_VER, \
|
||||
.bpfloader_max_ver = DEFAULT_BPFLOADER_MAX_VER, \
|
||||
}; \
|
||||
SEC(SECTION_NAME) \
|
||||
SECTION(SECTION_NAME) \
|
||||
int the_prog
|
||||
|
||||
// Programs (here used in the sense of functions/sections) marked optional are allowed to fail
|
||||
|
|
|
@ -116,10 +116,10 @@ _Static_assert(__alignof__(unsigned long long) == 8, "__alignof__ unsigned long
|
|||
* uses this structure from eBPF object to create maps at boot time.
|
||||
*
|
||||
* The eBPF C program should define structure in the maps section using
|
||||
* SEC("maps") otherwise it will be ignored by the eBPF loader.
|
||||
* SECTION("maps") otherwise it will be ignored by the eBPF loader.
|
||||
*
|
||||
* For example:
|
||||
* const struct bpf_map_def SEC("maps") mymap { .type=... , .key_size=... }
|
||||
* const struct bpf_map_def SECTION("maps") mymap { .type=... , .key_size=... }
|
||||
*
|
||||
* See 'bpf_helpers.h' for helpful macros for eBPF program use.
|
||||
*/
|
||||
|
|
|
@ -86,7 +86,7 @@ void mock_bpf_set_current_pid_tgid(uint64_t pid_tgid);
|
|||
#endif
|
||||
|
||||
/* place things in different elf sections */
|
||||
#define SEC(NAME) __attribute__((section(NAME), used))
|
||||
#define SECTION(NAME) __attribute__((section(NAME), used))
|
||||
|
||||
/* Example use: LICENSE("GPL"); or LICENSE("Apache 2.0"); */
|
||||
#define LICENSE(NAME) char _license[] SEC("license") = (NAME)
|
||||
#define LICENSE(NAME) char _license[] SECTION("license") = (NAME)
|
||||
|
|
Loading…
Reference in a new issue