]> Git Repo - binutils.git/blob - gas/gen-sframe.h
Automatic date update in version.in
[binutils.git] / gas / gen-sframe.h
1 /* gen-sframe.h - Support for generating SFrame.
2    Copyright (C) 2022 Free Software Foundation, Inc.
3
4    This file is part of GAS, the GNU Assembler.
5
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)
9    any later version.
10
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.
15
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
19    02110-1301, USA.  */
20
21 #ifndef GENSFRAME_H
22 #define GENSFRAME_H
23
24 #define SFRAME_FRE_ELEM_LOC_REG         0
25 #define SFRAME_FRE_ELEM_LOC_STACK       1
26
27 /* SFrame Frame Row Entry (FRE).
28
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.
32
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
37    the RA.
38 */
39
40 struct sframe_row_entry
41 {
42   /* A linked list.  */
43   struct sframe_row_entry *next;
44
45   /* Start and end of the frame row entry.  */
46   symbolS *pc_begin;
47   symbolS *pc_end;
48
49   /* A frame row entry is a merge candidate if new information can be updated
50      on it.  */
51   bool merge_candidate;
52
53   /* Track CFA base (architectural) register ID.  */
54   unsigned int cfa_base_reg;
55   /* Offset from the CFA base register for recovering CFA.  */
56   offsetT cfa_offset;
57
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;
61   unsigned int bp_loc;
62   /* If the other register is stashed on stack, note the offset.  */
63   offsetT bp_offset;
64
65   /* Track RA location.  Specify whether it is in register or memory.  */
66   unsigned int ra_loc;
67   /* If RA is stashed on stack, note the offset.  */
68   offsetT ra_offset;
69 };
70
71 /* SFrame Function Description Entry.  */
72
73 struct sframe_func_entry
74 {
75   /* A linked list.  */
76   struct sframe_func_entry *next;
77
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
80      member.  */
81   const struct fde_entry *dw_fde;
82
83   /* Reference to the first FRE for this function.  */
84   struct sframe_row_entry *sframe_fres;
85
86   unsigned int num_fres;
87 };
88
89 /* SFrame Function Description Entry Translation Context.  */
90
91 struct sframe_xlate_ctx
92 {
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;
97
98   /* List of FREs in the current FDE translation context, bounded by first_fre
99      and last_fre.  */
100
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;
106
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;
111
112   unsigned num_xlate_fres;
113 };
114
115 /* Error codes for SFrame translation context.  */
116 enum sframe_xlate_err
117 {
118   /* Success.  */
119   SFRAME_XLATE_OK = 0,
120   /* Error.  */
121   SFRAME_XLATE_ERROR = 1,
122   /* Detailed error codes.  */
123   SFRAME_XLATE_ERR_INVAL = -1,
124   SFRAME_XLATE_ERR_NOTREPRESENTED = -2,
125 };
126
127 /* Callback to create the abi/arch identifier for SFrame section.  */
128
129 unsigned char
130 sframe_get_abi_arch_callback (const char *target_arch,
131                               int big_endian_p);
132
133 /* The list of all FDEs with data in SFrame internal representation.  */
134
135 extern struct sframe_func_entry *all_sframe_fdes;
136
137 /* SFrame version specific operations structure.  */
138
139 struct sframe_version_ops
140 {
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);
146 };
147
148 /* Generate SFrame unwind info and prepare contents for the output.
149    outout_sframe ()  is called at the end of file.  */
150
151 extern void output_sframe (segT sframe_seg);
152
153 #endif /* GENSFRAME_H */
This page took 0.032099 seconds and 4 git commands to generate.