From patchwork Thu Jan 19 22:11:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9527003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 600CB60459 for ; Thu, 19 Jan 2017 22:13:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E8B22866F for ; Thu, 19 Jan 2017 22:13:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4322728671; Thu, 19 Jan 2017 22:13:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_SORBS_SPAM, RDNS_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (unknown [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D90052866F for ; Thu, 19 Jan 2017 22:13:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cUKxA-0005ZL-Td; Thu, 19 Jan 2017 22:13:08 +0000 Received: from mail-wm0-f46.google.com ([74.125.82.46]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cUKx7-0005Tl-1g for linux-arm-kernel@lists.infradead.org; Thu, 19 Jan 2017 22:13:07 +0000 Received: by mail-wm0-f46.google.com with SMTP id c206so15657174wme.0 for ; Thu, 19 Jan 2017 14:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9Ckpx3PpesWI4yH0XqDTSNvNkR5jzV3As4bJUcL1DnQ=; b=PpBh1AXrO8H7BjjUqy7nsML0GWnyGLznbYkvtHW0zWLWyFperrU7WD+usuH/lOF1vn Cb0O+Nj8tEKiWUAD0nbBNf9J18EtJbF2NDJiPhxfuH6JmDCPnLlM5Ip/hkZNPPYCAqeV NGjlmfIF/mXuS25H5nOAnfE0tvZrEHgEqWcBk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9Ckpx3PpesWI4yH0XqDTSNvNkR5jzV3As4bJUcL1DnQ=; b=U66X7uLbNZEiCyVikYkXADhK3gClF9kHHQuiCw+cMhf9SNCwV1GbeofH3pXGjpHAZM RHQIXWVYxs8AEgmRJ8TPxdxkzK7ESpqUQomEo62c/ewx3R85Yg99kFpulmMa7f5SIp7V 3kHkrJ2KLxN74khWHVFW0TrZeKeHso1DbTs9Srzm623KR8Rp+Jc9Mkn8fMVSEV0oHv2I +viP/jpc7RX6FTdTlpz0JGERidw6daYU3C6V5iCyImeHZ3vYjCSiPeR6QJMNj26v/Aha B8ZQFCirJpf4mzVhHtnYRvmibGDkqQU3iW1bwB9lJQ3+VbnKIVex3TXSW+BTxYXSJfvh 9fAA== X-Gm-Message-State: AIkVDXKbW/BJmNdCmrDQ7OhVO3UMNeLnMZSKt+CP0m8Ttp3iFyyDBJtEJMpADCIXKCbmrsJf X-Received: by 10.28.126.11 with SMTP id z11mr801768wmc.13.1484863903292; Thu, 19 Jan 2017 14:11:43 -0800 (PST) Received: from localhost.localdomain ([196.72.229.125]) by smtp.gmail.com with ESMTPSA id f67sm1226947wmd.13.2017.01.19.14.11.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 14:11:42 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm: module: add support for R_ARM_REL32 relocations Date: Thu, 19 Jan 2017 22:11:32 +0000 Message-Id: <1484863892-5818-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170119_141305_243407_D6486D2E X-CRM114-Status: GOOD ( 11.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel , linux@armlinux.org.uk, nico@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for R_ARM_REL32 relocations in the module loader, which will be used by the modversions code when (if) it switches to using relative references to refer to CRC values. Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/elf.h | 1 + arch/arm/kernel/module.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h index d2315ffd8f12..d450a59ca121 100644 --- a/arch/arm/include/asm/elf.h +++ b/arch/arm/include/asm/elf.h @@ -50,6 +50,7 @@ typedef struct user_fp elf_fpregset_t; #define R_ARM_NONE 0 #define R_ARM_PC24 1 #define R_ARM_ABS32 2 +#define R_ARM_REL32 3 #define R_ARM_CALL 28 #define R_ARM_JUMP24 29 #define R_ARM_TARGET1 38 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index 4f14b5ce6535..29629fe02ce5 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c @@ -159,6 +159,10 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, *(u32 *)loc = offset & 0x7fffffff; break; + case R_ARM_REL32: + *(u32 *)loc += sym->st_value - loc; + break; + case R_ARM_MOVW_ABS_NC: case R_ARM_MOVT_ABS: offset = tmp = __mem_to_opcode_arm(*(u32 *)loc);