From patchwork Fri Dec 15 08:19:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 179093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9118927dys; Fri, 15 Dec 2023 00:19:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiz92U/ttk/1FL0cA3ltfoXWvf6ZRjm3ZSMWz/WB09FY48oyMT/1zlraU1mwNO5KnV8Hg+ X-Received: by 2002:a0c:cdc2:0:b0:67e:f4f8:3662 with SMTP id a2-20020a0ccdc2000000b0067ef4f83662mr4886155qvn.0.1702628360378; Fri, 15 Dec 2023 00:19:20 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1702628360; cv=pass; d=google.com; s=arc-20160816; b=VINNLduHEe/b7OE1ZiW6c/ToMuK6w72vUHktFKwQlD+C3GRk4LAdeDrHrgfGHhQwrj 3vY4APwzHtX+q9OqoDXTdySsJdYbR8vmdCIQgegKwxMBebAW86HG/i0tjXxRDzrkwR3t V6M1pmGs2FsM5R6v65rraV3li3uop/XuUWTqyqxPE7IBgxgTB5Jf9pjWTrFPkyx2WRyJ LEAvEjsZ9zflZJHcX4dVKjUhitivwJXrx4qdXp94l3scu+ZuQYqgnd5HAtp4dDI45U76 nLukeDaV7OMEUn7SnyiRs/nMkdRwbv7L4Egj91jQn/ilYotjkHpzOlk+aJaoBG9WqsC0 dvVA== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :subject:from:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=7QCC62hgIDnqPOJ3xtuBw4vBiiBUikjNN9uM396U+90=; fh=NLxAvL/bDfPg4AGOtxqvQlND8vazkZrNzKLY8+LAbBY=; b=yJ3OJeAdCTGGtESeoNd+nduGDwknzKTv61ssgHJxRGuy3HRG6e3rVmYxPzLSPUgYD3 T68ksPW0x1s4OwBw+7O/De75dbf81sHf/2/lALgNicS/1sZ3biVpUCBwqCM70pwWZ392 xH/xdnD0J81aPIW73gX8+JSrdGJoH80za94BmezZwG/CVVCHnbCYWZ1Vbx9d8PXNMWfS J2OuCM3yEMWs5sTX2p2T0B3GqrjfFt09J33LJ4k78bedrwyxm6J+iSu2oKQIgpIvzwqI alo6VBVUBnPOlUlqKyz70W3UFmPTpFtA+aJ3WDvC9zDZSRLNmbP2PBOG9G4cFfnRnTWt WW9g== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@gjlay.de header.s=strato-dkim-0002 header.b=BdGaKM6H; dkim=neutral (no key) header.i=@gjlay.de header.s=strato-dkim-0003 header.b=J+koMlLn; arc=pass (i=2); 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" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m18-20020a0cdb92000000b0067ef1a2ef5asi4492467qvk.341.2023.12.15.00.19.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 00:19:20 -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=@gjlay.de header.s=strato-dkim-0002 header.b=BdGaKM6H; dkim=neutral (no key) header.i=@gjlay.de header.s=strato-dkim-0003 header.b=J+koMlLn; arc=pass (i=2); 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1B72F384772F for ; Fri, 15 Dec 2023 08:19:20 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.216]) by sourceware.org (Postfix) with ESMTPS id 86CC1384DED1 for ; Fri, 15 Dec 2023 08:19:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86CC1384DED1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gjlay.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=gjlay.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 86CC1384DED1 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=81.169.146.216 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1702628354; cv=pass; b=FuPbg8nIpyr8G4hjfgAgYKqIQgbnSAwvAaWKuV53nN26sfWzpZy2nAubyX11MyDcze0XgXWdP4ELnbh0sitrWDX9dRIJ6lhZy+L5L11u0+BW1PzeyZ22QdVHHjuanmtTmdYcDP++s9T6gXl7j/bUjm9pvUgttI4pXHJHL3d0Ios= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1702628354; c=relaxed/simple; bh=EsxcXVLZQWFdOwBx33RPPw8QMstTYt+ibXF5GJj20+E=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version:To: From:Subject; b=ZyknyXsZhDmYiba2QAxk7Smwcrq0D+0tmNUiYFa5OpigPI9XrQV92YqBFlk0P6jSBFzpuzTl0kbmBi2XxjfILxtozfPQl1hIcxjEziQwb/lOP+pcWEzfEigBXCMv9Eqp8wVVG624FiG99zw+Hx9ariRwmNMEv8/rekPiA6Ed5Uw= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1702628349; cv=none; d=strato.com; s=strato-dkim-0002; b=rmnnh6ATzp3RkF+Ns8aUWNP4FSNAn0t4Ipqb8w6SlQ7SpS5sP4nkonSD3GrmcuvBmP 7ZaXJwRhCOcRi/hOZC+aTLOu5LSiEO/eHGmbjtOO42aNEonsgEwvMjYriyAmUT3U9ASi r24UQRMF6aItE1A+Z44qCBFjzSu6viLCYFyZ3ev8HU/HhuAKrBdLFn+oLmYv/e5KFzsc JOLKRPu8GslQiEQr17rD0uU3v4F6BIX/pMNjdE87ZNOVs8PX+mkx5dIqNQSWkBTUzkoL HE15Vw2bAl5ryAHDVFzk6sX6fFHhjQESxidz1E5CKazfcxdO9w3JEjlMlRjpHM1rMKFi Co3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1702628349; s=strato-dkim-0002; d=strato.com; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=7QCC62hgIDnqPOJ3xtuBw4vBiiBUikjNN9uM396U+90=; b=GbSFYVMVI5k/jUM/4RheFIU7LIL1c42GHYeJAlFClu2Kn8hvUm1fQ9rWEiS2JykZuX OWCTzXfwKTs6UE2UZ28iXe8hbbNEWmdBrFR4AChTF8bJtw4/Yauc7E5lbaj1fP00HZTq XbpoI7e0jDt2VjpEqqxzpJMfP+wdziD4/wt3dc327BHKw7loa7BcEiQGpTWLbCyKXgjL DsIeM1yKLifw36S9M3tr572KAcfVSUFx2xgP4oJzPD/XN98NjwDeUdzSEdLVE0FdB0zH jYElWm5Hn+yKXMKgYzX8TbW+l7hGqx1mFLAjIYkZW9Uq0pp29hsqcOOCZVBB5ii1aJNH Io1g== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1702628349; s=strato-dkim-0002; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=7QCC62hgIDnqPOJ3xtuBw4vBiiBUikjNN9uM396U+90=; b=BdGaKM6HSZ+8rYI9qSsIZ8Fl31KDXHj5ERH6PSnCxR2OyRRxxfP+l54ES2mAgZOjZD Gzll7/iE0v3+t2/65NMz3oUEAh5phh24aagqK10F7T5zZl4X+lBPCBMdMOfylpWL0PAs 6PbmBrKw5RPnUaSunKq3fdvM7lQTaV9rtNWJlSa+qJX/4U8Liado+LGQIr4jSzuX9mJr 1O6kl54CiCkts6B0wtLDVgD+OpY5x9pH7n0SV+gp2F56GR/3qw1BLVvDEdUMSuLzjPID ZJf++07qa81l+/BlcSLRy7NadDKmHnfq5M/mXuBnqBYbJjV66jTMvp0wo1Hn+u+1xWzL s1BA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1702628349; s=strato-dkim-0003; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=7QCC62hgIDnqPOJ3xtuBw4vBiiBUikjNN9uM396U+90=; b=J+koMlLnG1gu1nvRf0b2NIvnBOu1luQMx87XoVb9QT6e5KBGN+hgGuJRdJ760CppYR pHHhzEFz0odV8NU9AABA== X-RZG-AUTH: ":LXoWVUeid/7A29J/hMvvT3koxZnKT7Qq0xotTetVnKkSjsSjo3O/MHXSz1aalw==" Received: from [192.168.2.102] by smtp.strato.de (RZmta 49.10.0 DYNA|AUTH) with ESMTPSA id Lf3d8bzBF8J81oc (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Fri, 15 Dec 2023 09:19:08 +0100 (CET) Message-ID: Date: Fri, 15 Dec 2023 09:19:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: binutils@sourceware.org From: Georg-Johann Lay Subject: [patch,avr] Addendum to PR31124 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785335235887218991 X-GMAIL-MSGID: 1785335235887218991 This is a small addendum to PR31124 "rodata in flash for more AVR devices". It adds some symbols so the startup code can set a lock on the FLMAP bit field as specified by the user. New symbols are introduced because otherwise, all the computations / decisions would have to be performed at run-time. It approved, please apply to master. Johann --- ld/ PR 31124 * scripttempl/avr.sc: Adjust comments. [MAYBE_FLMAP]: Add symbols __flmap_value and __flmap_value_with_lock. Remove __flmap_lsl4. diff --git a/ld/scripttempl/avr.sc b/ld/scripttempl/avr.sc index 9f2977cfd6d..a44eba5c9e9 100644 --- a/ld/scripttempl/avr.sc +++ b/ld/scripttempl/avr.sc @@ -23,9 +23,10 @@ # bit-field NVMCTRL_CTRLB.FLMAP. # Output section .rodata is placed in MEMORY region rodata. # The LMA of the .rodata section can be set by means of: -# * __flmap specifies which 32k block is visible in RAM. # * __RODATA_FLASH_START__ specifies the byte address of the -# rodata LMA and is used if __flmap is undefined. +# rodata LMA. +# * __flmap specifies which 32k block is visible in RAM provided +# __RODATA_FLASH_START__ is undefined # * When __flmap and __RODATA_FLASH_START__ are undefined, then an # emulation-specific default is used (the last 32k block). @@ -36,18 +37,21 @@ # achieved by new emulations avrxmega2_flmap and avrxmega4_flmap that # are selected by compiler option -mno-rodata-in-ram. # -# In order to facilitate initialization of NVMCTRL_CTRLB.FLMAP in -# the startup code irrespective of HAVE_FLMAP, the follwing symbols -# are defined in order to communicate with the startup code. +# In order to facilitate initialization of NVMCTRL_CTRLB.FLMAP and +# NVMCTRL_CTRLB.FLMAPLOCK in the startup code irrespective of +# HAVE_FLMAP, the following symbols are used / defined in order to +# communicate with the startup code. # Notice that the hardware default for FLMAP is the last 32k block, # so that explicit initialization of FLMAP is only required when the -# user wants to deviate from the defauls. +# user wants to deviate from the defaults. # # __flmap = HAVE_FLMAP # ? given by __flmap resp. __RODATA_FLASH_START__ >> 15 # : 0; # -# __flmap_lsl4 = __flmap << 4; +# __flmap_value = __flmap << __flmap_bpos; +# +# __flmap_value_with_lock = __flmap__value | __flmap_lock_mask; # # __flmap_init_label = HAVE_FLMAP # ? __flmap_init_start @@ -55,7 +59,14 @@ # Supposed to be used as a jump target for RJMP so that the code # can initialize FLMAP / skip initialization of FLMAP depending # on the chosen emulation, and without the need to support two code -# versions of crt.o for the two possble emulations. +# versions of crt.o for the two possible emulations. +# +# __flmap_lock is a bool provided by the user when FLMAP should be +# protected from any further changes. +# +# __flmap_lock_mask is an 8-bit mask like NVMCTRL_FLMAPLOCK_bm +# provided by the user which is set in __flmap_value_with_lock +# when __flmap_lock is on. # # __do_init_flmap = HAVE_FLMAP ? 1 : 0; # Whether or not FLMAP is supposed to be initialized according @@ -343,20 +354,11 @@ EOF # memory at 0x8000 (RODATA_LDS_OFFSET). Which portion will be determined by # bitfield NVMCTRL_CTRLB.FLMAP. -if test -n "${MAYBE_FLMAP}" && test -n "${RELOCATING}"; then - cat <> 15); +__flmap = ${FLMAP_MASK} & (__RODATA_FLASH_START__ >> 15); __RODATA_FLASH_START__ = __flmap << 15; __rodata_load_start = MAX (__data_load_end, __RODATA_FLASH_START__); -PROVIDE (__flmap_lsl4 = __flmap << 4) ; __rodata_start = __RODATA_ORIGIN__ + __rodata_load_start - __RODATA_FLASH_START__;} .rodata ${RELOCATING+ __rodata_start} ${RELOCATING-0} : ${RELOCATING+ AT (__rodata_load_start)} @@ -391,6 +392,19 @@ ${RELOCATING+ __rodata_load_end = __rodata_load_start + __rodata_end - __rodata_ EOF fi +if test -n "${MAYBE_FLMAP}" && test -n "${RELOCATING}"; then + cat <