diff --git a/libbpf_android/Loader.cpp b/libbpf_android/Loader.cpp index 47cf4c9..1c462dd 100644 --- a/libbpf_android/Loader.cpp +++ b/libbpf_android/Loader.cpp @@ -724,13 +724,16 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector& ret = getSectionSymNames(elfFile, "maps", mapNames); if (ret) return ret; + unsigned btfMinBpfLoaderVer = readSectionUint("btf_min_bpfloader_ver", elfFile, 0); + unsigned btfMinKernelVer = readSectionUint("btf_min_kernel_ver", elfFile, 0); + unsigned kvers = kernelVersion(); + std::optional btfFd; - if (!readSectionByName(".BTF", elfFile, btfData)) { + if ((BPFLOADER_VERSION >= btfMinBpfLoaderVer) && (kvers >= btfMinKernelVer) && + (!readSectionByName(".BTF", elfFile, btfData))) { btfFd = getMapBtfInfo(elfPath, btfTypeIdMap); } - unsigned kvers = kernelVersion(); - for (int i = 0; i < (int)mapNames.size(); i++) { if (BPFLOADER_VERSION < md[i].bpfloader_min_ver) { ALOGI("skipping map %s which requires bpfloader min ver 0x%05x", mapNames[i].c_str(),