From patchwork Sat May 30 02:00:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 39386 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 36DAC388A83A; Sat, 30 May 2020 02:00:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36DAC388A83A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1590804058; 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=GD72Dg9IJ4OBjioJr1KXE7fQ0L0eN+PeHC1zo2k19UfUZo0kHWB0OK5kMtLiDJJZt 34tI2QPMG2hDHpvk2bKgyzYwjRebcD2Z867b6+gsi4bbt3KdrlM3ZUHyrOd8ZBFg3j HGTtd9irMhVVJTQ2pbHa6sflYfPiWVrnlecPIGZY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.73.133]) by sourceware.org (Postfix) with ESMTPS id 189B1386EC5C for ; Sat, 30 May 2020 02:00:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 189B1386EC5C 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 4510C40956; Sat, 30 May 2020 02:00:51 +0000 (UTC) Received: from vineetg-Latitude-7400.internal.synopsys.com (unknown [10.13.183.89]) by mailhost.synopsys.com (Postfix) with ESMTP id 0403EA023A; Sat, 30 May 2020 02:00:50 +0000 (UTC) X-SNPS-Relay: synopsys.com To: libc-alpha@sourceware.org Subject: [PATCH 1/5] ARC/dl-runtime helper macros Date: Fri, 29 May 2020 19:00:43 -0700 Message-Id: <20200530020047.5490-2-vgupta@synopsys.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200530020047.5490-1-vgupta@synopsys.com> References: <20200530020047.5490-1-vgupta@synopsys.com> MIME-Version: 1.0 X-Spam-Status: No, score=-16.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, 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: Vineet Gupta via Libc-alpha From: Vineet Gupta 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; +}