From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 dcvr.yhbt.net (Postfix) with ESMTPS id 8D3641F55B for ; Fri, 29 May 2020 21:21:57 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87AA8388B014; Fri, 29 May 2020 21:21:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87AA8388B014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1590787316; bh=/Ha0VV5+5zRNBmkLTCHWM2OmlnDpcBceZnj+FZ4T/r8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=eY2J4LC6bmeyi6oT/6BQdJnBCaAEQ4cmKka6c3luD6HGEBuTgsc2e+C7Fo5L5R6WJ 6nW8lhzALq3ZRr+Xoj7n9EqaACytM2MGgLv2Hp7+WEjZxZoJyGYWsQVE5JiwnVZTrv 1uFo1R6DkqYb0pXtIWej0z5+yCzMCuo0xxnD/lbs= Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.73.133]) by sourceware.org (Postfix) with ESMTPS id 669F23870888 for ; Fri, 29 May 2020 21:21:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 669F23870888 Received: from mailhost.synopsys.com (sv1-mailhost2.synopsys.com [10.205.2.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id C83A54094C; Fri, 29 May 2020 21:21:50 +0000 (UTC) Received: from vineetg-Latitude-7400.internal.synopsys.com (unknown [10.13.183.89]) by mailhost.synopsys.com (Postfix) with ESMTP id 7F4A3A0073; Fri, 29 May 2020 21:21:50 +0000 (UTC) X-SNPS-Relay: synopsys.com To: libc-alpha@sourceware.org Subject: [PATCH 2/2] ARC/dl-runtime helper macros Date: Fri, 29 May 2020 14:21:42 -0700 Message-Id: <20200529212142.19869-2-vgupta@synopsys.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200529212142.19869-1-vgupta@synopsys.com> References: <9ec385e5-3427-f3ac-f4c8-73f0c98aaa97@linaro.org> <20200529212142.19869-1-vgupta@synopsys.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Vineet Gupta via Libc-alpha Reply-To: Vineet Gupta Cc: Vineet Gupta , linux-snps-arc@lists.infradead.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This is purely for review purposes to attest the interface defined in prior patch --- sysdeps/arc/dl-runtime.h | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 sysdeps/arc/dl-runtime.h diff --git a/sysdeps/arc/dl-runtime.h b/sysdeps/arc/dl-runtime.h new file mode 100644 index 000000000000..529d49f5d0a1 --- /dev/null +++ b/sysdeps/arc/dl-runtime.h @@ -0,0 +1,42 @@ +/* Helpers for On-demand PLT fixup for shared objects. ARC version. + Copyright (C) 2017-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +/* PLT jump into resolver passes PC of PLTn, while _dl_fixup expects the + address of corresponding .rela.plt entry. + + - @plt0: runtime pc of first plt entry (DT_PLTGOT) + - @pltn: runtime pc of plt entry being resolved + - @size: size of .plt.rela entry (unused). */ +static inline uintptr_t +reloc_index (uintptr_t plt0, uintptr_t pltn, size_t size) +{ + unsigned long int idx = (unsigned long)pltn - (unsigned long)plt0; + + /* PLT trampoline is 16 bytes. */ + idx /= 16; + + /* Exclude PLT0 and PLT1. */ + return idx - 2; +} + +static inline uintptr_t +reloc_offset (uintptr_t plt0, uintptr_t pltn) +{ + size_t sz = sizeof (ElfW(Rela)); + return reloc_index(plt0, pltn, sz) * sz; +} -- 2.20.1