Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testdata: drop the use of __clang_major__ directive #1151

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified testdata/btf_map_init-eb.elf
Binary file not shown.
Binary file modified testdata/btf_map_init-el.elf
Binary file not shown.
6 changes: 0 additions & 6 deletions testdata/btf_map_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "common.h"

#if __clang_major__ >= 9

int __section("socket/tail") tail_1() {
return 42;
}
Expand Down Expand Up @@ -54,7 +52,3 @@ struct {
[1] = &inner_map,
},
};

#else
#error This file has to be compiled with clang >= 9
#endif
4 changes: 0 additions & 4 deletions testdata/invalid_btf_map_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "common.h"

#if __clang_major__ >= 9
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, uint32_t);
Expand All @@ -12,6 +11,3 @@ struct {
/* This forces a non-zero byte into the .maps section. */
.key = (void *)1,
};
#else
#error This file has to be compiled with clang >= 9
#endif
Binary file modified testdata/loader-clang-11-eb.elf
Binary file not shown.
Binary file modified testdata/loader-clang-11-el.elf
Binary file not shown.
Binary file modified testdata/loader-clang-14-eb.elf
Binary file not shown.
Binary file modified testdata/loader-clang-14-el.elf
Binary file not shown.
Binary file modified testdata/loader-clang-17-eb.elf
Binary file not shown.
Binary file modified testdata/loader-clang-17-el.elf
Binary file not shown.
38 changes: 0 additions & 38 deletions testdata/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

char __license[] __section("license") = "MIT";

#if __clang_major__ >= 9
// Clang < 9 doesn't emit the necessary BTF for this to work.
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, uint32_t);
Expand Down Expand Up @@ -64,27 +62,6 @@ struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
__uint(max_entries, 4096);
} perf_event_array __section(".maps");
#else
struct bpf_map_def hash_map __section("maps") = {
.type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint64_t),
.max_entries = 1,
.map_flags = BPF_F_NO_PREALLOC,
};

struct bpf_map_def hash_map2 __section("maps") = {
.type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint64_t),
.max_entries = 2,
};

struct bpf_map_def perf_event_array __section("maps") = {
.type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
.max_entries = 4096,
};
#endif

struct bpf_map_def array_of_hash_map __section("maps") = {
.type = BPF_MAP_TYPE_ARRAY_OF_MAPS,
Expand All @@ -108,23 +85,14 @@ int __attribute__((noinline)) global_fn(uint32_t arg) {
return static_fn(arg) + global_fn2(arg) + global_fn3(arg);
}

#if __clang_major__ >= 9
static volatile unsigned int key1 = 0; // .bss
static volatile unsigned int key2 = 1; // .data
volatile const unsigned int key3 = 2; // .rodata
static volatile const uint32_t arg; // .rodata, populated by loader
// custom .rodata section, populated by loader
static volatile const uint32_t arg2 __section(".rodata.test");
#endif

__section("xdp") int xdp_prog() {
#if __clang_major__ < 9
unsigned int key1 = 0;
unsigned int key2 = 1;
unsigned int key3 = 2;
uint32_t arg = 1;
uint32_t arg2 = 2;
#endif
map_lookup_elem(&hash_map, (void *)&key1);
map_lookup_elem(&hash_map2, (void *)&key2);
map_lookup_elem(&hash_map2, (void *)&key3);
Expand All @@ -143,7 +111,6 @@ __section("socket/2") int asm_relocation() {
return my_const;
}

#if __clang_major__ >= 9
volatile const unsigned int uneg = -1;
volatile const int neg = -2;
static volatile const unsigned int static_uneg = -3;
Expand All @@ -164,11 +131,6 @@ __section("socket/3") int data_sections() {

return 0;
}
#else
__section("socket/3") int data_sections() {
return 0;
}
#endif

/*
* Up until LLVM 14, this program results in an .rodata.cst32 section
Expand Down
4 changes: 0 additions & 4 deletions testdata/map_spin_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ struct hash_elem {
struct bpf_spin_lock lock;
};

#if __clang_major__ >= 9
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, uint32_t);
__type(value, struct hash_elem);
__uint(max_entries, 2);
} spin_lock_map __section(".maps");
#else
#error This file required clang >= 9
#endif