libbpf_android: allow bpf w/o maps section

Currently, if a bpf program object has no map section, this error is
propagated, and the program will fail to load. However, it is desirable
to have programs without any map.

Bug: 140330870
Test: load program w/ bpf w/o maps section
Change-Id: Ia53c699212a8cb962e3c2db562921880fef0cce0
This commit is contained in:
Steven Moreland 2019-12-12 14:21:20 -08:00
parent be15fa1edd
commit c0905b4880

View file

@ -390,6 +390,7 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>&
string fname = pathToFilename(string(elfPath), true); string fname = pathToFilename(string(elfPath), true);
ret = readSectionByName("maps", elfFile, mdData); ret = readSectionByName("maps", elfFile, mdData);
if (ret == -2) return 0; // no maps to read
if (ret) return ret; if (ret) return ret;
md.resize(mdData.size() / sizeof(struct bpf_map_def)); md.resize(mdData.size() / sizeof(struct bpf_map_def));
memcpy(md.data(), mdData.data(), mdData.size()); memcpy(md.data(), mdData.data(), mdData.size());