simplify libbpf_android.h

Test: TreeHugger
Flag: EXEMPT trivial
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I39f73afef65b22b1d275742758aff7745991d9e7
This commit is contained in:
Maciej Żenczykowski 2025-07-15 23:14:37 -07:00
commit 8b3ea0a274
2 changed files with 9 additions and 33 deletions

View file

@ -817,6 +817,13 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const
return 0;
}
struct Location {
const char* const dir = "";
const char* const prefix = "";
const bpf_prog_type* allowedProgTypes = nullptr;
size_t allowedProgTypesLength = 0;
};
int loadProg(const char* elfPath, bool* isCritical, const Location& location) {
vector<char> license;
vector<char> critical;

View file

@ -17,39 +17,8 @@
#pragma once
#ifdef __cplusplus
#include <linux/bpf.h>
#include <fstream>
namespace android {
namespace bpf {
struct Location {
const char* const dir = "";
const char* const prefix = "";
const bpf_prog_type* allowedProgTypes = nullptr;
size_t allowedProgTypesLength = 0;
};
// BPF loader implementation. Loads an eBPF ELF object
int loadProg(const char* elfPath, bool* isCritical, const Location &location = {});
// Exposed for testing
unsigned int readSectionUint(const char* name, std::ifstream& elfFile, unsigned int defVal);
} // namespace bpf
} // namespace android
extern "C" {
#else // __cplusplus
#define __noreturn
#endif // __cplusplus
// The C++ portion of the BpfLoader is exposed as a terminal function.
__noreturn void vendorBpfLoader();
#ifdef __cplusplus
} // extern C
extern "C" __noreturn
#endif
void vendorBpfLoader();