Use __noinline macro from bpf_helpers

reviewable/pr638/r24
Tamir Duberstein 2 years ago
parent 1979da92a7
commit f56effedd3
No known key found for this signature in database

@ -4,7 +4,7 @@
#include <bpf/bpf_core_read.h> #include <bpf/bpf_core_read.h>
// clang-format on // clang-format on
char _license[] __attribute__((section("license"), used)) = "GPL"; char _license[] SEC("license") = "GPL";
struct { struct {
__uint(type, BPF_MAP_TYPE_ARRAY); __uint(type, BPF_MAP_TYPE_ARRAY);
@ -24,7 +24,7 @@ struct relocated_struct_with_scalars {
__u8 c; __u8 c;
}; };
__attribute__((noinline)) int field_global() { __noinline int field_global() {
struct relocated_struct_with_scalars s = {1, 2, 3}; struct relocated_struct_with_scalars s = {1, 2, 3};
return set_output(__builtin_preserve_access_index(s.b)); return set_output(__builtin_preserve_access_index(s.b));
} }
@ -36,7 +36,7 @@ struct relocated_struct_with_pointer {
struct relocated_struct_with_pointer *second; struct relocated_struct_with_pointer *second;
}; };
__attribute__((noinline)) int pointer_global() { __noinline int pointer_global() {
struct relocated_struct_with_pointer s = { struct relocated_struct_with_pointer s = {
(struct relocated_struct_with_pointer *)42, (struct relocated_struct_with_pointer *)42,
(struct relocated_struct_with_pointer *)21, (struct relocated_struct_with_pointer *)21,
@ -46,7 +46,7 @@ __attribute__((noinline)) int pointer_global() {
SEC("uprobe") int pointer(void *ctx) { return pointer_global(); } SEC("uprobe") int pointer(void *ctx) { return pointer_global(); }
__attribute__((noinline)) int struct_flavors_global() { __noinline int struct_flavors_global() {
struct relocated_struct_with_scalars s = {1, 2, 3}; struct relocated_struct_with_scalars s = {1, 2, 3};
if (bpf_core_field_exists(s.a)) { if (bpf_core_field_exists(s.a)) {
return set_output(__builtin_preserve_access_index(s.a)); return set_output(__builtin_preserve_access_index(s.a));
@ -59,7 +59,7 @@ SEC("uprobe") int struct_flavors(void *ctx) { return struct_flavors_global(); }
enum relocated_enum_unsigned_32 { U32 = 0xAAAAAAAA }; enum relocated_enum_unsigned_32 { U32 = 0xAAAAAAAA };
__attribute__((noinline)) int enum_unsigned_32_global() { __noinline int enum_unsigned_32_global() {
return set_output(bpf_core_enum_value(enum relocated_enum_unsigned_32, U32)); return set_output(bpf_core_enum_value(enum relocated_enum_unsigned_32, U32));
} }
@ -69,7 +69,7 @@ SEC("uprobe") int enum_unsigned_32(void *ctx) {
enum relocated_enum_signed_32 { S32 = -0x7AAAAAAA }; enum relocated_enum_signed_32 { S32 = -0x7AAAAAAA };
__attribute__((noinline)) int enum_signed_32_global() { __noinline int enum_signed_32_global() {
return set_output(bpf_core_enum_value(enum relocated_enum_signed_32, S32)); return set_output(bpf_core_enum_value(enum relocated_enum_signed_32, S32));
} }
@ -77,7 +77,7 @@ SEC("uprobe") int enum_signed_32(void *ctx) { return enum_signed_32_global(); }
enum relocated_enum_unsigned_64 { U64 = 0xAAAAAAAABBBBBBBB }; enum relocated_enum_unsigned_64 { U64 = 0xAAAAAAAABBBBBBBB };
__attribute__((noinline)) int enum_unsigned_64_global() { __noinline int enum_unsigned_64_global() {
return set_output(bpf_core_enum_value(enum relocated_enum_unsigned_64, U64)); return set_output(bpf_core_enum_value(enum relocated_enum_unsigned_64, U64));
} }
@ -87,7 +87,7 @@ SEC("uprobe") int enum_unsigned_64(void *ctx) {
enum relocated_enum_signed_64 { u64 = -0xAAAAAAABBBBBBBB }; enum relocated_enum_signed_64 { u64 = -0xAAAAAAABBBBBBBB };
__attribute__((noinline)) int enum_signed_64_global() { __noinline int enum_signed_64_global() {
return set_output(bpf_core_enum_value(enum relocated_enum_signed_64, u64)); return set_output(bpf_core_enum_value(enum relocated_enum_signed_64, u64));
} }

Loading…
Cancel
Save