X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-so.c;h=02e986e72fa086d41db1b185f503157bb545103d;hb=2f38d2ea0537107def8514dc2e0c680ff8d31ca8;hp=11088b1caf0f60c6383cb1836ef08117f37bc30b;hpb=2ba7c200c6c4844b63f8f707a6f04017661f16ca;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-so.c b/src/afb-api-so.c index 11088b1c..02e986e7 100644 --- a/src/afb-api-so.c +++ b/src/afb-api-so.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2019 "IoT.bzh" + * Copyright (C) 2015-2020 "IoT.bzh" * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,9 +15,12 @@ * limitations under the License. */ +#if WITH_DYNAMIC_BINDING + #define _GNU_SOURCE #include +#include #include #include #include @@ -25,7 +28,6 @@ #include #include "afb-api-so.h" -#include "afb-api-so-v2.h" #include "afb-api-so-v3.h" #include "verbose.h" #include "sig-monitor.h" @@ -36,6 +38,9 @@ #if WITH_LEGACY_BINDING_VDYN # include "afb-api-so-vdyn.h" #endif +#if WITH_LEGACY_BINDING_V2 +# include "afb-api-so-v2.h" +#endif struct safe_dlopen { @@ -70,10 +75,23 @@ static int load_binding(const char *path, int force, struct afb_apiset *declare_ int obsolete = 0; int rc; void *handle; + static int dlopen_flags = 0; + + /* compute the dlopen flags */ + if (dlopen_flags == 0) { + /* For ASan mode, export AFB_NO_RTLD_DEEPBIND=1, to disable RTLD_DEEPBIND */ + char *string = secure_getenv("AFB_NO_RTLD_DEEPBIND"); + if (string && string[0] == '1' && string[1] == 0) + dlopen_flags = RTLD_NOW | RTLD_LOCAL; + else + dlopen_flags = RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND; + } - // This is a loadable library let's check if it's a binding + /* set default return code rc according to force */ rc = -!!force; - handle = safe_dlopen(path, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND); + + /* try to open the library */ + handle = safe_dlopen(path, dlopen_flags); if (handle == NULL) { if (force) ERROR("binding [%s] not loadable: %s", path, dlerror()); @@ -81,6 +99,9 @@ static int load_binding(const char *path, int force, struct afb_apiset *declare_ WARNING("binding [%s] not loadable: %s", path, dlerror()); goto error; } + /* + * This is a loadable library let's check if it's a binding ... + */ /* try the version 3 */ rc = afb_api_so_v3_add(path, handle, declare_set, call_set); @@ -91,6 +112,7 @@ static int load_binding(const char *path, int force, struct afb_apiset *declare_ if (rc) return 0; /* yes version 3 */ +#if WITH_LEGACY_BINDING_V2 /* try the version 2 */ rc = afb_api_so_v2_add(path, handle, declare_set, call_set); if (rc < 0) { @@ -99,6 +121,12 @@ static int load_binding(const char *path, int force, struct afb_apiset *declare_ } if (rc) return 0; /* yes version 2 */ +#else + if (dlsym(handle, "afbBindingV2")) { + WARNING("binding [%s]: version 2 not supported", path); + obsolete = 1; + } +#endif #if WITH_LEGACY_BINDING_VDYN /* try the version dyn */ @@ -313,3 +341,4 @@ int afb_api_so_add_pathset_nofails(const char *pathset, struct afb_apiset *decla return afb_api_so_add_pathset(pathset, declare_set, call_set, 0); } +#endif