OSDN Git Service

MIPS LDSO: pass sym_ref parameter to _dl_find_hash() to support PROTECTED symbols
[uclinux-h8/uClibc.git] / ldso / ldso / ldso.c
index 74da588..7ee9257 100644 (file)
@@ -47,7 +47,9 @@
 
 /* Global variables used within the shared library loader */
 char *_dl_library_path         = NULL; /* Where we look for libraries */
+#ifdef __LDSO_PRELOAD_ENV_SUPPORT__
 char *_dl_preload              = NULL; /* Things to be loaded before the libs */
+#endif
 char *_dl_ldsopath             = NULL; /* Location of the shared lib loader */
 int _dl_errno                  = 0;    /* We can't use the real errno in ldso */
 size_t _dl_pagesize            = 0;    /* Store the page size for use later */
@@ -100,15 +102,13 @@ extern void _start(void);
 
 #ifdef __UCLIBC_HAS_SSP__
 # include <dl-osinfo.h>
-uintptr_t stack_chk_guard;
+static uintptr_t stack_chk_guard;
 # ifndef THREAD_SET_STACK_GUARD
 /* Only exported for architectures that don't store the stack guard canary
  * in local thread area.  */
 uintptr_t __stack_chk_guard attribute_relro;
-#  ifdef __UCLIBC_HAS_SSP_COMPAT__
-strong_alias(__stack_chk_guard,__guard)
-#  endif
-# elif __UCLIBC_HAS_SSP_COMPAT__
+# endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
 uintptr_t __guard attribute_relro;
 # endif
 #endif
@@ -348,7 +348,9 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
             auxvt[AT_UID].a_un.a_val == auxvt[AT_EUID].a_un.a_val &&
             auxvt[AT_GID].a_un.a_val == auxvt[AT_EGID].a_un.a_val)) {
                _dl_secure = 0;
+#ifdef __LDSO_PRELOAD_ENV_SUPPORT__
                _dl_preload = _dl_getenv("LD_PRELOAD", envp);
+#endif
                _dl_library_path = _dl_getenv("LD_LIBRARY_PATH", envp);
        } else {
                static const char unsecure_envvars[] =
@@ -365,7 +367,9 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
                        /* We could use rawmemchr but this need not be fast.  */
                        nextp = _dl_strchr(nextp, '\0') + 1;
                } while (*nextp != '\0');
+#ifdef __LDSO_PRELOAD_ENV_SUPPORT__
                _dl_preload = NULL;
+#endif
                _dl_library_path = NULL;
                /* SUID binaries can be exploited if they do LAZY relocation. */
                unlazy = RTLD_NOW;
@@ -612,6 +616,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 
        _dl_map_cache();
 
+#ifdef __LDSO_PRELOAD_ENV_SUPPORT__
        if (_dl_preload) {
                char c, *str, *str2;
 
@@ -667,6 +672,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
                                str++;
                }
        }
+#endif /* __LDSO_PRELOAD_ENV_SUPPORT__ */
 
 #ifdef __LDSO_PRELOAD_FILE_SUPPORT__
        do {
@@ -862,7 +868,16 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
                ElfW(Ehdr) *epnt = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_val;
                ElfW(Phdr) *myppnt = (ElfW(Phdr) *) DL_RELOC_ADDR(load_addr, epnt->e_phoff);
                int j;
-
+#ifdef __DSBT__
+               struct elf_resolve *ref = _dl_loaded_modules;
+               _dl_if_debug_dprint("ref is %x, dsbt %x, ref-dsbt %x size %x\n",
+                                   ref, tpnt->loadaddr.map->dsbt_table,
+                                   ref->loadaddr.map->dsbt_table,
+                                   tpnt->loadaddr.map->dsbt_size);
+
+               _dl_memcpy(tpnt->loadaddr.map->dsbt_table, ref->loadaddr.map->dsbt_table,
+                          tpnt->loadaddr.map->dsbt_size * sizeof(unsigned *));
+#endif
                tpnt = _dl_add_elf_hash_table(tpnt->libname, load_addr,
                                              tpnt->dynamic_info,
                                              (unsigned long)tpnt->dynamic_addr,
@@ -936,12 +951,12 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
        stack_chk_guard = _dl_setup_stack_chk_guard ();
 # ifdef THREAD_SET_STACK_GUARD
        THREAD_SET_STACK_GUARD (stack_chk_guard);
-#  ifdef __UCLIBC_HAS_SSP_COMPAT__
-       __guard = stack_chk_guard;
-#  endif
 # else
        __stack_chk_guard = stack_chk_guard;
 # endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
+       __guard = stack_chk_guard;
+# endif
 #endif