1 /* gen-sframe.h - Support for generating SFrame.
2 Copyright (C) 2022 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
24 #define SFRAME_FRE_ELEM_LOC_REG 0
25 #define SFRAME_FRE_ELEM_LOC_STACK 1
27 /* SFrame Frame Row Entry (FRE).
29 A frame row entry is a slice of the frame and can be valid for a set of
30 program instructions. It keeps all information needed to retrieve the CFA
31 and the Return Address (RA) if tracked.
33 A frame row entry effectively stores accumulated information gathered by
34 interpreting multiple CFI instructions. More precisely, it is a
35 self-sufficient record in its own right. Only the subset of information
36 necessary for unwinding is stored: Given a PC, how to retrieve the CFA and
40 struct sframe_row_entry
43 struct sframe_row_entry *next;
45 /* Start and end of the frame row entry. */
49 /* A frame row entry is a merge candidate if new information can be updated
53 /* Track CFA base (architectural) register ID. */
54 unsigned int cfa_base_reg;
55 /* Offset from the CFA base register for recovering CFA. */
58 /* Track the other register used as base register for CFA. Specify whether
59 it is in register or memory. */
60 unsigned int base_reg;
62 /* If the other register is stashed on stack, note the offset. */
65 /* Track RA location. Specify whether it is in register or memory. */
67 /* If RA is stashed on stack, note the offset. */
71 /* SFrame Function Description Entry. */
73 struct sframe_func_entry
76 struct sframe_func_entry *next;
78 /* Reference to the FDE created from CFI in dw2gencfi. Some information
79 like the start_address and the segment is made available via this
81 const struct fde_entry *dw_fde;
83 /* Reference to the first FRE for this function. */
84 struct sframe_row_entry *sframe_fres;
86 unsigned int num_fres;
89 /* SFrame Function Description Entry Translation Context. */
91 struct sframe_xlate_ctx
93 /* Reference to the FDE created from CFI in dw2gencfi. Information
94 like the FDE start_address, end_address and the cfi insns are
95 made available via this member. */
96 const struct fde_entry *dw_fde;
98 /* List of FREs in the current FDE translation context, bounded by first_fre
101 /* Keep track of the first FRE for the purpose of restoring state if
102 necessary (for DW_CFA_restore). */
103 struct sframe_row_entry *first_fre;
104 /* The last FRE in the list. */
105 struct sframe_row_entry *last_fre;
107 /* The current FRE under construction. */
108 struct sframe_row_entry *cur_fre;
109 /* Remember FRE for an eventual restore. */
110 struct sframe_row_entry *remember_fre;
112 unsigned num_xlate_fres;
115 /* Error codes for SFrame translation context. */
116 enum sframe_xlate_err
121 SFRAME_XLATE_ERROR = 1,
122 /* Detailed error codes. */
123 SFRAME_XLATE_ERR_INVAL = -1,
124 SFRAME_XLATE_ERR_NOTREPRESENTED = -2,
127 /* Callback to create the abi/arch identifier for SFrame section. */
130 sframe_get_abi_arch_callback (const char *target_arch,
133 /* The list of all FDEs with data in SFrame internal representation. */
135 extern struct sframe_func_entry *all_sframe_fdes;
137 /* SFrame version specific operations structure. */
139 struct sframe_version_ops
141 unsigned char format_version; /* SFrame format version. */
142 /* set SFrame FRE info. */
143 unsigned char (*set_fre_info) (unsigned int, unsigned int, unsigned int);
144 /* set SFrame Func info. */
145 unsigned char (*set_func_info) (unsigned int, unsigned int);
148 /* Generate SFrame unwind info and prepare contents for the output.
149 outout_sframe () is called at the end of file. */
151 extern void output_sframe (segT sframe_seg);
153 #endif /* GENSFRAME_H */