From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Wed, 03 Jan 2024 20:46:57 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rL7Cb-002V08-2L for lore@lore.pengutronix.de; Wed, 03 Jan 2024 20:46:57 +0100 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rL7Ca-00044h-7v for lore@pengutronix.de; Wed, 03 Jan 2024 20:46:57 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dPrdQMgi9QKe1VKiD1yQbDgzsz/eeyW1Q/tBrQvVFrk=; b=RJY5lbFaf3tjuY/0qHnnu8HEbe 2mzxN/yz/W+3d2E3IQ99VYGBR12fR4RR9iCeRL/6xCVSAux9NS2okLR7LSKbPfxAf49tuWVPUGhXW mVGeH3+nRhd80gjuYXS2auCvYYgQBpxh0T0Q7u9V6JXiN1cqlo+nVCKl/ae7OEkDg/P7nafk4Bp2r 1pCK/rV7CsM1az1mdv8qnF+DnZeQ/iVK2SYVEGOQ/NBFdamHqbK1GOWIC0Xji7sRrYeiMlFUa801U hW3A1F8rSrGcdxqp6seBp5v7ehAoWIBPvqrWw7+Mji7EkZdtn2TRKsEAkBfxRXwO6bApSwfquQOkj kpTI5SuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rL7BV-00Bw6h-1O; Wed, 03 Jan 2024 19:45:49 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rL60z-00Bh1I-2n for barebox@lists.infradead.org; Wed, 03 Jan 2024 18:30:58 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rL60y-0001Ot-OD; Wed, 03 Jan 2024 19:30:52 +0100 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rL60y-000AsV-Ba; Wed, 03 Jan 2024 19:30:52 +0100 Received: from localhost ([::1] helo=dude05.red.stw.pengutronix.de) by dude05.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1rL5k3-001j4X-1V; Wed, 03 Jan 2024 19:13:23 +0100 From: Ahmad Fatoum To: barebox@lists.infradead.org Cc: Ahmad Fatoum Date: Wed, 3 Jan 2024 19:12:16 +0100 Message-Id: <20240103181312.409668-57-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103181312.409668-1-a.fatoum@pengutronix.de> References: <20240103181312.409668-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240103_103053_910465_4633B533 X-CRM114-Status: GOOD ( 12.80 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-6.3 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH 056/112] ARM64: runtime-offset: make get_runtime_offset fully PIC X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.pengutronix.de) get_runtime_offset returns the offset that needs to be added onto code addresses to arrive at the runtime address. This is 0 after code relocation and the function calculates it by keeping a reference to _text and substituting it from the actual _text address, which is found out in a position-independent manner. For enabling barebox PBL text section to be mappable W^X, we need to avoid relocation entries within code, so let's move the runtime offset into the data section, which is always mapped writable. As ldr has only a 4K range for label references, we switch to ldr_l, which has a 4G range. Signed-off-by: Ahmad Fatoum --- arch/arm/lib64/runtime-offset.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/lib64/runtime-offset.S b/arch/arm/lib64/runtime-offset.S index 822e323c142e..b10c104b4dd0 100644 --- a/arch/arm/lib64/runtime-offset.S +++ b/arch/arm/lib64/runtime-offset.S @@ -11,10 +11,12 @@ */ ENTRY(get_runtime_offset) adr x0, _text - ldr x1, linkadr + ldr_l x1, linkadr subs x0, x0, x1 ret +ENDPROC(get_runtime_offset) +.section ".data.runtime_offset","a" .align 3 linkadr: /* @@ -24,4 +26,3 @@ linkadr: * use _text here since that is 0x0 and is correct without relocation. */ .quad _text -ENDPROC(get_runtime_offset) -- 2.39.2