From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 03CC83848147 for ; Fri, 7 Jul 2023 18:47:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 03CC83848147 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688755668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cRbP/Nx0yFD8Gx6CoknoYqUf7pRsVXmpcN39G3ZXbWc=; b=A4ASAw+WazXKEeBD6gI21mUcIqltJlqHSAuszFle6A2QD1SQ43tagB0b3mCQNRC6JRTaLa WN8fpA02Hd71Ci+npGUxjqDiajFty+0nk+Ku6Q17NkMFuEDzUdTNLpFYkOPxQG4eh4/68P ILjHzJgD3kB2Li7e+9KfffWmj/WQvGY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-357-FyUZRmsNMP-XyLuErTtgXQ-1; Fri, 07 Jul 2023 14:47:47 -0400 X-MC-Unique: FyUZRmsNMP-XyLuErTtgXQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 36BAD1064FB6 for ; Fri, 7 Jul 2023 18:47:47 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 900502166B27 for ; Fri, 7 Jul 2023 18:47:46 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v2 04/32] elf: Eliminate second loop in find_version in dl-version.c In-Reply-To: Message-ID: <482ee85bc23ab984718a69e88f9a61fff3f04614.1688741159.git.fweimer@redhat.com> References: X-From-Line: 482ee85bc23ab984718a69e88f9a61fff3f04614 Mon Sep 17 00:00:00 2001 Date: Fri, 07 Jul 2023 20:47:44 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.6 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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The first loop iterates through all objects in the namespace because _dl_check_map_versions is called after the loaded objects have been added to the list. (This list is not limited by symbol search scope.) Turn the assert in _dl_check_map_versions into a proper error because it can be triggered by inconsistent variants of shared objects. --- elf/dl-version.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/elf/dl-version.c b/elf/dl-version.c index 5b8693de04..b3b2160ac8 100644 --- a/elf/dl-version.c +++ b/elf/dl-version.c @@ -31,21 +31,17 @@ __attribute ((always_inline)) find_needed (const char *name, struct link_map *map) { struct link_map *tmap; - unsigned int n; for (tmap = GL(dl_ns)[map->l_ns]._ns_loaded; tmap != NULL; tmap = tmap->l_next) if (_dl_name_match_p (name, tmap)) return tmap; - /* The required object is not in the global scope, look to see if it is - a dependency of the current object. */ - for (n = 0; n < map->l_searchlist.r_nlist; n++) - if (_dl_name_match_p (name, map->l_searchlist.r_list[n])) - return map->l_searchlist.r_list[n]; - - /* Should never happen. */ - return NULL; + struct dl_exception exception; + _dl_exception_create_format + (&exception, DSO_FILENAME (map->l_name), + "missing soname %s in version dependency", name); + _dl_signal_exception (0, &exception, NULL); } @@ -199,10 +195,6 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode) ElfW(Vernaux) *aux; struct link_map *needed = find_needed (strtab + ent->vn_file, map); - /* If NEEDED is NULL this means a dependency was not found - and no stub entry was created. This should never happen. */ - assert (needed != NULL); - /* Make sure this is no stub we created because of a missing dependency. */ if (__builtin_expect (! trace_mode, 1) -- 2.41.0