Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp659957rdg; Wed, 11 Oct 2023 01:37:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMDJMAcl8EXEPdRgkoRoLf75cjvII7Kge4JXMXNli6aq9JMVdK1A1/aigA2gHyvOCS0ceZ X-Received: by 2002:a05:6358:9485:b0:135:46d9:12f7 with SMTP id i5-20020a056358948500b0013546d912f7mr18522880rwb.26.1697013424361; Wed, 11 Oct 2023 01:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697013424; cv=none; d=google.com; s=arc-20160816; b=sh/gEupWnH0a1rQaYiZmSjSVAho+vFzDXimwde2G6v7TBxp9Y3Rnjn7OJyjN1Ev4Kk R7MOQpdQhfDxe2878O3M+1iXSF4Rk1AuW46Sv2gpvZnilYsdWLlpZ5u3pbbX+jOHOHoe nPpstlxJnHwqRa75zDMAjjIA8aWX67ryochhpxeGVklGfLgvLftIxE/QNr6ZhSOBeRSi 45eH4UEPm+dr8q1+QmJehuPbzfmCM7+4lE2Y21k1TStqTaoaPqgeBRXRvps/1O1fBGA3 79P620Jji5G6g57G9FyNtiazpr4/1BUvUsabTzHopqL82vHEZpzf7oAmgn6gubo+gilq jGEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=e12JwzCEw+EC6YVE/g3DVUHyLDjdVNVsMT22TZvcnAo=; fh=DlYutkg/6Wkat5B72kLfp99kToTYZ2djuWDJ1GjZ1/g=; b=Ko7/wlVuBCK1zxl97TR1OAEOcWyvMDHerUHIrGbC7peEtbuVbZ//+xlo9py/EivWqN /rZ0OgFFpB6SGZcB+LrJJxbvP0H2uPvulolS5BSM4jL5Ampcm0ie2xicjHFpLU7u/Kkc 2QPWp0ANi2SQ2DN9nMzQ86Q3LRpOjw4eurWb7pwTsvK/G3FMn23tJGCNew7k5mCn1UBY hpQ4FZYEcbNTdcuaQwR/ml1ZKF4rfnQPY+gE+2C7vpHBsg9g5TSd1H8GWZ5r19BmCeIm gcY0/bcdJoJ+3vrND9CTQ4+/c0fuWi2061wCvm4RgIulSB9JEOlFIkEeWbN4jQ9rfmaf +aXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id z64-20020a633343000000b0059c78eb3fe7si3080143pgz.838.2023.10.11.01.37.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 01:37:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 091BD808D29A; Wed, 11 Oct 2023 01:36:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230393AbjJKIfn (ORCPT + 99 others); Wed, 11 Oct 2023 04:35:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbjJKIfm (ORCPT ); Wed, 11 Oct 2023 04:35:42 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2042D93 for ; Wed, 11 Oct 2023 01:35:38 -0700 (PDT) X-QQ-mid: bizesmtp71t1697013251tdcqqafe Received: from localhost.localdomain ( [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 11 Oct 2023 16:34:09 +0800 (CST) X-QQ-SSF: 01200000000000B0B000000A0000000 X-QQ-FEAT: FwowAM4HOqAVKxvoHOg+FFtkzyhqthXdQT4dyvq8RM0ldk9sx097/DTTVtTym zDrumLi3wKzCr8HeAtYLjJAO0L0+aIbGeOa415C5O9jPe7FMnKkoUVvHuiA9aKuYc+9Q1aM 9cJ/snUP8/szBAD7Bjs3eaWzuqEX+BnI7N+51e2OV79N001z7CTBNMWbJqV+bykxn7ic2Q7 RRHq54a8wsMzE6aZmUluVyilqnAsv/dg/rJUBkGm4OBESBJw3+EzrA5i0dRI+0hK+/Dazvv F6v2yTOubJMkx7Sf6/j1qLEQN3zoG54wpS3sggddPKE3seMGmKHz2Dx4zAl25vrsVzJFfqU bs1DClkTvFRJjSLK+rmaGFnDXt4enoq7xPY3bzlojOIb1ZqDxL5jep7gSIHFg== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 10839386821577447536 From: Song Shuai To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, conor.dooley@microchip.com, lihuafei1@huawei.com, songshuaishuai@tinylab.org, petr.tesarik.ext@huawei.com, duwe@suse.de, ribalda@chromium.org, akpm@linux-foundation.org, keescook@chromium.org, hi@alyssa.is, heiko@sntech.de, alexghiti@rivosinc.com, schwab@suse.de Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org Subject: [PATCH 2/2] riscv: kexec: Remove -fPIE for PURGATORY_CFLAGS Date: Wed, 11 Oct 2023 16:31:32 +0800 Message-Id: <20231011083132.2428720-3-songshuaishuai@tinylab.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20231011083132.2428720-1-songshuaishuai@tinylab.org> References: <20231011083132.2428720-1-songshuaishuai@tinylab.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz4a-0 X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 01:36:19 -0700 (PDT) With CONFIG_RELOCATABLE enabled, KBUILD_CFLAGS had a -fPIE option and then the purgatory/string.o was built to reference _ctype symbol via R_RISCV_GOT_HI20 relocations which can't be handled by purgatory. As a consequence, the kernel failed kexec_load_file() with: [ 880.386562] kexec_image: The entry point of kernel at 0x80200000 [ 880.388650] kexec_image: Unknown rela relocation: 20 [ 880.389173] kexec_image: Error loading purgatory ret=-8 So remove the -fPIE option for PURGATORY_CFLAGS to generate R_RISCV_PCREL_HI20 relocations type making puragtory work as it was. Fixes: 39b33072941f ("riscv: Introduce CONFIG_RELOCATABLE") Signed-off-by: Song Shuai --- arch/riscv/purgatory/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/riscv/purgatory/Makefile b/arch/riscv/purgatory/Makefile index 9e6476719abb..982fc8e77108 100644 --- a/arch/riscv/purgatory/Makefile +++ b/arch/riscv/purgatory/Makefile @@ -81,6 +81,10 @@ ifdef CONFIG_CFI_CLANG PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_CFI) endif +ifdef CONFIG_RELOCATABLE +PURGATORY_CFLAGS_REMOVE += -fPIE +endif + CFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_purgatory.o += $(PURGATORY_CFLAGS) -- 2.20.1