diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp index f8691fd06b..64ebe0c577 100644 --- a/bpf/loader/NetBpfLoad.cpp +++ b/bpf/loader/NetBpfLoad.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "NetBpfLoad" #include +#include #include #include #include @@ -649,6 +650,24 @@ static bool mapMatchesExpectations(const unique_fd& fd, const string& mapName, return false; } +static int setBtfDatasecSize(ifstream &elfFile, struct btf *btf, + struct btf_type *bt) { + const char *name = btf__name_by_offset(btf, bt->name_off); + if (!name) { + ALOGE("Couldn't resolve section name, errno: %d", errno); + return -errno; + } + + vector data; + int ret = readSectionByName(name, elfFile, data); + if (ret) { + ALOGE("Couldn't read section %s, ret: %d", name, ret); + return ret; + } + bt->size = data.size(); + return 0; +} + static int createMaps(const char* elfPath, ifstream& elfFile, vector& mapFds, const char* prefix, const unsigned int bpfloader_ver) { int ret;