Keil™, An ARM® Company

RealView Linker and Utilities Guide

Using command-line options to handle C++ exceptions

3.5. Using command-line options to handle C++ exceptions

By default, or if the option ‑‑exceptions is specified, the image can contain exception tables. Exception tables are discarded silently if no code throws an exception. However, if the option ‑‑no_exceptions is specified, the linker generates an error if any exceptions sections are present after unused sections have been eliminated.

You can use the ‑‑no_exceptions option if you want to ensure that your code is exceptions free. The linker generates an error message to highlight that exceptions have been found and does not produce a final image.

However, you can use the ‑‑no_exceptions option with the ‑‑diag_warning option to downgrade the error message to a warning. The linker produces a final image but also generates a message to warn you that exceptions have been found.

The linker can create exception tables for legacy objects that contain debug frame information. The linker can do this safely for C and assembly language objects. By default, the linker does not create exception tables. This is the same as using the linker option ‑‑exceptions_tables=nocreate.

The linker option ‑‑exceptions_tables=unwind enables the linker to use the .debug_frame information to create a register-restoring unwinding table for each section in your image that does not already have an exception table. If this is not possible, the linker creates a nounwind table instead.

Use the linker option ‑‑exceptions_tables=cantunwind to create a nounwind table for each section in your image that does not already have an exception table.

Note

Be aware of the following:

  • With the default settings, that is, ‑‑exceptions ‑‑exception_tables=nocreate, it is not safe to throw an exception through C or assembly code (unless the C code is compiled with the option ‑‑exceptions).

  • The linker cannot generate cleanup code for automatic variables in C++ code that is compiled without exceptions support, for example, any code compiled with RVCT v1.2, or code compiled with RVCT 3.0 using the ‑‑no_exceptions option.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0377A