ARM Compiler toolchain Using the Linker - ARM Information Center
ARM Compiler toolchain Using the Linker - ARM Information Center
ARM Compiler toolchain Using the Linker - ARM Information Center
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Image structure and generation<br />
4.21 <strong>Using</strong> command-line options to control <strong>the</strong> generation of C++ exception tables<br />
4.21.1 See also<br />
By default, or if <strong>the</strong> option --exceptions is specified, <strong>the</strong> image can contain exception tables.<br />
Exception tables are discarded silently if no code throws an exception. However, if <strong>the</strong> option<br />
--no_exceptions is specified, <strong>the</strong> linker generates an error if any exceptions sections are present<br />
after unused sections have been eliminated.<br />
You can use <strong>the</strong> --no_exceptions option to ensure that your code is exceptions free. The linker<br />
generates an error message to highlight that exceptions have been found and does not produce<br />
a final image.<br />
However, you can use <strong>the</strong> --no_exceptions option with <strong>the</strong> --diag_warning option to downgrade<br />
<strong>the</strong> error message to a warning. The linker produces a final image but also generates a message<br />
to warn you that exceptions have been found.<br />
The linker can create exception tables for legacy objects that contain debug frame information.<br />
The linker can do this safely for C and assembly language objects. By default, <strong>the</strong> linker does<br />
not create exception tables. This is <strong>the</strong> same as using <strong>the</strong> linker option<br />
--exceptions_tables=nocreate.<br />
The linker option --exceptions_tables=unwind enables <strong>the</strong> linker to use <strong>the</strong> .debug_frame<br />
information to create a register-restoring unwinding table for each section in your image that<br />
does not already have an exception table. If this is not possible, <strong>the</strong> linker creates a nounwind<br />
table instead.<br />
Use <strong>the</strong> linker option --exceptions_tables=cantunwind to create a nounwind table for each<br />
section in your image that does not already have an exception table.<br />
Note<br />
Be aware of <strong>the</strong> following:<br />
• With <strong>the</strong> default settings, that is, --exceptions --exception_tables=nocreate, it is not safe<br />
to throw an exception through C or assembly code, unless <strong>the</strong> C code is compiled with <strong>the</strong><br />
option --exceptions.<br />
• The linker can generate frame unwinding instructions from objects with .debug_frame<br />
information. Frame unwinding is sufficient for C and assembler code. It is not sufficient<br />
for C++ code, because it does not call <strong>the</strong> destructors for <strong>the</strong> objects on <strong>the</strong> stack that is<br />
being unwound.<br />
The cleanup code for C++ must be generated by <strong>the</strong> compiler with <strong>the</strong> --exceptions<br />
option.<br />
Reference<br />
<strong>Linker</strong> Reference:<br />
• --diag_warning=tag[,tag,...] on page 2-48<br />
• --exceptions, --no_exceptions on page 2-61<br />
• --exceptions_tables=action on page 2-62.<br />
<strong>Compiler</strong> Reference:<br />
• --exceptions, --no_exceptions on page 3-85.<br />
<strong>ARM</strong> DUI 0474C Copyright © 2010-2011 <strong>ARM</strong>. All rights reserved. 4-31<br />
ID080411 Non-Confidential