From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 1AC963858D1E for ; Wed, 21 Dec 2022 20:15:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1AC963858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x635.google.com with SMTP id bj12so103825ejb.13 for ; Wed, 21 Dec 2022 12:15:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jJ/Rfg9LxuwzflWkGs4MuXrBQgw7MQvHAMBVfRlQpJA=; b=Deh+a0lheVReHjLwwPTv10WmS/RgPygVRUJ8ohwDHrtx+X/3h4sDZZkag6rJnwNPtM sc2JxIXZ1tKrPmWGbkt2jdGORzvPBGlkOZD0m1hA+tomew6OsiNelPMSTzqMEBo2EOzW hopLvLPk6liipCl7h+8AUFIJDaOZsWYkd522Vq2DUlwWGSB8PrHfrvj/SMaMgoYtkbSm 0wKy0W55Gt2RjadAu8tMr0PgSGEC8lxkKhwRg6yYiG4kirbaJhhP7KU8Jg/IwWCPN8YB futunDbcYCOtVJn0BdWp9DKAo4XJVB6hVLuqyhA5MPrEQ23xGzyLMcJTTVDu6f/HFopE paWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jJ/Rfg9LxuwzflWkGs4MuXrBQgw7MQvHAMBVfRlQpJA=; b=uDNiLsnA8cR6TxcxkwvGfILLUlGPfjPdJnZaiPSfrns1dJ+SVPKQIF8QkVhBgeF1XG BHM269muM2twAeAS8Gl6o9s3XSENjgyTmqn2iISAZgl8bl8kLaDUf7QNo1yp6EupME7C faNjZU0Qq2+qwdjHZkSJZ+bOR5I5C7b8snD/RZOQq9Wier2jkT3q4KRqlAlvreuvUGz5 7PEEHysynNcVbAylXV6zoPzRx6mh/gVmBd/2HOBaJQszHeNYteIFixdCv+zrdJmG/dvd 9edhWN35v+kRU9snAu5ppoSqt37TgMhVWH+w0b07q8tigbYs+ADKxE73tvZmG+wuKayh x2+w== X-Gm-Message-State: AFqh2kp1+PrC9pr8tSEtRMJ63Wz88LkBWfwsLg6ErYSdnEESTW7JNj5B tW7dAWqaFb8c5AEs2OreZ2MGaHtxOHqtU5jYXaY= X-Google-Smtp-Source: AMrXdXvhagiZOG+Yq0A4ZKTkE5YoM4Pv4nFmftwOxchj0Pa6LxZU/UfY+zNVrWd5KesFiM/eU1Y+ijNxhWMVAOHxTIY= X-Received: by 2002:a17:906:3398:b0:7c0:efb6:8744 with SMTP id v24-20020a170906339800b007c0efb68744mr315186eja.267.1671653734939; Wed, 21 Dec 2022 12:15:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Lad, Prabhakar" Date: Wed, 21 Dec 2022 20:15:08 +0000 Message-ID: Subject: Re: [RFC PATCH] ld/emulparams: elf32lriscv-defs: Add support tune the text segment start address To: Nelson Chu Cc: Palmer Dabbelt , jeffreyalaw@gmail.com, i@maskray.me, prabhakar.mahadev-lad.rj@bp.renesas.com, Andrew Waterman , Jim Wilson , binutils@sourceware.org, Chris.Paterson2@renesas.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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: Hi Nelson, Thank you for the feedback. On Wed, Dec 21, 2022 at 1:24 PM Nelson Chu wrote: > > On Tue, Dec 20, 2022 at 5:33 AM Palmer Dabbelt wrote: > > > > On Mon, 19 Dec 2022 01:11:13 PST (-0800), prabhakar.csengg@gmail.com wrote: > > > Hi Jeff, > > > > > > On Mon, Dec 19, 2022 at 5:00 AM Jeff Law wrote: > > >> > > >> > > >> > > >> On 12/18/22 15:44, Lad, Prabhakar via Binutils wrote: > > >> > Hi Fangrui, > > >> > > > >> > Thank you for the feedback. > > >> > > > >> > On Sun, Dec 18, 2022 at 6:24 AM Fangrui Song wrote: > > >> >> > > >> >> 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 > > > > I'm never great with shell expansion, what does the "+x" do here? > > I think it should be similar to what nds32 did in the > ld/emulparams/nds32elf_linux.sh, but I'm not really sure how it works. > When should the DEFAULT_TEXT_START_ADDR be defined? Maybe when > configure or make, not sure about that. But at least I only see the > changes in nds32, all of the other targets won't do that, so this must > be a handy little trick, but there are always other ways to do the DEFAULT_TEXT_START_ADDR needs to be exported in the shell before doing configure && make.. For example for testing I bbappended the binutils yocto recipe and exported the variable in do_configure() so that it picks up the new offset. > same things - for example, what maskray said should be the general way > to do. I don't have any opinion on this change, if it won't break the > general build, then probably acceptable. Just that it seems need to > introduce the DEFAULT_TEXT_START_ADDR or whatever configure options, > so this isn't only be the riscv gnu ld's issue, this will also be the > issue of lld, so if the maintainers of lld already have some > suggestions, then it will definitely worth to referring to. > Is there a mailing list for lld so that we could include them in this mail thread (I couldn't find one)? Cheers, Prabhakar