-save-temps=obj
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/assignments.html [[https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/sections.html https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/expressions.html https://ftp.gnu.org/pub/old-gnu/Manuals/ld-2.9.1/html_node/ld_21.html https://sourceware.org/binutils/docs-2.27/ld/Builtin-Functions.html http://www.math.utah.edu/docs/info/ld_3.html
.crc 0x7FFE : { KEEP(*(.crc)) }
or
.crc (ORIGIN(rom)+LENGTH(rom)-2): { _crcstart = .; KEEP(*(.crc)) _crcend = .; } >rom
const uint32_t crcValue __attribute__ ((section (".crc"))) = 0xDEADBEEF;
.bss : { _bss = .; *(EXCLUDE_FILE (*redoznes.co) .bss*) /* *(.bss*)*/ *(COMMON) _ebss = .; } > SRAM ._user_heap_stack : { *redzones.co(.bss.redzone1) . = ALIGN(4); end = .; _heap = .; /* "end" for newlib's syscalls, "_heap" for sbrk heap boundary checks */ . = . + _Min_Heap_Size; _eheap = .; *redoznes.co(.bss.redzone2) . = . + _Min_Stack_Size; . = ALIGN(4); } > SRAM
_redzone2_begin = .; . = . + 16; _redzone2_end = .;
and access them from C code:
extern uint8_t _redzone1_begin; extern uint8_t _redzone1_end; ... checkRedzone(&_redzone1_begin, &_redzone1_end - &_redzone1_begin);
empty_ram_size = _estack - ABSOLUTE(.) - _Min_Stack_Size - 16; . = . + empty_ram_size;
int foo(int i) __attribute__((optimize("-O3")));