ld: Move the .note.build-id section to near the start of the memory map.
[binutils-gdb.git] / gas / gen-sframe.h
blob8ed46dbb087b06bc7516d6fa6191d35d271df596
1 /* gen-sframe.h - Support for generating SFrame.
2 Copyright (C) 2022-2024 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)
9 any later version.
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
19 02110-1301, USA. */
21 #ifndef GENSFRAME_H
22 #define GENSFRAME_H
24 #define SFRAME_FRE_ELEM_LOC_REG 0
25 #define SFRAME_FRE_ELEM_LOC_STACK 1
27 #define SFRAME_FRE_BASE_REG_INVAL ((unsigned int)-1)
29 /* SFrame Frame Row Entry (FRE).
31 A frame row entry is a slice of the frame and can be valid for a set of
32 program instructions. It keeps all information needed to retrieve the CFA
33 and the Return Address (RA) if tracked.
35 A frame row entry effectively stores accumulated information gathered by
36 interpreting multiple CFI instructions. More precisely, it is a
37 self-sufficient record in its own right. Only the subset of information
38 necessary for unwinding is stored: Given a PC, how to retrieve the CFA and
39 the RA.
42 struct sframe_row_entry
44 /* A linked list. */
45 struct sframe_row_entry *next;
47 /* Start and end of the frame row entry. */
48 symbolS *pc_begin;
49 symbolS *pc_end;
51 /* A frame row entry is a merge candidate if new information can be updated
52 on it. */
53 bool merge_candidate;
55 /* Whether the return address is mangled with pauth code. */
56 bool mangled_ra_p;
58 /* Track CFA base (architectural) register ID. */
59 unsigned int cfa_base_reg;
60 /* Offset from the CFA base register for recovering CFA. */
61 offsetT cfa_offset;
63 /* Track the other register used as base register for CFA. Specify whether
64 it is in register or memory. */
65 unsigned int base_reg;
66 unsigned int bp_loc;
67 /* If the other register is stashed on stack, note the offset. */
68 offsetT bp_offset;
70 /* Track RA location. Specify whether it is in register or memory. */
71 unsigned int ra_loc;
72 /* If RA is stashed on stack, note the offset. */
73 offsetT ra_offset;
76 /* SFrame Function Description Entry. */
78 struct sframe_func_entry
80 /* A linked list. */
81 struct sframe_func_entry *next;
83 /* Reference to the FDE created from CFI in dw2gencfi. Some information
84 like the start_address and the segment is made available via this
85 member. */
86 const struct fde_entry *dw_fde;
88 /* Reference to the first FRE for this function. */
89 struct sframe_row_entry *sframe_fres;
91 unsigned int num_fres;
94 /* SFrame Function Description Entry Translation Context. */
96 struct sframe_xlate_ctx
98 /* Reference to the FDE created from CFI in dw2gencfi. Information
99 like the FDE start_address, end_address and the cfi insns are
100 made available via this member. */
101 const struct fde_entry *dw_fde;
103 /* List of FREs in the current FDE translation context, bounded by first_fre
104 and last_fre. */
106 /* Keep track of the first FRE for the purpose of restoring state if
107 necessary (for DW_CFA_restore). */
108 struct sframe_row_entry *first_fre;
109 /* The last FRE in the list. */
110 struct sframe_row_entry *last_fre;
112 /* The current FRE under construction. */
113 struct sframe_row_entry *cur_fre;
114 /* Remember FRE for an eventual restore. */
115 struct sframe_row_entry *remember_fre;
117 unsigned num_xlate_fres;
120 /* Error codes for SFrame translation context. */
121 enum sframe_xlate_err
123 /* Success. */
124 SFRAME_XLATE_OK = 0,
125 /* Error. */
126 SFRAME_XLATE_ERROR = 1,
127 /* Detailed error codes. */
128 SFRAME_XLATE_ERR_INVAL = -1,
129 SFRAME_XLATE_ERR_NOTREPRESENTED = -2,
132 /* Callback to create the abi/arch identifier for SFrame section. */
134 unsigned char
135 sframe_get_abi_arch_callback (const char *target_arch,
136 int big_endian_p);
138 /* The list of all FDEs with data in SFrame internal representation. */
140 extern struct sframe_func_entry *all_sframe_fdes;
142 /* SFrame version specific operations structure. */
144 struct sframe_version_ops
146 unsigned char format_version; /* SFrame format version. */
147 /* set SFrame FRE info. */
148 unsigned char (*set_fre_info) (unsigned int, unsigned int, unsigned int,
149 bool);
150 /* set SFrame Func info. */
151 unsigned char (*set_func_info) (unsigned int, unsigned int, unsigned int);
154 /* Generate SFrame stack trace info and prepare contents for the output.
155 outout_sframe () is called at the end of file. */
157 extern void output_sframe (segT sframe_seg);
159 #endif /* GENSFRAME_H */