I use an ARM Cortex-M0+ (RP2040 Pico), and I compile my programs with gcc, and then "flash" the MCU using openocd over SWD, by issuing the command
program myprog.elf verify reset exit
... to openocd.
What I want to know is this: Let's say I want to "protect" a Flash memory region: for instance, for the Pico, Flash starts at address 0x10000000, - and let's say I want to "protect" 0x10001000 to 0x10002000 ( which I could use for https://mcuoneclipse.com/2012/11/01/defining-variables-at-absolute-addresses-with-gcc/ )
Is there any flag that I can write in either .c source code, or in gcc command line, or gcc linker script, that would mark this Flash region as "protected" in the compiled .elf file - so that I would not have to give any special options to openocd; but instead, openocd would figure out "on its own" from the compiled .elf file, that when doing the flashing of the .elf on the chip (via program myprog.elf), it should basically skip the region from 0x10001000 to 0x10002000, so that Flash memory region keeps the data it had before the flashing?