From patchwork Thu Dec 7 10:31:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 81632 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 69E50385C6FC for ; Thu, 7 Dec 2023 10:31:45 +0000 (GMT) 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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 72809385B83D for ; Thu, 7 Dec 2023 10:31:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72809385B83D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 72809385B83D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701945087; cv=none; b=GTahok3zQyvNvjX27eqPZ2t5385cOw6EuXcxUJjb3+z8Ii+694pRaBEeHyR8MoiW+zvg9CcOBwYrrCN3vIIIVDjlmvFvMrfuo7X4oLn37T+P/Of6O9m7z9z1iyS/+lnJefnNKVugY3e2EMC8U2qDj+QBOxVrcyuivaveGR0CUtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701945087; c=relaxed/simple; bh=r+414S/qwyaVph5lBzSwhAWJpZVX+/5qNb58Oe7qgYE=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=KeSDMuy5tJnJBd0ZpzNB3LLq46EJUQOOudBhiV9e/+3oza9c7U8h+pUuR3jhIUmqYiZvbnirQ+MBwcS86Zym++hA4pgu2+z5/SWSCHZdc2vpHxRTYKhKjW8bCboGouxnbSDrZ5nTsxouoT27MllzXnVL1pMCn/b7sKqosNQ75f8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701945086; 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=vNZ0fRqtNHASG4AfzruUEWyPLa3SjwQUi/5D+kgBYNM=; b=Oa4hSoXNDUXqmkrGN0hZMRMTgaTIgyrXAI+a9OtNHR5Ubz2SinAdfmWq0DeObYq6DEAyVp UAtkV9kJqxmys3gHT/p5jT4ItbCwrEjLXQm8JOGLHNRLFIf7a9F8b4hc2yoGzMddenHR8f nErEQWQVjVDKo2QJexTaytrkdOHS+HU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-blB4RhZlNfK9NKr7DGKlXg-1; Thu, 07 Dec 2023 05:31:24 -0500 X-MC-Unique: blB4RhZlNfK9NKr7DGKlXg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D37B106D1A4 for ; Thu, 7 Dec 2023 10:31:24 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DAFCC8CD0 for ; Thu, 7 Dec 2023 10:31:23 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v3 04/32] elf: Eliminate second loop in find_version in dl-version.c In-Reply-To: Message-ID: References: X-From-Line: ff5ca6d28edb1c1ea42ad16bc261e282534c3264 Mon Sep 17 00:00:00 2001 Date: Thu, 07 Dec 2023 11:31:22 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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_H3, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org 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)