From patchwork Mon Jun 22 15:14:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39742 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7B0A53939C1E; Mon, 22 Jun 2020 15:14:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B0A53939C1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1592838862; bh=ly61VqxLTr4tg99R/pUa6bxV9A8J2u5pzohDq0lv2jI=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mJjqLCUxxFhvNjB0QEEjQtugMY/GVQ78ruGLDQDCRh9gCsXFz+6px2QArpC1rWrfw odfP6oqMWWevXW2KMEObTiVDjJeQ4oYJdtqtVustkJVkpMvgMStfDDRKL2iIRP7gLr zFuk35TULkpJ0nSeksME2Sd5UpHPmbmtRKsemFgA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id D1D233890436 for ; Mon, 22 Jun 2020 15:14:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D1D233890436 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-213-pqPR6Xm6MpiLEHdDVDP6pQ-1; Mon, 22 Jun 2020 11:14:17 -0400 X-MC-Unique: pqPR6Xm6MpiLEHdDVDP6pQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3972A835B58 for ; Mon, 22 Jun 2020 15:14:16 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-185.ams2.redhat.com [10.36.112.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8838360BEC for ; Mon, 22 Jun 2020 15:14:15 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 14/30] elf: Make __rtld_env_path_list and __rtld_search_dirs global variables In-Reply-To: References: Message-Id: <35006bff80b0670092334bf1d0ea71fbe49d2b2f.1592836143.git.fweimer@redhat.com> Date: Mon, 22 Jun 2020 17:14:14 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" They have been renamed from env_path_list and rtld_search_dirs to avoid linknamespace issues. This change will allow future use these variables in diagnostics. --- elf/dl-load.c | 53 +++++++++++++++++++++++++------------------------- include/link.h | 4 ++++ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 2339ada485..675d5bd48b 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -98,7 +98,7 @@ int __stack_prot attribute_hidden attribute_relro /* This is the decomposed LD_LIBRARY_PATH search path. */ -static struct r_search_path_struct env_path_list attribute_relro; +struct r_search_path_struct __rtld_env_path_list attribute_relro; /* List of the hardware capabilities we might end up using. */ #ifdef SHARED @@ -442,7 +442,7 @@ add_name_to_object (struct link_map *l, const char *name) } /* Standard search directories. */ -static struct r_search_path_struct rtld_search_dirs attribute_relro; +struct r_search_path_struct __rtld_search_dirs attribute_relro; static size_t max_dirnamelen; @@ -702,9 +702,9 @@ _dl_init_paths (const char *llp, const char *source) #endif /* First set up the rest of the default search directory entries. */ - aelem = rtld_search_dirs.dirs = (struct r_search_path_elem **) + aelem = __rtld_search_dirs.dirs = (struct r_search_path_elem **) malloc ((nsystem_dirs_len + 1) * sizeof (struct r_search_path_elem *)); - if (rtld_search_dirs.dirs == NULL) + if (__rtld_search_dirs.dirs == NULL) { errstring = N_("cannot create search path array"); signal_error: @@ -715,16 +715,17 @@ _dl_init_paths (const char *llp, const char *source) + ncapstr * sizeof (enum r_dir_status)) / sizeof (struct r_search_path_elem)); - rtld_search_dirs.dirs[0] = malloc (nsystem_dirs_len * round_size - * sizeof (*rtld_search_dirs.dirs[0])); - if (rtld_search_dirs.dirs[0] == NULL) + __rtld_search_dirs.dirs[0] + = malloc (nsystem_dirs_len * round_size + * sizeof (*__rtld_search_dirs.dirs[0])); + if (__rtld_search_dirs.dirs[0] == NULL) { errstring = N_("cannot create cache for search path"); goto signal_error; } - rtld_search_dirs.malloced = 0; - pelem = GL(dl_all_dirs) = rtld_search_dirs.dirs[0]; + __rtld_search_dirs.malloced = 0; + pelem = GL(dl_all_dirs) = __rtld_search_dirs.dirs[0]; strp = system_dirs; idx = 0; @@ -811,27 +812,27 @@ _dl_init_paths (const char *llp, const char *source) if (*cp == ':' || *cp == ';') ++nllp; - env_path_list.dirs = (struct r_search_path_elem **) + __rtld_env_path_list.dirs = (struct r_search_path_elem **) malloc ((nllp + 1) * sizeof (struct r_search_path_elem *)); - if (env_path_list.dirs == NULL) + if (__rtld_env_path_list.dirs == NULL) { errstring = N_("cannot create cache for search path"); goto signal_error; } - (void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;", + (void) fillin_rpath (llp_tmp, __rtld_env_path_list.dirs, ":;", source, NULL, l); - if (env_path_list.dirs[0] == NULL) + if (__rtld_env_path_list.dirs[0] == NULL) { - free (env_path_list.dirs); - env_path_list.dirs = (void *) -1; + free (__rtld_env_path_list.dirs); + __rtld_env_path_list.dirs = (void *) -1; } - env_path_list.malloced = 0; + __rtld_env_path_list.malloced = 0; } else - env_path_list.dirs = (void *) -1; + __rtld_env_path_list.dirs = (void *) -1; } @@ -1918,9 +1919,9 @@ open_path (const char *name, size_t namelen, int mode, if (sps->malloced) free (sps->dirs); - /* rtld_search_dirs and env_path_list are attribute_relro, therefore - avoid writing into it. */ - if (sps != &rtld_search_dirs && sps != &env_path_list) + /* __rtld_search_dirs and __rtld_env_path_list are + attribute_relro, therefore avoid writing to them. */ + if (sps != &__rtld_search_dirs && sps != &__rtld_env_path_list) sps->dirs = (void *) -1; } @@ -2068,8 +2069,8 @@ _dl_map_object (struct link_map *loader, const char *name, } /* Try the LD_LIBRARY_PATH environment variable. */ - if (fd == -1 && env_path_list.dirs != (void *) -1) - fd = open_path (name, namelen, mode, &env_path_list, + if (fd == -1 && __rtld_env_path_list.dirs != (void *) -1) + fd = open_path (name, namelen, mode, &__rtld_env_path_list, &realname, &fb, loader ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded, LA_SER_LIBPATH, &found_other_class); @@ -2158,8 +2159,8 @@ _dl_map_object (struct link_map *loader, const char *name, if (fd == -1 && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL || __glibc_likely (!(l->l_flags_1 & DF_1_NODEFLIB))) - && rtld_search_dirs.dirs != (void *) -1) - fd = open_path (name, namelen, mode, &rtld_search_dirs, + && __rtld_search_dirs.dirs != (void *) -1) + fd = open_path (name, namelen, mode, &__rtld_search_dirs, &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); /* Add another newline when we are tracing the library loading. */ @@ -2327,7 +2328,7 @@ _dl_rtld_di_serinfo (struct link_map *loader, Dl_serinfo *si, bool counting) } /* Try the LD_LIBRARY_PATH environment variable. */ - add_path (&p, &env_path_list, XXX_ENV); + add_path (&p, &__rtld_env_path_list, XXX_ENV); /* Look at the RUNPATH information for this binary. */ if (cache_rpath (loader, &loader->l_runpath_dirs, DT_RUNPATH, "RUNPATH")) @@ -2339,7 +2340,7 @@ _dl_rtld_di_serinfo (struct link_map *loader, Dl_serinfo *si, bool counting) /* Finally, try the default path. */ if (!(loader->l_flags_1 & DF_1_NODEFLIB)) - add_path (&p, &rtld_search_dirs, XXX_default); + add_path (&p, &__rtld_search_dirs, XXX_default); if (counting) /* Count the struct size before the string area, which we didn't diff --git a/include/link.h b/include/link.h index aea268439c..d4714bc28d 100644 --- a/include/link.h +++ b/include/link.h @@ -79,6 +79,10 @@ struct r_search_path_struct int malloced; }; +/* Search path information computed by _dl_init_paths. */ +extern struct r_search_path_struct __rtld_search_dirs attribute_hidden; +extern struct r_search_path_struct __rtld_env_path_list attribute_hidden; + /* Structure describing a loaded shared object. The `l_next' and `l_prev' members form a chain of all the shared objects loaded at startup.