2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. _exception-region-output:
8 Assembler Commands for Exception Regions
9 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 .. prevent bad page break with this line
13 This describes commands marking the start and the end of an exception
16 .. c:macro:: EH_FRAME_SECTION_NAME
18 If defined, a C string constant for the name of the section containing
19 exception handling frame unwind information. If not defined, GCC will
20 provide a default definition if the target supports named sections.
21 :samp:`crtstuff.c` uses this macro to switch to the appropriate section.
23 You should define this symbol if your target supports DWARF 2 frame
24 unwind information and the default definition does not work.
26 .. c:macro:: EH_FRAME_THROUGH_COLLECT2
28 If defined, DWARF 2 frame unwind information will identified by
29 specially named labels. The collect2 process will locate these
30 labels and generate code to register the frames.
32 This might be necessary, for instance, if the system linker will not
33 place the eh_frames in-between the sentinals from :samp:`crtstuff.c`,
34 or if the system linker does garbage collection and sections cannot
35 be marked as not to be collected.
37 .. c:macro:: EH_TABLES_CAN_BE_READ_ONLY
39 Define this macro to 1 if your target is such that no frame unwind
40 information encoding used with non-PIC code will ever require a
41 runtime relocation, but the linker may not support merging read-only
42 and read-write sections into a single read-write section.
44 .. c:macro:: MASK_RETURN_ADDR
46 An rtx used to mask the return address found via ``RETURN_ADDR_RTX``, so
47 that it does not contain any extraneous set bits in it.
49 .. c:macro:: DWARF2_UNWIND_INFO
51 Define this macro to 0 if your target supports DWARF 2 frame unwind
52 information, but it does not yet work with exception handling.
53 Otherwise, if your target supports this information (if it defines
54 ``INCOMING_RETURN_ADDR_RTX`` and ``OBJECT_FORMAT_ELF``),
55 GCC will provide a default definition of 1.
57 .. function:: enum unwind_info_type TARGET_EXCEPT_UNWIND_INFO (struct gcc_options *opts)
59 .. hook-start:TARGET_EXCEPT_UNWIND_INFO
63 This hook defines the mechanism that will be used for exception handling
64 by the target. If the target has ABI specified unwind tables, the hook
65 should return ``UI_TARGET``. If the target is to use the
66 ``setjmp`` / ``longjmp`` -based exception handling scheme, the hook
67 should return ``UI_SJLJ``. If the target supports DWARF 2 frame unwind
68 information, the hook should return ``UI_DWARF2``.
70 A target may, if exceptions are disabled, choose to return ``UI_NONE``.
71 This may end up simplifying other parts of target-specific code. The
72 default implementation of this hook never returns ``UI_NONE``.
74 Note that the value returned by this hook should be constant. It should
75 not depend on anything except the command-line switches described by
76 :samp:`{opts}`. In particular, the
77 setting ``UI_SJLJ`` must be fixed at compiler start-up as C pre-processor
78 macros and builtin functions related to exception handling are set up
79 depending on this setting.
81 The default implementation of the hook first honors the
82 :option:`--enable-sjlj-exceptions` configure option, then
83 ``DWARF2_UNWIND_INFO``, and finally defaults to ``UI_SJLJ``. If
84 ``DWARF2_UNWIND_INFO`` depends on command-line options, the target
85 must define this hook so that :samp:`{opts}` is used correctly.
87 .. c:var:: bool TARGET_UNWIND_TABLES_DEFAULT
89 .. hook-start:TARGET_UNWIND_TABLES_DEFAULT
93 This variable should be set to ``true`` if the target ABI requires unwinding
94 tables even when exceptions are not used. It must not be modified by
95 command-line option processing.
97 .. c:macro:: DONT_USE_BUILTIN_SETJMP
99 Define this macro to 1 if the ``setjmp`` / ``longjmp`` -based scheme
100 should use the ``setjmp`` / ``longjmp`` functions from the C library
101 instead of the ``__builtin_setjmp`` / ``__builtin_longjmp`` machinery.
103 .. c:macro:: JMP_BUF_SIZE
105 This macro has no effect unless ``DONT_USE_BUILTIN_SETJMP`` is also
106 defined. Define this macro if the default size of ``jmp_buf`` buffer
107 for the ``setjmp`` / ``longjmp`` -based exception handling mechanism
108 is not large enough, or if it is much too large.
109 The default size is ``FIRST_PSEUDO_REGISTER * sizeof(void *)``.
111 .. c:macro:: DWARF_CIE_DATA_ALIGNMENT
113 This macro need only be defined if the target might save registers in the
114 function prologue at an offset to the stack pointer that is not aligned to
115 ``UNITS_PER_WORD``. The definition should be the negative minimum
116 alignment if ``STACK_GROWS_DOWNWARD`` is true, and the positive
117 minimum alignment otherwise. See :ref:`dwarf`. Only applicable if
118 the target supports DWARF 2 frame unwind information.
120 .. c:var:: bool TARGET_TERMINATE_DW2_EH_FRAME_INFO
122 .. hook-start:TARGET_TERMINATE_DW2_EH_FRAME_INFO
124 Contains the value true if the target should add a zero word onto the
125 end of a Dwarf-2 frame info section when used for exception handling.
126 Default value is false if ``EH_FRAME_SECTION_NAME`` is defined, and
131 .. function:: rtx TARGET_DWARF_REGISTER_SPAN (rtx reg)
133 .. hook-start:TARGET_DWARF_REGISTER_SPAN
135 Given a register, this hook should return a parallel of registers to
136 represent where to find the register pieces. Define this hook if the
137 register and its mode are represented in Dwarf in non-contiguous
138 locations, or if the register should be represented in more than one
139 register in Dwarf. Otherwise, this hook should return ``NULL_RTX``.
140 If not defined, the default is to return ``NULL_RTX``.
144 .. function:: machine_mode TARGET_DWARF_FRAME_REG_MODE (int regno)
146 .. hook-start:TARGET_DWARF_FRAME_REG_MODE
148 Given a register, this hook should return the mode which the
149 corresponding Dwarf frame register should have. This is normally
150 used to return a smaller mode than the raw mode to prevent call
151 clobbered parts of a register altering the frame register size
155 .. function:: void TARGET_INIT_DWARF_REG_SIZES_EXTRA (tree address)
157 .. hook-start:TARGET_INIT_DWARF_REG_SIZES_EXTRA
159 If some registers are represented in Dwarf-2 unwind information in
160 multiple pieces, define this hook to fill in information about the
161 sizes of those pieces in the table used by the unwinder at runtime.
162 It will be called by ``expand_builtin_init_dwarf_reg_sizes`` after
163 filling in a single size corresponding to each hard register;
164 :samp:`{address}` is the address of the table.
168 .. function:: bool TARGET_ASM_TTYPE (rtx sym)
170 .. hook-start:TARGET_ASM_TTYPE
172 This hook is used to output a reference from a frame unwinding table to
173 the type_info object identified by :samp:`{sym}`. It should return ``true``
174 if the reference was output. Returning ``false`` will cause the
175 reference to be output using the normal Dwarf2 routines.
179 .. c:var:: bool TARGET_ARM_EABI_UNWINDER
181 .. hook-start:TARGET_ARM_EABI_UNWINDER
183 This flag should be set to ``true`` on targets that use an ARM EABI
184 based unwinding library, and ``false`` on other targets. This effects
185 the format of unwinding tables, and how the unwinder in entered after
186 running a cleanup. The default is ``false``.