From patchwork Wed Dec 16 13:26:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 1417160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=o+oDoSmQ; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CwwvV00BCz9sWj for ; Thu, 17 Dec 2020 00:29:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 61936383E82A; Wed, 16 Dec 2020 13:28:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61936383E82A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608125281; bh=/yTgZfzyu3Bci74gxNOAUNrYymX4DGueK8qGLLp41Cs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=o+oDoSmQkVFMZstfWyaXB+vFTcm2tfp/2rHUAujL+Vj3FHgvpEbsHxFmdYFypJABO 2kAg5usTXwt6jKvYnvyw3cnToCHlj6MfzCwI6G+3j/Jdd1NKFcojVc0wur3zE55g2C ANxTvcpq8jzR8cjA1iltQbxj7+KRp6PfZYAI741c= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by sourceware.org (Postfix) with ESMTPS id 4FFEB3840C1F for ; Wed, 16 Dec 2020 13:27:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FFEB3840C1F Received: from noise.cbg.collabora.co.uk (unknown [IPv6:2001:4d48:ad5c:ef00:8e70:5aff:fe59:c29c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id C3FE11F456A6 for ; Wed, 16 Dec 2020 13:27:46 +0000 (GMT) To: libc-alpha Subject: [RFC][PATCH v7 17/20] dlsym, dlvsym should be able to look up symbols via DSO proxies Date: Wed, 16 Dec 2020 13:26:47 +0000 Message-Id: <20201216132650.22949-18-vivek@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201216132650.22949-1-vivek@collabora.com> References: <20201216132650.22949-1-vivek@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, 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: =?utf-8?q?Vivek_Das=C2=A0Mohapatra_via_Libc-alpha?= From: Vivek Dasmohapatra Reply-To: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --- elf/dl-sym.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/elf/dl-sym.c b/elf/dl-sym.c index 361b926ea9..4abd7eb3b4 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -96,6 +96,10 @@ do_sym (void *handle, const char *name, void *who, { match = _dl_sym_find_caller_link_map (caller); + /* Proxies don't contain any symbols: Need to look at the real DSO. */ + if (__glibc_unlikely (match->l_proxy)) + match = match->l_real; + /* Search the global scope. We have the simple case where we look up in the scope of an object which was part of the initial binary. And then the more complex part @@ -140,6 +144,11 @@ RTLD_NEXT used in code not dynamically loaded")); } struct link_map *l = match; + + /* Proxies don't contain any symbols: Need to look at the real DSO. */ + if (__glibc_unlikely (l->l_proxy)) + l = l->l_real; + while (l->l_loader != NULL) l = l->l_loader; @@ -150,6 +159,11 @@ RTLD_NEXT used in code not dynamically loaded")); { /* Search the scope of the given object. */ struct link_map *map = handle; + + /* Proxies don't contain any symbols: Need to look at the real DSO. */ + if (__glibc_unlikely (map->l_proxy)) + map = map->l_real; + result = GLRO(dl_lookup_symbol_x) (name, map, &ref, map->l_local_scope, vers, 0, flags, NULL); }