Add method to update btf_type.size for BTF_KIND_DATASEC
size in btf_type of BTF_KIND_DATASEC is 0 at compilation time. So bpf loader needs to update to actual size based on ELF's section size. Bug: 403381101 Test: boot Change-Id: I78fb26a5b8eeb120044b5737667f472fac51d79f
This commit is contained in:
parent
712088dff3
commit
b3d3c2ae57
1 changed files with 19 additions and 0 deletions
|
|
@ -17,6 +17,7 @@
|
|||
#define LOG_TAG "NetBpfLoad"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <bpf/btf.h>
|
||||
#include <bpf/libbpf.h>
|
||||
#include <dirent.h>
|
||||
#include <elf.h>
|
||||
|
|
@ -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<char> 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<unique_fd>& mapFds,
|
||||
const char* prefix, const unsigned int bpfloader_ver) {
|
||||
int ret;
|
||||
|
|
|
|||
Loading…
Reference in a new issue