From patchwork Tue Jul 25 08:44:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Tesarik X-Patchwork-Id: 13326130 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5BC2C001DF for ; Tue, 25 Jul 2023 08:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QRWIkGvPkN5KFTIPuWQch7QUE/ICFPF58Jnuixvl+uI=; b=g30wPMmocfdaTu 6LvXabY3qhRBTYaQZHjs5pdNM3b/UrdSd8tlnaytEzevrqVfONfmDInxpA7XOLY+zTg2Vkn0DTXTI wVRQBb4hVYfL7aPWVe3K9j6ELgmRS6tvXgIpYq3ROsXLiR/YdhpX/Cm2D79gC814w0tsDRAEa546x wAZbtpe/DZwgutC+2hJKKaaSg7IEQwlPEejbis4uLXuKu0UDrU6w3Qb6/EbpnAQQ6tPviV+0FFbh+ KRQrU5KSZIb8KH0L0iNvRgCgcgX3lURntoHE+MJ1/cMNbM/0YevCbw5qDOMMLgF5ZAy+pwK7FEyib kOg/tHwRH7d/cPGwwDqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qODfl-006nxD-2j; Tue, 25 Jul 2023 08:45:37 +0000 Received: from [14.137.139.23] (helo=frasgout11.his.huawei.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qODfg-006nup-10 for linux-riscv@lists.infradead.org; Tue, 25 Jul 2023 08:45:33 +0000 Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4R99LB0ZLBz9xrp2 for ; Tue, 25 Jul 2023 16:34:10 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.48.128.235]) by APP2 (Coremail) with SMTP id GxC2BwB3Ijlwi79kXB38BA--.63760S5; Tue, 25 Jul 2023 09:45:14 +0100 (CET) From: Petr Tesarik To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Li Huafei , Liao Chang , Masahiro Yamada , Alyssa Ross , Nick Desaulniers , Ricardo Ribalda , Kees Cook , Heiko Stuebner , Li Zhengyu , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Cc: Roberto Sassu , petr@tesarici.cz Subject: [PATCH v1 3/3] riscv/purgatory: do not link with string.o Date: Tue, 25 Jul 2023 10:44:27 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: GxC2BwB3Ijlwi79kXB38BA--.63760S5 X-Coremail-Antispam: 1UD129KBjvJXoWxJrWfuw15GrWfGF4xXw18Krg_yoW8tw1Dpa yxKayDK3s8Aw1kKrZ7XF1Uuw17Z3yUKrWFqF42grW5AFy5JF9IvryfXrWDAFWUJr1Ik3s8 AryIgFyUt3WFkwUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI 8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwAC jcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka0x kIwI1lc7CjxVAaw2AFwI0_Jw0_GFylc7CjxVAKzI0EY4vE52x082I5MxAIw28IcxkI7VAK I48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7 xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xII jxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfUnku4UUUUU X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230725_014532_625090_5BC8AAEE X-CRM114-Status: UNSURE ( 9.05 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Petr Tesarik Linking with this object file it makes kexec_file_load(2) fail with: kexec_image: Unknown rela relocation: 20 kexec_image: Error loading purgatory ret=-8 This is R_RISCV_GOT_HI20, generated by the linker to handle references to the global variable _ctype from strcasecmp() and strncasecmp(). Rather than implementing GOT for the purgatory, remove the object file, because it is not needed by the purgatory code. Fixes: 838b3e28488f ("RISC-V: Load purgatory in kexec_file") Signed-off-by: Petr Tesarik Cc: Li Zhengyu Cc: stable@vger.kernel.org --- arch/riscv/purgatory/Makefile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/riscv/purgatory/Makefile b/arch/riscv/purgatory/Makefile index dc20e166983e..497bb72b6ba8 100644 --- a/arch/riscv/purgatory/Makefile +++ b/arch/riscv/purgatory/Makefile @@ -1,15 +1,12 @@ # SPDX-License-Identifier: GPL-2.0 OBJECT_FILES_NON_STANDARD := y -purgatory-y := purgatory.o sha256.o entry.o string.o ctype.o memcpy.o memset.o +purgatory-y := purgatory.o sha256.o entry.o ctype.o memcpy.o memset.o purgatory-y += strcmp.o strlen.o strncmp.o targets += $(purgatory-y) PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) -$(obj)/string.o: $(srctree)/lib/string.c FORCE - $(call if_changed_rule,cc_o_c) - $(obj)/ctype.o: $(srctree)/lib/ctype.c FORCE $(call if_changed_rule,cc_o_c) @@ -32,7 +29,6 @@ $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE $(call if_changed_rule,cc_o_c) CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY -CFLAGS_string.o := -D__DISABLE_EXPORTS CFLAGS_ctype.o := -D__DISABLE_EXPORTS # When profile-guided optimization is enabled, llvm emits two different @@ -83,9 +79,6 @@ CFLAGS_purgatory.o += $(PURGATORY_CFLAGS) CFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_sha256.o += $(PURGATORY_CFLAGS) -CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE) -CFLAGS_string.o += $(PURGATORY_CFLAGS) - CFLAGS_REMOVE_ctype.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_ctype.o += $(PURGATORY_CFLAGS)