From patchwork Thu Apr 11 16:42:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 13626388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 414BBC4345F for ; Thu, 11 Apr 2024 16:42:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C41956B00AB; Thu, 11 Apr 2024 12:42:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF1746B00B8; Thu, 11 Apr 2024 12:42:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB8FF6B00B9; Thu, 11 Apr 2024 12:42:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8D8C86B00AB for ; Thu, 11 Apr 2024 12:42:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4A6DDC0C4F for ; Thu, 11 Apr 2024 16:42:53 +0000 (UTC) X-FDA: 81997820226.22.5D0806F Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by imf07.hostedemail.com (Postfix) with ESMTP id 7131B4000B for ; Thu, 11 Apr 2024 16:42:51 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=U9h87E1L; spf=pass (imf07.hostedemail.com: domain of shorne@gmail.com designates 209.85.128.43 as permitted sender) smtp.mailfrom=shorne@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712853771; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2I/kZba/eZof5I7oj6voMjU9Ljlm5m0ug+oOrZQT5kw=; b=r+nHBCHKwWE5+osyGS5t0AZrP8THfspCGvEdgjBegoI7P/6MBCa/tDgtQfusEDwez9Jmpp JWwY8ZkaAhidYBHwMep3gJseQgzacp5HoJzugr10uxPwuVBAcLyPJFrYe9vtoTKud5/u5l m6y/Uu0LdJYCAXdzBVN1JsFUo71+uLk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712853771; a=rsa-sha256; cv=none; b=SoGuyGLX8c1nODOZrtRe0/nDGMAQmUzLUrDb6wTLuCdvSe9EhAYXgXzegexx6JF5kkLHL2 yR8SBL1ZErhmAxNexuDRqqhpf6mS7O5RMKP2+leBriv6sf7SxZxo9HJA6yxbDWWwdmkN64 WNl6eN909iYbnCZtRLXDDZZIMQUP60U= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=U9h87E1L; spf=pass (imf07.hostedemail.com: domain of shorne@gmail.com designates 209.85.128.43 as permitted sender) smtp.mailfrom=shorne@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-416c4767b07so548485e9.0 for ; Thu, 11 Apr 2024 09:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712853770; x=1713458570; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2I/kZba/eZof5I7oj6voMjU9Ljlm5m0ug+oOrZQT5kw=; b=U9h87E1Lu+DdqZ9J4Om8ZC7RbijEEfy6p6VGK3oNYbwZtNynHQQBBPXv25BQIRmHoF czPFQzpe6+ruiLjedVLhGfn5AlbLyGJasXn9au8wQ/jOzvKjNP63yrujC/Qg4NImFva+ nA0Qu+3U8tbonuRWi9uiBq/cvhOgW1gjRelKRswf2yUeeK7KhKv6Dm5mbvN/o7juYO3+ xQi1I9RCLjP6G28KWeoDZsTY/DBeAksPknjUEZI/oHUJ16yewoOYaSRu/7GQf50MmH4b QkBf+pTDDtXL3zsDylzzBulbyESE4LijnNK7+lASzL6hlvqGHdBQqMpTKYn3cmxsENhO Ih2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712853770; x=1713458570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2I/kZba/eZof5I7oj6voMjU9Ljlm5m0ug+oOrZQT5kw=; b=AkWid0zInIHRkn60QC3o+V4uaMptaG49bWvfslXFjSm0Ak06Pdv7i6aSVKVMkhBHIz gY4UhlYOycUswu6cOIcjajFhyLjWPsruZLr4Ow3kw5EM8P6PJ4F1u8J0zOXzSKGDDL+T ZD/7Pa0ZsnrghmVkrMi2OiciMKU8tHCz6jCzHWE3BlBHpv3ROR5pgh+mzJofc219goMn 4EfPvjJaEqaPwrzG4wdGCpA603erA0917vR4sB4IUKha/ciwkaSMn29tC3U5qd4OBUth NoPrPwSfRoZCT/2er8kg5Jn7GDf3jh9gwh/bnoCxWFrKzgxxN1DqRxUXEDInhaL88CJi nFUg== X-Forwarded-Encrypted: i=1; AJvYcCVpXcVLgnddCvuRCitwFWx0d3vyy79E4wABmvaqJS6M+ogYTcyo7RuiO+pf2+ntX2aXIsoBm5J7NdrwjIsoBp5l9+E= X-Gm-Message-State: AOJu0YwgbB7I7kI8QlVWqh9eLbFYZKAuroVGpMvEd4jG8m+Ex4NVMfx9 at/C0zbL2zaRux9ISK+7pMMetpdAGOVM3qEwWy5vlxEPAwPYqKZM X-Google-Smtp-Source: AGHT+IEaWmPJXXfZ9p+0M5IfDFkfmjGp+xfzxESQfhvmLoMbC9tFCWL1bugJU8jkLZtjkN44p/gBpg== X-Received: by 2002:a05:600c:3849:b0:416:b671:30cd with SMTP id s9-20020a05600c384900b00416b67130cdmr196532wmr.36.1712853769713; Thu, 11 Apr 2024 09:42:49 -0700 (PDT) Received: from localhost (cpc1-brnt4-2-0-cust862.4-2.cable.virginm.net. [86.9.131.95]) by smtp.gmail.com with ESMTPSA id bg25-20020a05600c3c9900b004162d06768bsm6060760wmb.21.2024.04.11.09.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 09:42:49 -0700 (PDT) From: Stafford Horne To: LKML Cc: Linux OpenRISC , Stafford Horne , Jonas Bonn , Stefan Kristiansson , Eric Biederman , Kees Cook , linux-mm@kvack.org Subject: [PATCH v2 1/2] openrisc: Define openrisc relocation types Date: Thu, 11 Apr 2024 17:42:31 +0100 Message-ID: <20240411164234.1997000-2-shorne@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411164234.1997000-1-shorne@gmail.com> References: <20240411164234.1997000-1-shorne@gmail.com> MIME-Version: 1.0 X-Stat-Signature: e7n668o3fmgd3n73pr6n5hwiub933nr6 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7131B4000B X-Rspam-User: X-HE-Tag: 1712853771-83144 X-HE-Meta: U2FsdGVkX1+4Fe1oVfLR3lz9f/xlJc7NBZOKx3Z6tDFw0opxQs27hWQSnSH1bFxGGMjEpe3gz07H05sXwJ5nEwiPbSZi+QTtQEw4AVagiybhYCQmE7BTpmS8U4fD87155WA+WFTIUfV+rA5vZCumKM3KNiwxd0R2WqfWl6k0PIUQoPht2tfEbpsHVlshfcUr4cZ8DDem2li3RWqPvrDm/8aGZsJ+QeNWBpLPzv1n+88wqEirwLkugAqE+fUnBbgUxDexhcibpD2krIzYHY63TPV+loj2rLt3OHoFZ2UTprDhe56Tal6/u3IOkQ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aj8JBtXd/8vu1h1qNuPEEUA30G+UgUGQ02waBkMvOHA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.358965, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This defines the current OpenRISC relocation types using the current R_OR1K_* naming conventions. The old R_OR32_* definitions are left for backwards compatibility. Note, the R_OR32_VTENTRY and R_OR32_VTINHERIT macros were defined with the wrong values the have always been 7 and 8 respectively, not 8 and 7. They are not used for module loading and I have updated them to use the correct values. Signed-off-by: Stafford Horne --- arch/openrisc/include/uapi/asm/elf.h | 75 ++++++++++++++++++++++++---- arch/openrisc/kernel/module.c | 8 +-- 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/arch/openrisc/include/uapi/asm/elf.h b/arch/openrisc/include/uapi/asm/elf.h index 6868f81c281e..441e343f8268 100644 --- a/arch/openrisc/include/uapi/asm/elf.h +++ b/arch/openrisc/include/uapi/asm/elf.h @@ -34,15 +34,72 @@ #include /* The OR1K relocation types... not all relevant for module loader */ -#define R_OR32_NONE 0 -#define R_OR32_32 1 -#define R_OR32_16 2 -#define R_OR32_8 3 -#define R_OR32_CONST 4 -#define R_OR32_CONSTH 5 -#define R_OR32_JUMPTARG 6 -#define R_OR32_VTINHERIT 7 -#define R_OR32_VTENTRY 8 +#define R_OR1K_NONE 0 +#define R_OR1K_32 1 +#define R_OR1K_16 2 +#define R_OR1K_8 3 +#define R_OR1K_LO_16_IN_INSN 4 +#define R_OR1K_HI_16_IN_INSN 5 +#define R_OR1K_INSN_REL_26 6 +#define R_OR1K_GNU_VTENTRY 7 +#define R_OR1K_GNU_VTINHERIT 8 +#define R_OR1K_32_PCREL 9 +#define R_OR1K_16_PCREL 10 +#define R_OR1K_8_PCREL 11 +#define R_OR1K_GOTPC_HI16 12 +#define R_OR1K_GOTPC_LO16 13 +#define R_OR1K_GOT16 14 +#define R_OR1K_PLT26 15 +#define R_OR1K_GOTOFF_HI16 16 +#define R_OR1K_GOTOFF_LO16 17 +#define R_OR1K_COPY 18 +#define R_OR1K_GLOB_DAT 19 +#define R_OR1K_JMP_SLOT 20 +#define R_OR1K_RELATIVE 21 +#define R_OR1K_TLS_GD_HI16 22 +#define R_OR1K_TLS_GD_LO16 23 +#define R_OR1K_TLS_LDM_HI16 24 +#define R_OR1K_TLS_LDM_LO16 25 +#define R_OR1K_TLS_LDO_HI16 26 +#define R_OR1K_TLS_LDO_LO16 27 +#define R_OR1K_TLS_IE_HI16 28 +#define R_OR1K_TLS_IE_LO16 29 +#define R_OR1K_TLS_LE_HI16 30 +#define R_OR1K_TLS_LE_LO16 31 +#define R_OR1K_TLS_TPOFF 32 +#define R_OR1K_TLS_DTPOFF 33 +#define R_OR1K_TLS_DTPMOD 34 +#define R_OR1K_AHI16 35 +#define R_OR1K_GOTOFF_AHI16 36 +#define R_OR1K_TLS_IE_AHI16 37 +#define R_OR1K_TLS_LE_AHI16 38 +#define R_OR1K_SLO16 39 +#define R_OR1K_GOTOFF_SLO16 40 +#define R_OR1K_TLS_LE_SLO16 41 +#define R_OR1K_PCREL_PG21 42 +#define R_OR1K_GOT_PG21 43 +#define R_OR1K_TLS_GD_PG21 44 +#define R_OR1K_TLS_LDM_PG21 45 +#define R_OR1K_TLS_IE_PG21 46 +#define R_OR1K_LO13 47 +#define R_OR1K_GOT_LO13 48 +#define R_OR1K_TLS_GD_LO13 49 +#define R_OR1K_TLS_LDM_LO13 50 +#define R_OR1K_TLS_IE_LO13 51 +#define R_OR1K_SLO13 52 +#define R_OR1K_PLTA26 53 +#define R_OR1K_GOT_AHI16 54 + +/* Old relocation names */ +#define R_OR32_NONE R_OR1K_NONE +#define R_OR32_32 R_OR1K_32 +#define R_OR32_16 R_OR1K_16 +#define R_OR32_8 R_OR1K_8 +#define R_OR32_CONST R_OR1K_LO_16_IN_INSN +#define R_OR32_CONSTH R_OR1K_HI_16_IN_INSN +#define R_OR32_JUMPTARG R_OR1K_INSN_REL_26 +#define R_OR32_VTENTRY R_OR1K_GNU_VTENTRY +#define R_OR32_VTINHERIT R_OR1K_GNU_VTINHERIT typedef unsigned long elf_greg_t; diff --git a/arch/openrisc/kernel/module.c b/arch/openrisc/kernel/module.c index 532013f523ac..292f0afe27b9 100644 --- a/arch/openrisc/kernel/module.c +++ b/arch/openrisc/kernel/module.c @@ -39,16 +39,16 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, value = sym->st_value + rel[i].r_addend; switch (ELF32_R_TYPE(rel[i].r_info)) { - case R_OR32_32: + case R_OR1K_32: *location = value; break; - case R_OR32_CONST: + case R_OR1K_LO_16_IN_INSN: *((uint16_t *)location + 1) = value; break; - case R_OR32_CONSTH: + case R_OR1K_HI_16_IN_INSN: *((uint16_t *)location + 1) = value >> 16; break; - case R_OR32_JUMPTARG: + case R_OR1K_INSN_REL_26: value -= (uint32_t)location; value >>= 2; value &= 0x03ffffff;