]> git.ipfire.org Git - thirdparty/gcc.git/commit
AVR: target/112944 - Addendum: Link code to initialize NVMCTRL_CTRLB.FLMAP
authorGeorg-Johann Lay <avr@gjlay.de>
Mon, 12 Feb 2024 10:10:48 +0000 (11:10 +0100)
committerGeorg-Johann Lay <avr@gjlay.de>
Mon, 12 Feb 2024 11:03:11 +0000 (12:03 +0100)
commit525cfe1e9554858366e7811aa9e437357c0f272e
tree2139ea6c99d54e13ab507a007b547469903f49e6
parent1e3f78dbb328a2f2db8def241372cb947d9cb7eb
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<mcu>.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.
gcc/config/avr/gen-avr-mmcu-specs.cc