meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gcc [2017/06/29 14:45]
niziak
gcc [2024/04/26 14:39] (current)
niziak
Line 1: Line 1:
 +====== GCC ======
 +
 +===== preprocesor files =====
 +
 +''​-save-temps=obj''​
 +
 +
 ===== Linker ===== ===== 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]]   * **--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]]
Line 4: Line 11:
   * **--hash-style** - insert faster GNU hash table instead of SysV table. But looses compatiblity with older systems. [[http://​stackoverflow.com/​questions/​11741816/​only-one-hash-style-in-embedded-linux-why]]   * **--hash-style** - insert faster GNU hash table instead of SysV table. But looses compatiblity with older systems. [[http://​stackoverflow.com/​questions/​11741816/​only-one-hash-style-in-embedded-linux-why]]
  
-https://​access.redhat.com/​documentation/​en-US/​Red_Hat_Enterprise_Linux/​4/​html/​Using_ld_the_GNU_Linker/​sections.html+===== ld script ===== 
 + 
 +[[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]] 
 + 
 + 
 +=== Place const variables === 
 +<​file>​ 
 +.crc 0x7FFE : {   ​KEEP(*(.crc)) ​ } 
 +</​file>​ 
 +or 
 +<​file>​ 
 +  .crc (ORIGIN(rom)+LENGTH(rom)-2):​ 
 +  { 
 +     ​_crcstart = .; 
 +    KEEP(*(.crc)) 
 +    _crcend = .; 
 +  } >rom 
 +</​file>​ 
 + 
 +<code c> 
 +const uint32_t crcValue __attribute__ ((section ("​.crc"​))) ​    = 0xDEADBEEF;​ 
 +</​code>​
  
 === Place some symbols === === Place some symbols ===
Line 30: Line 63:
     } > SRAM     } > SRAM
 </​file>​ </​file>​
 +
 +<​file>​
 +      _redzone2_begin = .;
 +      . = . + 16;
 +      _redzone2_end = .;
 +</​file>​
 +
 +and access them from C code:
 +
 +<code C>
 +extern uint8_t _redzone1_begin;​
 +extern uint8_t _redzone1_end;​
 +...
 +checkRedzone(&​_redzone1_begin,​ &​_redzone1_end - &​_redzone1_begin);​
 +</​code>​
 +
 +<​file>​
 +     ​empty_ram_size = _estack - ABSOLUTE(.) - _Min_Stack_Size - 16;
 +      . = . + empty_ram_size;​
 +</​file>​
 +
  
 ===== Optimize per function ===== ===== Optimize per function =====
 <code c>int foo(int i) __attribute__((optimize("​-O3"​)));</​code>​ <code c>int foo(int i) __attribute__((optimize("​-O3"​)));</​code>​