From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by sourceware.org (Postfix) with ESMTPS id 53D8C3A01E1E for ; Sun, 18 Dec 2022 06:24:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 53D8C3A01E1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f47.google.com with SMTP id n65-20020a17090a2cc700b0021bc5ef7a14so6191747pjd.0 for ; Sat, 17 Dec 2022 22:24:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vIPv2mUnnDnxoHtmfIw7GYsA15P9Ts/xF2W8GHi/5E4=; b=rRTB/QjzO1WzBAAqD87s6UzBX1jdAn0aXEOU0vyBzxDf9D2aUUzJRFSP4U4hc8Iulq e/MUEqPJPbChGIR8aWCHyI4lL2HxeOLv3KEgstZqdb363IoSuIAbKClOz7aYyb542DGi YPWVEq9GpCACc7RKsIT64YYGGKsF/JaWqV8McK9p5y6mEfevJDkk8Rwr3K4Sojc+gATo Y8kjIcy6t0TU5apR9VToRWmEnoOi8VPnvsEPY9V58Z0Jlrldm+dzqs9hG/bFL5fpb//+ GitE3EfZ2LMY4QpiOhV0SKMlJoPFyZZOY/YoOYKrMuIaXtPdU/+KHNtRKFosLUH5Kb78 JT0Q== X-Gm-Message-State: AFqh2kpPQW6xvD48tP8280UE5f9ivaGYDmaCcgdDCaWA4QFYcQebVcYo V+Qw353WOFXntE1Brj87Zzc= X-Google-Smtp-Source: AMrXdXveS1nG9c/ywaaenjP0l5q57FZlG/3HAUP+QoRPnw/CmvYaXlmtYa9zDy4t9faAJ9R9uDEG/A== X-Received: by 2002:a17:902:e993:b0:189:e290:c65f with SMTP id f19-20020a170902e99300b00189e290c65fmr4320683plb.66.1671344646251; Sat, 17 Dec 2022 22:24:06 -0800 (PST) Received: from localhost ([2601:647:6300:b760:1779:923f:77a9:4a85]) by smtp.gmail.com with ESMTPSA id y2-20020a17090264c200b00190efb4071dsm4458992pli.160.2022.12.17.22.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 22:24:05 -0800 (PST) Date: Sat, 17 Dec 2022 22:24:04 -0800 From: Fangrui Song To: Lad Prabhakar Cc: Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu , binutils@sourceware.org, Prabhakar Subject: Re: [RFC PATCH] ld/emulparams: elf32lriscv-defs: Add support tune the text segment start address Message-ID: <20221218062404.cn75smc4pperrsd7@gmail.com> References: <20221216214310.13155-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20221216214310.13155-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 2022-12-16, Lad Prabhakar via Binutils wrote: >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 > Changing ld does not look like a good change to me. This tuning can be placed at the compiler driver side as that is the usual place to tune these things. We can ask users to specify -Wl,-Ttext-segment= (with lld use --image-base= instead) . If that is inconvenient, with Clang you can add the option to a configuration file (https://clang.llvm.org/docs/UsersManual.html#configuration-files). With GCC there may be an option to add a fragment to the default specs file.