X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Feal_common_options.c;h=622c7bc4295b40c4a46b1090e3b248dafb87f11b;hb=e863fe3a13da89787fdf3b5c590101a3c0f10af6;hp=ac3884a371dd89fbc4b4c0f2bdda1ea06ae4e438;hpb=7781950f4d38eb7d9f473fedf517f6550c593b1d;p=dpdk.git diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index ac3884a371..622c7bc429 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -402,8 +402,10 @@ eal_plugindir_init(const char *path) struct stat sb; int nlen = strnlen(dent->d_name, sizeof(dent->d_name)); - /* check if name ends in .so */ - if (strcmp(&dent->d_name[nlen - 3], ".so") != 0) + /* check if name ends in .so or .so.ABI_VERSION */ + if (strcmp(&dent->d_name[nlen - 3], ".so") != 0 && + strcmp(&dent->d_name[nlen - 4 - strlen(ABI_VERSION)], + ".so."ABI_VERSION) != 0) continue; snprintf(sopath, sizeof(sopath), "%s/%s", path, dent->d_name); @@ -492,6 +494,39 @@ out: return retval; } +static int +is_shared_build(void) +{ +#define EAL_SO "librte_eal.so" + char soname[32]; + size_t len, minlen = strlen(EAL_SO); + + len = strlcpy(soname, EAL_SO"."ABI_VERSION, sizeof(soname)); + if (len > sizeof(soname)) { + RTE_LOG(ERR, EAL, "Shared lib name too long in shared build check\n"); + len = sizeof(soname) - 1; + } + + while (len >= minlen) { + /* check if we have this .so loaded, if so - shared build */ + RTE_LOG(DEBUG, EAL, "Checking presence of .so '%s'\n", soname); + if (dlopen(soname, RTLD_LAZY | RTLD_NOLOAD) != NULL) { + RTE_LOG(INFO, EAL, "Detected shared linkage of DPDK\n"); + return 1; + } + + /* remove any version numbers off the end to retry */ + while (len-- > 0) + if (soname[len] == '.') { + soname[len] = '\0'; + break; + } + } + + RTE_LOG(INFO, EAL, "Detected static linkage of DPDK\n"); + return 0; +} + int eal_plugins_init(void) { @@ -503,7 +538,7 @@ eal_plugins_init(void) * (Using dlopen with NOLOAD flag on EAL, will return NULL if the EAL * shared library is not already loaded i.e. it's statically linked.) */ - if (dlopen("librte_eal.so."ABI_VERSION, RTLD_LAZY | RTLD_NOLOAD) != NULL && + if (is_shared_build() && *default_solib_dir != '\0' && stat(default_solib_dir, &sb) == 0 && S_ISDIR(sb.st_mode))