From patchwork Thu Oct 1 16:32:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 40605 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 5154B398B873; Thu, 1 Oct 2020 16:33:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5154B398B873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1601569980; bh=7bvIUjLLDv8x7oDfKTjTunExw1mjvnjlj8OMyOLl8ew=; 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=CbOJGDd0psl8GlxLmALa4nAd5uM/BaQvsNFPAqCfkv8idQC//BS+2owoOwVl0pwiz Xgg+brCo7lH6vzWiZXRpelzqOpALBjxXuDz0jLXT6V1RjG29w7Nn1xCEpp7eX119Dp e3QeIYHWs8LVzLHsWcYTbdoL5QZiWZFNHqVqPNP4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 5DB9E398B835 for ; Thu, 1 Oct 2020 16:32:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5DB9E398B835 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-243-jYKs4wVJMYOShULdBOQmuw-1; Thu, 01 Oct 2020 12:32:54 -0400 X-MC-Unique: jYKs4wVJMYOShULdBOQmuw-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 F25B910BBED0 for ; Thu, 1 Oct 2020 16:32:53 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F09060BFA for ; Thu, 1 Oct 2020 16:32:52 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 12/28] elf: Make __rtld_env_path_list and __rtld_search_dirs global variables In-Reply-To: References: Message-Id: Date: Thu, 01 Oct 2020 18:32:50 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (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=-11.4 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_H5, 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. Reviewed-by: Adhemerval Zanella --- 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 5fbb8c9ad4..0c8fa72c4d 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; } @@ -1996,9 +1997,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; } @@ -2146,8 +2147,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); @@ -2236,8 +2237,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. */ @@ -2405,7 +2406,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")) @@ -2417,7 +2418,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.