11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRLinker OperationsThe main purpose of <strong>the</strong> linker is to combine multiple object files into an output filesuitable to be loaded by a device programmer or target simulator. The linker can alsotake input from a “library,” which is basically a file containing multiple object files. Inproducing <strong>the</strong> output file, <strong>the</strong> linker resolves any references between <strong>the</strong> input files. Insome detail, <strong>the</strong> linking steps involve:1. Making <strong>the</strong> startup file be <strong>the</strong> first file to be linked. The startup file initializes <strong>the</strong>execution <strong>environment</strong> <strong>for</strong> <strong>the</strong> C program to run.2. Appending any libraries that you explicitly requested (or in most cases, as wererequested by <strong>the</strong> IDE) to <strong>the</strong> list of files to be linked. Library modules that aredirectly or indirectly referenced will be linked in. All <strong>the</strong> user-specified object files(<strong>for</strong> example, your program files) are linked.3. Appending <strong>the</strong> st<strong>and</strong>ard C library libc<strong>avr</strong>.a to <strong>the</strong> end of <strong>the</strong> file list.4. Scanning <strong>the</strong> object files to find unresolved references. The linker marks <strong>the</strong>object file (possibly in <strong>the</strong> library) that satisfies <strong>the</strong> references <strong>and</strong> adds to its list ofunresolved references. It repeats <strong>the</strong> process until <strong>the</strong>re are no outst<strong>and</strong>ingunresolved references.5. Combining “areas” in all marked object files into an output file <strong>and</strong> generating map<strong>and</strong> listing files as needed.Lastly, if this is <strong>the</strong> ADVANCED or PROFESSIONAL version <strong>and</strong> if <strong>the</strong> CodeCompressor (tm) optimization option is on, <strong>the</strong>n <strong>the</strong> Code Compressor is called.Memory AllocationAs <strong>the</strong> linker combines areas from <strong>the</strong> input object files, it assigns memory addressesto <strong>the</strong>m based on <strong>the</strong> address ranges passed in from <strong>the</strong> comm<strong>and</strong> line (see LinkerArguments). These arguments in turn are normally passed down from <strong>the</strong> IDE basedon <strong>the</strong> specified device. That is, in <strong>the</strong> normal case, you do not need to do anything<strong>and</strong> <strong>the</strong> IDE/<strong>compiler</strong> will do <strong>the</strong> correct memory allocation <strong>for</strong> you.If you use #pragma text / data / lit / abs_address to assign your ownmemory areas, you must manually ensure that <strong>the</strong>ir addresses do not overlap <strong>the</strong>ones used by <strong>the</strong> linker. As an attempt to overlap allocation may or may not cause <strong>the</strong>linker to generate an error, you should always check <strong>the</strong> .mp map file (use <strong>the</strong> IDEmenu selection View->Map File) <strong>for</strong> potential problems.191

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!