From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1733) id E96A73858D37; Mon, 12 Feb 2024 11:04:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E96A73858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707735879; bh=bubE+EOFvHbUycnzqVVfE7rbkNj1A/OoZRmDyMLSlFI=; h=From:To:Subject:Date:From; b=bxp321aPJlwY8rVTReBgsSmLmUBwarMATcUsV/2TIH+TeqE79HtNkFMpJ3XKitlLY dhbhzaGml2xfSRlVMXJP6HWRymIU1xUL87wzo/gPlWSDim+MvzyFhyoMep8c5j+5dE rWZ8deHq2q335XgXYM5acbgpv/D9xJj0+TxjrfdY= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Georg-Johann Lay To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8926] AVR: target/112944 - Addendum: Link code to initialize NVMCTRL_CTRLB.FLMAP X-Act-Checkin: gcc X-Git-Author: Georg-Johann Lay X-Git-Refname: refs/heads/master X-Git-Oldrev: 1e3f78dbb328a2f2db8def241372cb947d9cb7eb X-Git-Newrev: 525cfe1e9554858366e7811aa9e437357c0f272e Message-Id: <20240212110439.E96A73858D37@sourceware.org> Date: Mon, 12 Feb 2024 11:04:39 +0000 (GMT) List-Id: https://gcc.gnu.org/g:525cfe1e9554858366e7811aa9e437357c0f272e commit r14-8926-g525cfe1e9554858366e7811aa9e437357c0f272e Author: Georg-Johann Lay Date: Mon Feb 12 11:10:48 2024 +0100 AVR: target/112944 - Addendum: Link code to initialize NVMCTRL_CTRLB.FLMAP For devices that see a part for the flash memory in the RAM address space, bit-field NVMCTRL_CTRLB.FLMAP must match the value of symbol __flmap. This is achieved by dragging in startup code from lib.a. The mechanism is the same like for libgcc's __do_copy_data and __do_clear_bss. The code is implemented in AVR-LibC #931 and can be dragged by referencing __do_flmap_init. In addition to setting FLMAP, that code also sets bit FLMAPLOCK provided symbol __flmap_lock has a non-zero value. This protects FLMAP from future changes. When the __do_flmap_init code is not wanted, the symbol can be satisfied by linking with -Wl,--defsym,__do_flmap_init=0 gcc/ PR target/112944 * config/avr/gen-avr-mmcu-specs.cc (print_mcu) [have_flmap]: <*link_rodata_in_ram>: Spec undefs symbol __do_flmap_init when not linked with -mrodata-in-ram. Diff: --- gcc/config/avr/gen-avr-mmcu-specs.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/config/avr/gen-avr-mmcu-specs.cc b/gcc/config/avr/gen-avr-mmcu-specs.cc index ea69145d404c..bb94bea12b00 100644 --- a/gcc/config/avr/gen-avr-mmcu-specs.cc +++ b/gcc/config/avr/gen-avr-mmcu-specs.cc @@ -369,7 +369,10 @@ print_mcu (const avr_mcu_t *mcu, const McuInfo &mi) } // -m[no-]rodata-in-ram affects linking. Sanity check its usage. - fprintf (f, "*link_rodata_in_ram:\n\t%%(check_rodata_in_ram)\n\n"); + fprintf (f, "*link_rodata_in_ram:\n\t%%(check_rodata_in_ram)"); + if (mi.is_device && mi.have_flmap) + fprintf (f, " %%{!mrodata-in-ram:-u __do_flmap_init}"); + fprintf (f, "\n\n"); // Specs known to GCC.