IAR Linker and Library Tools Reference Guide
Total Page:16
File Type:pdf, Size:1020Kb
IAR Linker and Library Tools Reference Guide XLINK-620 XLINK-620 COPYRIGHT NOTICE © 1987–2015 IAR Systems AB. No part of this document may be reproduced without the prior written consent of IAR Systems AB. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. TRADEMARKS IAR Systems, IAR Embedded Workbench, C-SPY, C-RUN, C-STAT, visualSTATE, Focus on Your Code, IAR KickStart Kit, IAR Experiment!, I-jet, I-jet Trace, I-scope, IAR Academy, IAR, and the logotype of IAR Systems are trademarks or registered trademarks owned by IAR Systems AB. Microsoft and Windows are registered trademarks of Microsoft Corporation. Adobe and Acrobat Reader are registered trademarks of Adobe Systems Incorporated. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE February 2015 Part number: XLINK-620 XLINK-620 Contents Tables ........................................................................................................................ 7 Preface ...................................................................................................................... 9 Who should read this guide ................................................................. 9 How to use this guide ............................................................................. 9 What this guide contains ..................................................................... 10 Document conventions ........................................................................ 10 Typographic conventions ................................................................... 11 Naming conventions .......................................................................... 11 Part 1: The IAR XLINK Linker ........................................... 13 Introduction to the IAR XLINK Linker ............................................... 15 Key features .............................................................................................. 15 Large Address Awareness .................................................................. 15 Stack usage analysis ........................................................................... 16 MISRA C ........................................................................................... 16 The linking process ............................................................................... 17 Object format ..................................................................................... 17 XLINK functions ............................................................................... 18 Libraries ............................................................................................ 18 Output format ..................................................................................... 18 Input files and modules ........................................................................ 19 Libraries ............................................................................................. 19 Formatters for printf and scanf ........................................................... 20 Segments ............................................................................................ 21 Noalloc content .................................................................................. 21 Segment control ..................................................................................... 22 Address translation ............................................................................. 23 Allocation segment types ................................................................... 23 Memory segment types ...................................................................... 24 Overlap errors ................................................................................... 25 3 XLINK-620 Contents Range errors ...................................................................................... 25 Segment placement examples ............................................................ 26 Listing format ........................................................................................... 27 Header ................................................................................................ 27 Cross-reference .................................................................................. 28 Checksummed areas and memory usage ........................................... 35 Checksum calculation ........................................................................... 35 Checksum calculation by the linker ................................................... 36 Adding a checksum function to your source code ............................. 36 Things to remember ........................................................................... 38 Checksum value symbol .................................................................... 38 Bytewise and mirrored initial checksum values ........................ 39 Bitwise initial values .......................................................................... 39 Bytewise initial values ....................................................................... 40 Mirroring ............................................................................................ 40 Logging ........................................................................................................ 41 Logging object files ........................................................................... 41 Logging modules ................................................................................ 42 Logging segment parts ....................................................................... 42 Logging automatic redirections ......................................................... 44 XLINK options .................................................................................................. 47 Setting XLINK options ......................................................................... 47 Summary of options .............................................................................. 47 Descriptions of XLINK options ........................................................ 49 XLINK output formats .................................................................................. 85 Single output file ..................................................................................... 85 UBROF versions ............................................................................... 87 Two output files ...................................................................................... 89 Output format variants ........................................................................ 90 IEEE695 ............................................................................................. 90 ELF ..................................................................................................... 92 XCOFF78K ........................................................................................ 94 Restricting the output to a single address space ..................... 95 IAR Linker and Library Tools 4 Reference Guide XLINK-620 Contents XLINK environment variables ................................................................... 97 Summary of XLINK environment variables ............................... 97 XLINK diagnostics ......................................................................................... 101 Introduction ............................................................................................ 101 XLINK warning messages ............................................................... 101 XLINK error messages .................................................................... 101 XLINK fatal error messages ............................................................ 101 XLINK internal error messages ....................................................... 101 XLINK stack usage analysis diagnostic messages .......................... 102 Error messages ...................................................................................... 102 Warning messages ............................................................................... 123 Stack usage analysis diagnostic messages .................................. 133 Part 2: The IAR Library Tools ............................................ 137 Introduction to the IAR Systems library tools ............................... 139 Libraries .................................................................................................... 139 IAR XAR Library Builder and IAR XLIB Librarian ............... 139 Choosing which tool to use .............................................................. 140 Using libraries with C/C++ programs .......................................... 140 Using libraries with assembler programs .................................. 140 The IAR XAR Library Builder .................................................................