From patchwork Thu Dec 23 18:43:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 49224 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 A32733858012 for ; Thu, 23 Dec 2021 18:45:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A32733858012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1640285138; bh=qwbetgKJXWFj4xBXuuexilTGne/VyB4r1Uob1v+b1ak=; 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=yP+WdXiNdHU90taLIjAtfvQs3sgTdKzY1jR5b0fRIUyXXmE8ye9pyI0Cj59M04MRT 9gYh1MztqZUSVKAJvDcmOsBFw0kgsxGKEXuLEkIoGHb33Qcwe31IkyKOe2GCFnvCih xlLWRuG4R7aCEbaO1Oq+c2T9GMiQBSyb/K0NMpyo= 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 6D1923858016 for ; Thu, 23 Dec 2021 18:43:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D1923858016 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-168-xwD_dMkOP5C4xcnal_UBcg-1; Thu, 23 Dec 2021 13:43:25 -0500 X-MC-Unique: xwD_dMkOP5C4xcnal_UBcg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 084561800D50 for ; Thu, 23 Dec 2021 18:43:25 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.104]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6181AE2FE for ; Thu, 23 Dec 2021 18:43:24 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 3/4] elf: Support version-less lookup in _dl_lookup_direct In-Reply-To: References: X-From-Line: 52bda11381ea8bec52decc1809373971e46abbab Mon Sep 17 00:00:00 2001 Message-Id: <52bda11381ea8bec52decc1809373971e46abbab.1640284721.git.fweimer@redhat.com> Date: Thu, 23 Dec 2021 19:43:22 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- elf/dl-lookup-direct.c | 5 +++++ sysdeps/generic/ldsodefs.h | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/elf/dl-lookup-direct.c b/elf/dl-lookup-direct.c index 08ac4d4104..6617962c4d 100644 --- a/elf/dl-lookup-direct.c +++ b/elf/dl-lookup-direct.c @@ -54,6 +54,11 @@ check_match (const struct link_map *const map, const char *const undef_name, /* Not the symbol we are looking for. */ return NULL; + if (map->l_versyms == NULL || version == NULL) + /* No symbol versioning information available, or no symbol + version requested. Accepted the symbol. */ + return sym; + ElfW(Half) ndx = map->l_versyms[symidx] & 0x7fff; if (map->l_versions[ndx].hash != version_hash || strcmp (map->l_versions[ndx].name, version) != 0) diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 9efd5506b6..8ff06d6b02 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1051,9 +1051,10 @@ extern lookup_t _dl_lookup_symbol_x (const char *undef, MAP) for the symbol UNDEF_NAME, with GNU hash NEW_HASH (computed with dl_new_hash), symbol version VERSION, and symbol version hash VERSION_HASH (computed with _dl_elf_hash). Returns a pointer to - the symbol table entry in MAP on success, or NULL on failure. MAP - must have symbol versioning information, or otherwise the result is - undefined. */ + the symbol table entry in MAP on success, or NULL on failure. + + If VERSION is NULL or MAP does not have symbol versioning + information, any symbol version is accepted. */ const ElfW(Sym) *_dl_lookup_direct (struct link_map *map, const char *undef_name, uint32_t new_hash,