From patchwork Fri Dec 16 21:43:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar Mahadev Lad X-Patchwork-Id: 34093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1211796wrn; Fri, 16 Dec 2022 13:43:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5YkYmYemclUUJWdQEpqqy0dAeb99MBNY49URnyskal+BidKSj6exHmQFTBUrkd0+3J2dUW X-Received: by 2002:a05:6402:2b95:b0:460:5706:d1fa with SMTP id fj21-20020a0564022b9500b004605706d1famr27517193edb.18.1671227012979; Fri, 16 Dec 2022 13:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671227012; cv=none; d=google.com; s=arc-20160816; b=jiGgMs6M7xVSBCE0yECknqS/Bqj9yUVU2LHRt5Y5eih1UYph1U90OU8Tp+1JbJ/V4J 65to0LhwZFMoH+XWE+DZ/YU0a03+Yf0mYCj+T/fdx5bgyJedB+c+qrg74o2wf8FBeYXz uQAjNhUIQ9OchEVqbajBEYD6l3I9u0gLQwLSv8qhZ0Ebvf3sgfMOuog3EULGm/UvqdhJ yj9EIONsdHaKJ4g0JvSPwQYZQf+oIf/hLLIBh5ggYG3Fr8tTf8Y2Pl13GXiQZMgY4yAH aXuUWdbX09pyWq70BJFBKCudOyLwdWb7odEB/+607s4LdVPro9WuXnpAfIivABLujdlk W9ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id:date :subject:cc:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=au4Q5tK9M3EknlIxFPOZGYmwqjg9NDU5/4YvDJhK+8k=; b=EZ8HGbzClbSxw2bCSof7E6iCur+M30P9HqNNjIfvlbfA3NHEqBff8mMPFCa+4d+UTG XWimolEvjmDgats8INOVJzR4KyECkOqgnXsck24jTstlP8GuPHiOwmQFhi8ZZ1ZUV7P1 xsVZaET/3CeGHZsMGCx9nLfhsINDBW0BCcSKCta5aJ36mWwE+cfH758WcxtTdyDuBPZR OFsUEOaN5JmwL/DN20UiTtM667nHQic1jH7FmQJl4A2a+d8zURYl4ZKejemkhSjvuYyX SDAAP2Lo6SFbugN+Z9y3Prvb4QfewAaUIaH/F6AqG+5fAFdvX0rTeikntqDo/lCKgCty VS+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NV5zz5t8; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f18-20020a0564021e9200b00476ac0819ecsi1664487edf.426.2022.12.16.13.43.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 13:43:32 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NV5zz5t8; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1D4C383F0A7 for ; Fri, 16 Dec 2022 21:43:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1D4C383F0A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671227011; bh=au4Q5tK9M3EknlIxFPOZGYmwqjg9NDU5/4YvDJhK+8k=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=NV5zz5t8UMB4qFeQV7pfBqOclYIN9nqjGVZJWydUsxO68bRtyZSXGRatVkKIVef2D 3B1jsw8a4hU2QlhZfHcyOzju6/bidrFw6zLprVxdQswcm9XhzU/EkQR5oitXUq8qKT EQi/IRl2ZJ9GECTE10pWkSQdSePesnkG1MqhCMCc= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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) 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Lad Prabhakar via Binutils From: Prabhakar Mahadev Lad Reply-To: Lad Prabhakar Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752408536405382317?= X-GMAIL-MSGID: =?utf-8?q?1752408536405382317?= 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)"