From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by sourceware.org (Postfix) with ESMTP id 15C5C384FE83 for ; Fri, 16 Dec 2022 21:43:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 15C5C384FE83 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bp.renesas.com X-IronPort-AV: E=Sophos;i="5.96,251,1665414000"; d="scan'208";a="146468536" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 17 Dec 2022 06:43:19 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id A55DA40029BD; Sat, 17 Dec 2022 06:43:17 +0900 (JST) From: Lad Prabhakar To: Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu , binutils@sourceware.org Cc: Prabhakar , Lad Prabhakar Subject: [RFC PATCH] ld/emulparams: elf32lriscv-defs: Add support tune the text segment start address Date: Fri, 16 Dec 2022 21:43:10 +0000 Message-Id: <20221216214310.13155-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On the RISC-V architecture the TEXT_START_ADDR defaults to 0x10000. On some RISC-V platforms we want to set this offset to something else. So this patch provides a way to tune the text segment start address. elf32lriscv-defs.sh now checks for DEFAULT_TEXT_START_ADDR variable and if being set it overrides TEXT_START_ADDR to the value set by DEFAULT_TEXT_START_ADDR or else defaults to 0x10000. Renesas RZ/Five RISC-V SoC has Instruction local memory and Data local memory (ILM & DLM) which maps between region 0x30000 - 0x4FFFF. When the virtual address falls in this range the MMU doesn't trigger a page fault and assumes the virtual address as physical address and causes undesired behaviours of statically applications/libraries. Hence introduce an option to tune the TEXT_START_ADDR. Signed-off-by: Lad Prabhakar --- Hi All, This patch is inspired from the current ld/emulparams/nds32elf_linux.sh file where similar approach is being used and DEFAULT_TEXT_START_ADDR variable is checked to adjust the TEXT_START_ADDR for the platform. I am not sure if this is the right approach the above issue has been discussed on the ML [0]. [0] https://sourceware.org/pipermail/binutils/2022-November/124813.html Cheers, Prabhakar --- ld/emulparams/elf32lriscv-defs.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ld/emulparams/elf32lriscv-defs.sh b/ld/emulparams/elf32lriscv-defs.sh index b823cedacab..026aef4714b 100644 --- a/ld/emulparams/elf32lriscv-defs.sh +++ b/ld/emulparams/elf32lriscv-defs.sh @@ -27,7 +27,11 @@ case "$target" in esac IREL_IN_PLT= -TEXT_START_ADDR=0x10000 +if [ -z ${DEFAULT_TEXT_START_ADDR+x} ]; then + TEXT_START_ADDR=0x10000 +else + TEXT_START_ADDR=$DEFAULT_TEXT_START_ADDR +fi MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" -- 2.17.1