未验证 提交 3e7a20ca 编写于 作者: O openharmony_ci 提交者: Gitee

!703 revert remove global library in default namespace

Merge pull request !703 from yinchuang/revert_global
...@@ -4,4 +4,3 @@ ...@@ -4,4 +4,3 @@
[acquiescence] [acquiescence]
namespace.default.lib.paths = /system/lib64:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/ndk:/system/lib64/chipset-pub-sdk:/system/lib64/chipset-sdk:/system/lib64/platformsdk:/system/lib64/priv-platformsdk:/system/lib64/priv-module:/system/lib64/module:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/vendor/lib:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib namespace.default.lib.paths = /system/lib64:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/ndk:/system/lib64/chipset-pub-sdk:/system/lib64/chipset-sdk:/system/lib64/platformsdk:/system/lib64/priv-platformsdk:/system/lib64/priv-module:/system/lib64/module:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/vendor/lib:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib
namespace.default.asan.lib.paths = /system/lib64:/system/lib64/module:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib namespace.default.asan.lib.paths = /system/lib64:/system/lib64/module:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib
namespace.default.ignore_global_library = true
\ No newline at end of file
...@@ -4,4 +4,3 @@ ...@@ -4,4 +4,3 @@
[acquiescence] [acquiescence]
namespace.default.lib.paths = /system/lib:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib namespace.default.lib.paths = /system/lib:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib
namespace.default.asan.lib.paths = /system/lib:/system/lib/module:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib namespace.default.asan.lib.paths = /system/lib:/system/lib/module:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib
namespace.default.ignore_global_library = true
\ No newline at end of file
...@@ -4,4 +4,3 @@ ...@@ -4,4 +4,3 @@
[acquiescence] [acquiescence]
namespace.default.lib.paths = /system/lib64:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/ndk:/system/lib64/chipset-pub-sdk:/system/lib64/chipset-sdk:/system/lib64/platformsdk:/system/lib64/priv-platformsdk:/system/lib64/priv-module:/system/lib64/module:/system/lib64/module/data:/system/lib64/module/multimedia:/lib64 namespace.default.lib.paths = /system/lib64:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/ndk:/system/lib64/chipset-pub-sdk:/system/lib64/chipset-sdk:/system/lib64/platformsdk:/system/lib64/priv-platformsdk:/system/lib64/priv-module:/system/lib64/module:/system/lib64/module/data:/system/lib64/module/multimedia:/lib64
namespace.default.asan.lib.paths = /system/lib64:/system/lib64/module:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/module/data:/system/lib64/module/multimedia:/lib64 namespace.default.asan.lib.paths = /system/lib64:/system/lib64/module:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/module/data:/system/lib64/module/multimedia:/lib64
namespace.default.ignore_global_library = true
\ No newline at end of file
...@@ -274,15 +274,13 @@ static void init_default_namespace(struct dso *app) ...@@ -274,15 +274,13 @@ static void init_default_namespace(struct dso *app)
if (env_path) ns_set_env_paths(default_ns, env_path); if (env_path) ns_set_env_paths(default_ns, env_path);
ns_set_lib_paths(default_ns, sys_path); ns_set_lib_paths(default_ns, sys_path);
ns_set_separated(default_ns, false); ns_set_separated(default_ns, false);
ns_set_ignore_global_library(default_ns, true);
app->namespace = default_ns; app->namespace = default_ns;
ns_add_dso(default_ns, app); ns_add_dso(default_ns, app);
LD_LOGD("init_default_namespace default_namespace:" LD_LOGD("init_default_namespace default_namespace:"
"nsname: default ," "nsname: default ,"
"lib_paths:%{public}s ," "lib_paths:%{public}s ,"
"env_path:%{public}s ," "env_path:%{public}s ,"
"separated: false ," "separated: false.",
"ignore_global_library: true.",
sys_path, env_path); sys_path, env_path);
return; return;
} }
...@@ -297,8 +295,6 @@ static void set_ns_attrs(ns_t *ns, ns_configor *conf) ...@@ -297,8 +295,6 @@ static void set_ns_attrs(ns_t *ns, ns_configor *conf)
ns_set_separated(ns, conf->get_separated(ns->ns_name)); ns_set_separated(ns, conf->get_separated(ns->ns_name));
ns_set_ignore_global_library(ns, conf->get_ignore_global_library(ns->ns_name));
lib_paths = conf->get_lib_paths(ns->ns_name); lib_paths = conf->get_lib_paths(ns->ns_name);
if (lib_paths) ns_set_lib_paths(ns, lib_paths); if (lib_paths) ns_set_lib_paths(ns, lib_paths);
...@@ -646,11 +642,11 @@ static Sym *gnu_lookup(struct sym_info_pair s_info_p, uint32_t *hashtab, struct ...@@ -646,11 +642,11 @@ static Sym *gnu_lookup(struct sym_info_pair s_info_p, uint32_t *hashtab, struct
static Sym *gnu_lookup_filtered(struct sym_info_pair s_info_p, uint32_t *hashtab, struct dso *dso, struct verinfo *verinfo, uint32_t fofs, size_t fmask) static Sym *gnu_lookup_filtered(struct sym_info_pair s_info_p, uint32_t *hashtab, struct dso *dso, struct verinfo *verinfo, uint32_t fofs, size_t fmask)
{ {
uint32_t h1 = s_info_p.sym_h;
const size_t *bloomwords = (const void *)(hashtab+4); const size_t *bloomwords = (const void *)(hashtab+4);
size_t f = bloomwords[fofs & (hashtab[2]-1)]; size_t f = bloomwords[fofs & (hashtab[2]-1)];
if (!(f & fmask)) return 0; if (!(f & fmask)) return 0;
uint32_t h1 = s_info_p.sym_h;
f >>= (h1 >> hashtab[3]) % (8 * sizeof f); f >>= (h1 >> hashtab[3]) % (8 * sizeof f);
if (!(f & 1)) return 0; if (!(f & 1)) return 0;
...@@ -2742,7 +2738,6 @@ void __dls3(size_t *sp, size_t *auxv) ...@@ -2742,7 +2738,6 @@ void __dls3(size_t *sp, size_t *auxv)
/* Initial dso chain consists only of the app. */ /* Initial dso chain consists only of the app. */
head = tail = syms_tail = &app; head = tail = syms_tail = &app;
struct dso *orig_syms_tail = syms_tail;
/* Donate unused parts of app and library mapping to malloc */ /* Donate unused parts of app and library mapping to malloc */
reclaim_gaps(&app); reclaim_gaps(&app);
...@@ -2888,9 +2883,6 @@ void __dls3(size_t *sp, size_t *auxv) ...@@ -2888,9 +2883,6 @@ void __dls3(size_t *sp, size_t *auxv)
DFX_InstallSignalHandler(); DFX_InstallSignalHandler();
#endif #endif
errno = 0; errno = 0;
if (app.namespace->ignore_global_library) {
revert_syms(orig_syms_tail);
}
CRTJMP((void *)aux[AT_ENTRY], argv-1); CRTJMP((void *)aux[AT_ENTRY], argv-1);
for(;;); for(;;);
...@@ -3113,9 +3105,8 @@ static void *dlopen_impl_orig( ...@@ -3113,9 +3105,8 @@ static void *dlopen_impl_orig(
/* If RTLD_GLOBAL was not specified, undo any new additions /* If RTLD_GLOBAL was not specified, undo any new additions
* to the global symbol table. This is a nop if the library was * to the global symbol table. This is a nop if the library was
* previously loaded and already global. If it is default namespace, * previously loaded and already global. */
* we also undo any new additions to the global symbol table. */ if (!(mode & RTLD_GLOBAL))
if (!(mode & RTLD_GLOBAL) || p->namespace->ignore_global_library)
revert_syms(orig_syms_tail); revert_syms(orig_syms_tail);
/* Processing of deferred lazy relocations must not happen until /* Processing of deferred lazy relocations must not happen until
......
...@@ -327,15 +327,6 @@ void ns_set_separated(ns_t *ns, bool separated) ...@@ -327,15 +327,6 @@ void ns_set_separated(ns_t *ns, bool separated)
LD_LOGD("ns_set_separated ns[%{public}s] separated:%{public}d.", ns->ns_name, ns->separated); LD_LOGD("ns_set_separated ns[%{public}s] separated:%{public}d.", ns->ns_name, ns->separated);
} }
void ns_set_ignore_global_library(ns_t *ns, bool ignore_global_library)
{
if (!ns) {
return;
}
ns->ignore_global_library = ignore_global_library;
LD_LOGD("ns_set_ignore_global_library ns[%{public}s] ignore_global_library:%{public}d.", ns->ns_name, ns->ignore_global_library);
}
void ns_set_allowed_libs(ns_t *ns, const char *allowed_libs) void ns_set_allowed_libs(ns_t *ns, const char *allowed_libs)
{ {
if (!ns) { if (!ns) {
......
...@@ -43,7 +43,6 @@ typedef struct _namespace_t_ { ...@@ -43,7 +43,6 @@ typedef struct _namespace_t_ {
strlist *asan_permitted_paths; /* when asan is enable and separated,the same as above. */ strlist *asan_permitted_paths; /* when asan is enable and separated,the same as above. */
bool separated; /* if separated */ bool separated; /* if separated */
bool ignore_global_library; /* when true, RTLD_GLOBAL will be invalid in current ns. */
strlist *allowed_libs; /* when separated, allowed library names splited by ':'. */ strlist *allowed_libs; /* when separated, allowed library names splited by ':'. */
dsolist *ns_dsos; /* dso list in this namespace */ dsolist *ns_dsos; /* dso list in this namespace */
struct _ns_inherit_list_ *ns_inherits; /* inherit list in this namespace */ struct _ns_inherit_list_ *ns_inherits; /* inherit list in this namespace */
...@@ -79,7 +78,6 @@ void ns_set_asan_lib_paths(ns_t *ns, const char *asan_lib_paths); ...@@ -79,7 +78,6 @@ void ns_set_asan_lib_paths(ns_t *ns, const char *asan_lib_paths);
void ns_set_permitted_paths(ns_t *ns, const char *permitted_paths); void ns_set_permitted_paths(ns_t *ns, const char *permitted_paths);
void ns_set_asan_permitted_paths(ns_t *ns, const char *asan_permitted_paths); void ns_set_asan_permitted_paths(ns_t *ns, const char *asan_permitted_paths);
void ns_set_separated(ns_t *ns, bool separated); void ns_set_separated(ns_t *ns, bool separated);
void ns_set_ignore_global_library(ns_t *ns, bool ignore_global_library);
void ns_set_allowed_libs(ns_t *ns, const char *allowed_libs); void ns_set_allowed_libs(ns_t *ns, const char *allowed_libs);
void ns_add_dso(ns_t *ns, struct dso *dso); void ns_add_dso(ns_t *ns, struct dso *dso);
void nslist_add_ns(ns_t *ns); void nslist_add_ns(ns_t *ns);
......
...@@ -361,7 +361,6 @@ static ns_configor g_configor; ...@@ -361,7 +361,6 @@ static ns_configor g_configor;
#define ATTR_NS_PERMITTED_PATHS "permitted.paths" /* when separated, permitted dir paths of libs, including sub dirs */ #define ATTR_NS_PERMITTED_PATHS "permitted.paths" /* when separated, permitted dir paths of libs, including sub dirs */
#define ATTR_NS_INHERITS "inherits" /* inherited namespace */ #define ATTR_NS_INHERITS "inherits" /* inherited namespace */
#define ATTR_NS_SEPARATED "separated" /* if separated */ #define ATTR_NS_SEPARATED "separated" /* if separated */
#define ATTR_NS_IGNORE_GLOBAL_LIBRARY "ignore_global_library" /* when true, RTLD_GLOBAL will be invalid in current ns. */
#define ATTR_ADDED_NSLIST "added.nslist" /* all namespace names except default */ #define ATTR_ADDED_NSLIST "added.nslist" /* all namespace names except default */
#define ATTR_NS_DEFAULT "default" /* default namespace name */ #define ATTR_NS_DEFAULT "default" /* default namespace name */
#define ATTR_NS_ACQUIESCENCE "acquiescence" /* acquiescence section name */ #define ATTR_NS_ACQUIESCENCE "acquiescence" /* acquiescence section name */
...@@ -599,22 +598,7 @@ static bool config_get_separated(const char *ns_name) ...@@ -599,22 +598,7 @@ static bool config_get_separated(const char *ns_name)
if (val && !strcmp("true", val)) return true; if (val && !strcmp("true", val)) return true;
return false; /* default false */ return false; /* default false */
} }
/* get ignore_global_library */
static bool config_get_ignore_global_library(const char *ns_name)
{
if (ns_name == NULL) {
return false;
}
config_key_join(ATTR_NS_PREFIX, true);
config_key_join(".", false);
config_key_join(ns_name, false);
config_key_join(".", false);
char *key = config_key_join(ATTR_NS_IGNORE_GLOBAL_LIBRARY, false);
char *val = config_get_value(key);
strlwc(val);
if (val && !strcmp("true", val)) return true;
return false; /* default false */
}
/* get allowed libs */ /* get allowed libs */
static char *config_get_allowed_libs(const char *ns_name) static char *config_get_allowed_libs(const char *ns_name)
{ {
...@@ -664,7 +648,6 @@ ns_configor *configor_init() ...@@ -664,7 +648,6 @@ ns_configor *configor_init()
g_configor.get_permitted_paths = config_get_permitted_paths; g_configor.get_permitted_paths = config_get_permitted_paths;
g_configor.get_asan_permitted_paths = config_get_asan_permitted_paths; g_configor.get_asan_permitted_paths = config_get_asan_permitted_paths;
g_configor.get_separated = config_get_separated; g_configor.get_separated = config_get_separated;
g_configor.get_ignore_global_library = config_get_ignore_global_library;
g_configor.get_inherits = config_get_inherits; g_configor.get_inherits = config_get_inherits;
g_configor.get_allowed_libs = config_get_allowed_libs; g_configor.get_allowed_libs = config_get_allowed_libs;
g_configor.get_inherit_shared_libs = config_get_inherit_shared_libs; g_configor.get_inherit_shared_libs = config_get_inherit_shared_libs;
......
...@@ -62,7 +62,6 @@ typedef struct _ns_configor_ { ...@@ -62,7 +62,6 @@ typedef struct _ns_configor_ {
char *(*get_permitted_paths)(const char *ns_name); char *(*get_permitted_paths)(const char *ns_name);
char *(*get_asan_permitted_paths)(const char *ns_name); char *(*get_asan_permitted_paths)(const char *ns_name);
bool (*get_separated)(const char *ns_name); bool (*get_separated)(const char *ns_name);
bool (*get_ignore_global_library)(const char *ns_name);
strlist *(*get_inherits)(const char *ns_name); strlist *(*get_inherits)(const char *ns_name);
char *(*get_allowed_libs)(const char *ns_name); char *(*get_allowed_libs)(const char *ns_name);
char *(*get_inherit_shared_libs)(const char *ns_name, const char *inherited_ns_name); char *(*get_inherit_shared_libs)(const char *ns_name, const char *inherited_ns_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册