meta data for this page

GCC

preprocesor files

-save-temps=obj

Linker

  • –as-needed - do not load symbols from libraries specified in command line when they are not needed. This option couses many unresolved symbol errors when order of libraries specified in command line is not correct. http://savannah.gnu.org/forum/forum.php?forum_id=5655

ld script

Place const variables

.crc 0x7FFE : {   KEEP(*(.crc))  }

or

  .crc (ORIGIN(rom)+LENGTH(rom)-2):
  {
     _crcstart = .;
    KEEP(*(.crc))
    _crcend = .;
  } >rom
const uint32_t crcValue __attribute__ ((section (".crc")))     = 0xDEADBEEF;

Place some symbols

    .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;

Optimize per function

int foo(int i) __attribute__((optimize("-O3")));