From patchwork Mon Jun 1 22:18:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 39414 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 A15E13840C16; Mon, 1 Jun 2020 22:18:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A15E13840C16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1591049919; 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=BX2qAWZaTokmIwqm8t5K/o5kyaQI7HvvN2I+DisV4AWouiHzZ29GnSlSMp+SrKKyC sWMecVdU7F7VrS83MFgBeukelXCt3MHxIBMD+CdEaZMequseYKcoXCdqyQ9+18K+99 aPkU7De85JXKsR2Cmm6on/1a6M5ieXMnWfiMJLOg= 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.87.133]) by sourceware.org (Postfix) with ESMTPS id 2DBE538708E1 for ; Mon, 1 Jun 2020 22:18:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2DBE538708E1 Received: from mailhost.synopsys.com (sv2-mailhost1.synopsys.com [10.205.2.133]) (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 17760C008F; Mon, 1 Jun 2020 22:18:34 +0000 (UTC) Received: from vineetg-Latitude-7400.internal.synopsys.com (unknown [10.13.183.89]) by mailhost.synopsys.com (Postfix) with ESMTP id 591F5A025E; Mon, 1 Jun 2020 22:18:33 +0000 (UTC) X-SNPS-Relay: synopsys.com To: libc-alpha@sourceware.org Subject: [PATCH v2 2/2] ARC/dl-runtime helper macros Date: Mon, 1 Jun 2020 15:18:23 -0700 Message-Id: <20200601221823.17861-3-vgupta@synopsys.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601221823.17861-1-vgupta@synopsys.com> References: <20200601221823.17861-1-vgupta@synopsys.com> MIME-Version: 1.0 X-Spam-Status: No, score=-16.1 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 Reviewed-by: Adhemerval Zanella --- 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; +}