From 2f389d46df6a9634589554708e2a7ea6ca901b86 Mon Sep 17 00:00:00 2001 From: Leonid Lisovskiy Date: Tue, 26 Jan 2016 20:12:58 +0300 Subject: ldso: Use single rtld_flags interpretation through all the calls Implement single rtld_flags interpretation through all the do_dlopen()/_dl_load_shared_library()/_dl_load_elf_shared_library() calls chain. This adds the ability to use the flags, passed to dlopen(), in all underlaying functions and implement rtld_flags inheritance. Saves a few bytes code. Signed-off-by: Leonid Lisovskiy Signed-off-by: Waldemar Brodkorb --- ldso/ldso/dl-elf.c | 14 +++++++------- ldso/ldso/ldso.c | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'ldso/ldso') diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 5b8572a8f..04e8c60a4 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -132,7 +132,7 @@ _dl_protect_relro (struct elf_resolve *l) /* This function's behavior must exactly match that * in uClibc/ldso/util/ldd.c */ static struct elf_resolve * -search_for_named_library(const char *name, unsigned rflags, const char *path_list, +search_for_named_library(const char *name, unsigned int rflags, const char *path_list, struct dyn_elf **rpnt, const char* origin) { char *mylibname; @@ -164,7 +164,7 @@ search_for_named_library(const char *name, unsigned rflags, const char *path_lis int olen; /* $ORIGIN is not expanded for SUID/GUID programs (except if it is $ORIGIN alone) */ - if ((rflags & DL_RESOLVE_SECURE) && plen != 7) + if ((rflags & __RTLD_SECURE) && plen != 7) continue; if (origin == NULL) continue; @@ -196,7 +196,7 @@ search_for_named_library(const char *name, unsigned rflags, const char *path_lis unsigned long _dl_error_number; unsigned long _dl_internal_error_number; -struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rpnt, +struct elf_resolve *_dl_load_shared_library(unsigned int rflags, struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname, int attribute_unused trace_loaded_objects) { char *pnt; @@ -495,7 +495,7 @@ map_writeable (int infile, ElfW(Phdr) *ppnt, int piclib, int flags, * are required. */ -struct elf_resolve *_dl_load_elf_shared_library(unsigned rflags, +struct elf_resolve *_dl_load_elf_shared_library(unsigned int rflags, struct dyn_elf **rpnt, const char *libname) { ElfW(Ehdr) *epnt; @@ -534,7 +534,7 @@ struct elf_resolve *_dl_load_elf_shared_library(unsigned rflags, } /* If we are in secure mode (i.e. a setuid/gid binary using LD_PRELOAD), we don't load the library if it isn't setuid. */ - if (rflags & DL_RESOLVE_SECURE) { + if (rflags & __RTLD_SECURE) { if (!(st.st_mode & S_ISUID)) { _dl_close(infile); return NULL; @@ -550,7 +550,7 @@ struct elf_resolve *_dl_load_elf_shared_library(unsigned rflags, return tpnt; } } - if (rflags & DL_RESOLVE_NOLOAD) { + if (rflags & RTLD_NOLOAD) { _dl_close(infile); return NULL; } @@ -814,7 +814,7 @@ struct elf_resolve *_dl_load_elf_shared_library(unsigned rflags, DL_RELOC_ADDR(DL_GET_RUN_ADDR(tpnt->loadaddr, tpnt->mapaddr), epnt->e_phoff); tpnt->n_phent = epnt->e_phnum; - tpnt->rtld_flags |= rtld_flags; + tpnt->rtld_flags = rflags | rtld_flags; #ifdef __LDSO_STANDALONE_SUPPORT__ tpnt->l_entry = epnt->e_entry; #endif diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 0cdc91d99..9f4e84130 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -589,7 +589,8 @@ of this helper program; chances are you did not intend to run this program.\n\ * but it could be also a shared object (when ld.so used for tracing) * We keep the misleading app_tpnt name to avoid variable pollution */ - app_tpnt = _dl_load_elf_shared_library(_dl_secure, &rpnt, _dl_progname); + app_tpnt = _dl_load_elf_shared_library(_dl_secure ? __RTLD_SECURE : 0, + &rpnt, _dl_progname); if (!app_tpnt) { _dl_dprintf(2, "can't load '%s'\n", _dl_progname); _dl_exit(16); @@ -887,7 +888,7 @@ of this helper program; chances are you did not intend to run this program.\n\ _dl_if_debug_dprint("\tfile='%s'; needed by '%s'\n", str, _dl_progname); tpnt1 = _dl_load_shared_library( - _dl_secure ? DL_RESOLVE_SECURE : 0, + _dl_secure ? __RTLD_SECURE : 0, &rpnt, NULL, str, trace_loaded_objects); if (!tpnt1) { #ifdef __LDSO_LDD_SUPPORT__ -- cgit v1.2.3