From patchwork Tue Dec 15 18:44:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 41423 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 8C22738708EC; Tue, 15 Dec 2020 18:45:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C22738708EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608057921; 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=YPo3dK9HE5+H59OiceeHAQpNbuOiveI2e7eH2znzHo6dOQWHKfS7Oy7O80TtV7Fak 4DH7wCM+CMl+8DpNSEpn06oCeczFz5a3LBiWRAGntW/krqxDCqiWjjvyJTyJsEZX++ 5xpGbzu8bbdYoxE527TAkrZWSY14NQ2/YzecKUsk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by sourceware.org (Postfix) with ESMTPS id 88604387089D for ; Tue, 15 Dec 2020 18:45:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 88604387089D 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 519911F45621 for ; Tue, 15 Dec 2020 18:45:09 +0000 (GMT) To: libc-alpha Subject: [RFC][PATCH v6 17/20] dlsym, dlvsym should be able to look up symbols via DSO proxies Date: Tue, 15 Dec 2020 18:44:57 +0000 Message-Id: <20201215184500.25915-18-vivek@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201215184500.25915-1-vivek@collabora.com> References: <20201215184500.25915-1-vivek@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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); }