Coverage Report

Created: 2026-09-14 08:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/include/elf/xtensa.h
Line
Count
Source
1
/* Xtensa ELF support for BFD.
2
   Copyright (C) 2003-2026 Free Software Foundation, Inc.
3
   Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica.
4
5
   This file is part of BFD, the Binary File Descriptor library.
6
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3 of the License, or
10
   (at your option) any later version.
11
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
20
   USA.  */
21
22
/* This file holds definitions specific to the Xtensa ELF ABI.  */
23
24
#ifndef _ELF_XTENSA_H
25
#define _ELF_XTENSA_H
26
27
#include "elf/reloc-macros.h"
28
29
#ifdef __cplusplus
30
extern "C" {
31
#endif
32
33
/* Relocations.  */
34
4.68k
START_RELOC_NUMBERS (elf_xtensa_reloc_type)
35
4.68k
     RELOC_NUMBER (R_XTENSA_NONE, 0)
36
152
     RELOC_NUMBER (R_XTENSA_32, 1)
37
35
     RELOC_NUMBER (R_XTENSA_RTLD, 2)
38
11
     RELOC_NUMBER (R_XTENSA_GLOB_DAT, 3)
39
71
     RELOC_NUMBER (R_XTENSA_JMP_SLOT, 4)
40
4
     RELOC_NUMBER (R_XTENSA_RELATIVE, 5)
41
4
     RELOC_NUMBER (R_XTENSA_PLT, 6)
42
26
     RELOC_NUMBER (R_XTENSA_OP0, 8)
43
64
     RELOC_NUMBER (R_XTENSA_OP1, 9)
44
43
     RELOC_NUMBER (R_XTENSA_OP2, 10) 
45
5
     RELOC_NUMBER (R_XTENSA_ASM_EXPAND, 11)
46
12
     RELOC_NUMBER (R_XTENSA_ASM_SIMPLIFY, 12)
47
390
     RELOC_NUMBER (R_XTENSA_32_PCREL, 14)
48
1
     RELOC_NUMBER (R_XTENSA_GNU_VTINHERIT, 15)
49
15
     RELOC_NUMBER (R_XTENSA_GNU_VTENTRY, 16)
50
8
     RELOC_NUMBER (R_XTENSA_DIFF8, 17)
51
5
     RELOC_NUMBER (R_XTENSA_DIFF16, 18)
52
255
     RELOC_NUMBER (R_XTENSA_DIFF32, 19)
53
9
     RELOC_NUMBER (R_XTENSA_SLOT0_OP, 20)
54
13
     RELOC_NUMBER (R_XTENSA_SLOT1_OP, 21)
55
3
     RELOC_NUMBER (R_XTENSA_SLOT2_OP, 22)
56
5
     RELOC_NUMBER (R_XTENSA_SLOT3_OP, 23)
57
1
     RELOC_NUMBER (R_XTENSA_SLOT4_OP, 24)
58
6
     RELOC_NUMBER (R_XTENSA_SLOT5_OP, 25)
59
2
     RELOC_NUMBER (R_XTENSA_SLOT6_OP, 26)
60
17
     RELOC_NUMBER (R_XTENSA_SLOT7_OP, 27)
61
3
     RELOC_NUMBER (R_XTENSA_SLOT8_OP, 28)
62
13
     RELOC_NUMBER (R_XTENSA_SLOT9_OP, 29)
63
2
     RELOC_NUMBER (R_XTENSA_SLOT10_OP, 30)
64
0
     RELOC_NUMBER (R_XTENSA_SLOT11_OP, 31)
65
15
     RELOC_NUMBER (R_XTENSA_SLOT12_OP, 32)
66
14
     RELOC_NUMBER (R_XTENSA_SLOT13_OP, 33)
67
3
     RELOC_NUMBER (R_XTENSA_SLOT14_OP, 34)
68
0
     RELOC_NUMBER (R_XTENSA_SLOT0_ALT, 35)
69
6
     RELOC_NUMBER (R_XTENSA_SLOT1_ALT, 36)
70
7
     RELOC_NUMBER (R_XTENSA_SLOT2_ALT, 37)
71
30
     RELOC_NUMBER (R_XTENSA_SLOT3_ALT, 38)
72
8
     RELOC_NUMBER (R_XTENSA_SLOT4_ALT, 39)
73
27
     RELOC_NUMBER (R_XTENSA_SLOT5_ALT, 40)
74
0
     RELOC_NUMBER (R_XTENSA_SLOT6_ALT, 41)
75
11
     RELOC_NUMBER (R_XTENSA_SLOT7_ALT, 42)
76
12
     RELOC_NUMBER (R_XTENSA_SLOT8_ALT, 43)
77
2
     RELOC_NUMBER (R_XTENSA_SLOT9_ALT, 44)
78
17
     RELOC_NUMBER (R_XTENSA_SLOT10_ALT, 45)
79
11
     RELOC_NUMBER (R_XTENSA_SLOT11_ALT, 46)
80
3
     RELOC_NUMBER (R_XTENSA_SLOT12_ALT, 47)
81
12
     RELOC_NUMBER (R_XTENSA_SLOT13_ALT, 48)
82
92
     RELOC_NUMBER (R_XTENSA_SLOT14_ALT, 49)
83
0
     RELOC_NUMBER (R_XTENSA_TLSDESC_FN, 50)
84
23
     RELOC_NUMBER (R_XTENSA_TLSDESC_ARG, 51)
85
5
     RELOC_NUMBER (R_XTENSA_TLS_DTPOFF, 52)
86
12
     RELOC_NUMBER (R_XTENSA_TLS_TPOFF, 53)
87
4
     RELOC_NUMBER (R_XTENSA_TLS_FUNC, 54)
88
4
     RELOC_NUMBER (R_XTENSA_TLS_ARG, 55)
89
1
     RELOC_NUMBER (R_XTENSA_TLS_CALL, 56)
90
53
     RELOC_NUMBER (R_XTENSA_PDIFF8, 57)
91
259
     RELOC_NUMBER (R_XTENSA_PDIFF16, 58)
92
23
     RELOC_NUMBER (R_XTENSA_PDIFF32, 59)
93
168
     RELOC_NUMBER (R_XTENSA_NDIFF8, 60)
94
60
     RELOC_NUMBER (R_XTENSA_NDIFF16, 61)
95
13
     RELOC_NUMBER (R_XTENSA_NDIFF32, 62)
96
     /* Positive same-section difference encoded as uleb128; rewritten
97
  in place after relaxation without changing the section size.  */
98
2
     RELOC_NUMBER (R_XTENSA_PDIFF_ULEB128, 63)
99
1.24k
END_RELOC_NUMBERS (R_XTENSA_max)
100
101
/* Processor-specific flags for the ELF header e_flags field.  */
102
103
/* Four-bit Xtensa machine type field.  */
104
5.77k
#define EF_XTENSA_MACH      0x0000000f
105
106
/* Various CPU types.  */
107
5.75k
#define E_XTENSA_MACH     0x00000000
108
109
/* Leave bits 0xf0 alone in case we ever have more than 16 cpu types.
110
   Highly unlikely, but what the heck.  */
111
112
1.47k
#define EF_XTENSA_XT_INSN   0x00000100
113
1.47k
#define EF_XTENSA_XT_LIT    0x00000200
114
115
116
/* Processor-specific dynamic array tags.  */
117
118
/* Offset of the table that records the GOT location(s).  */
119
0
#define DT_XTENSA_GOT_LOC_OFF   0x70000000
120
121
/* Number of entries in the GOT location table.  */
122
0
#define DT_XTENSA_GOT_LOC_SZ    0x70000001
123
124
125
/* Definitions for instruction and literal property tables.  The
126
   tables for ".gnu.linkonce.*" sections are placed in the following
127
   sections:
128
129
   instruction tables:  .gnu.linkonce.x.*
130
   literal tables:  .gnu.linkonce.p.*
131
*/
132
133
5.59k
#define XTENSA_INSN_SEC_NAME ".xt.insn"
134
0
#define XTENSA_LIT_SEC_NAME  ".xt.lit"
135
5.59k
#define XTENSA_PROP_SEC_NAME ".xt.prop"
136
137
typedef struct property_table_entry_t
138
{
139
  bfd_vma address;
140
  bfd_vma size;
141
  flagword flags;
142
} property_table_entry;
143
144
/* Flags in the property tables to specify whether blocks of memory are
145
   literals, instructions, data, or unreachable.  For instructions,
146
   blocks that begin loop targets and branch targets are designated.
147
   Blocks that do not allow density instructions, instruction reordering
148
   or transformation are also specified.  Finally, for branch targets,
149
   branch target alignment priority is included.  Alignment of the next
150
   block is specified in the current block and the size of the current
151
   block does not include any fill required to align to the next
152
   block.  */
153
   
154
0
#define XTENSA_PROP_LITERAL   0x00000001
155
0
#define XTENSA_PROP_INSN    0x00000002
156
5.59k
#define XTENSA_PROP_DATA    0x00000004
157
0
#define XTENSA_PROP_UNREACHABLE   0x00000008
158
/* Instruction-only properties at beginning of code. */
159
0
#define XTENSA_PROP_INSN_LOOP_TARGET  0x00000010
160
0
#define XTENSA_PROP_INSN_BRANCH_TARGET  0x00000020
161
/* Instruction-only properties about code. */
162
0
#define XTENSA_PROP_INSN_NO_DENSITY 0x00000040
163
0
#define XTENSA_PROP_INSN_NO_REORDER 0x00000080
164
/* Historically, NO_TRANSFORM was a property of instructions, 
165
   but it should apply to literals under certain circumstances.  */
166
5.59k
#define XTENSA_PROP_NO_TRANSFORM  0x00000100
167
168
/*  Branch target alignment information.  This transmits information
169
    to the linker optimization about the priority of aligning a
170
    particular block for branch target alignment: None, low priority,
171
    high priority, or required.  These only need to be checked in
172
    instruction blocks marked as XTENSA_PROP_INSN_BRANCH_TARGET.
173
    Common usage is:
174
175
    switch (GET_XTENSA_PROP_BT_ALIGN(flags))
176
    case XTENSA_PROP_BT_ALIGN_NONE:
177
    case XTENSA_PROP_BT_ALIGN_LOW:
178
    case XTENSA_PROP_BT_ALIGN_HIGH:
179
    case XTENSA_PROP_BT_ALIGN_REQUIRE:
180
*/
181
#define XTENSA_PROP_BT_ALIGN_MASK       0x00000600
182
183
/* No branch target alignment.  */
184
#define XTENSA_PROP_BT_ALIGN_NONE       0x0
185
/* Low priority branch target alignment.  */
186
#define XTENSA_PROP_BT_ALIGN_LOW        0x1
187
/* High priority branch target alignment. */
188
#define XTENSA_PROP_BT_ALIGN_HIGH       0x2
189
/* Required branch target alignment.  */
190
#define XTENSA_PROP_BT_ALIGN_REQUIRE    0x3
191
192
#define GET_XTENSA_PROP_BT_ALIGN(flag) \
193
  (((unsigned)((flag) & (XTENSA_PROP_BT_ALIGN_MASK))) >> 9)
194
#define SET_XTENSA_PROP_BT_ALIGN(flag, align) \
195
  (((flag) & (~XTENSA_PROP_BT_ALIGN_MASK)) | \
196
    (((align) << 9) & XTENSA_PROP_BT_ALIGN_MASK))
197
198
/* Alignment is specified in the block BEFORE the one that needs
199
   alignment.  Up to 5 bits.  Use GET_XTENSA_PROP_ALIGNMENT(flags) to
200
   get the required alignment specified as a power of 2.  Use
201
   SET_XTENSA_PROP_ALIGNMENT(flags, pow2) to set the required
202
   alignment.  Be careful of side effects since the SET will evaluate
203
   flags twice.  Also, note that the SIZE of a block in the property
204
   table does not include the alignment size, so the alignment fill
205
   must be calculated to determine if two blocks are contiguous.
206
   TEXT_ALIGN is not currently implemented but is a placeholder for a
207
   possible future implementation.  */
208
209
0
#define XTENSA_PROP_ALIGN   0x00000800
210
211
0
#define XTENSA_PROP_ALIGNMENT_MASK      0x0001f000
212
213
#define GET_XTENSA_PROP_ALIGNMENT(flag) \
214
0
  (((unsigned)((flag) & (XTENSA_PROP_ALIGNMENT_MASK))) >> 12)
215
#define SET_XTENSA_PROP_ALIGNMENT(flag, align) \
216
  (((flag) & (~XTENSA_PROP_ALIGNMENT_MASK)) | \
217
    (((align) << 12) & XTENSA_PROP_ALIGNMENT_MASK))
218
219
#define XTENSA_PROP_INSN_ABSLIT        0x00020000
220
221
extern char *xtensa_property_section_name (asection *, const char *, bool);
222
extern int
223
xtensa_read_table_entries (bfd *abfd,
224
         asection *section,
225
         property_table_entry **table_p,
226
         const char *sec_name,
227
         bool output_addr);
228
extern int
229
xtensa_compute_fill_extra_space (property_table_entry *entry);
230
231
extern int
232
xtensa_abi_choice (void);
233
234
#ifdef __cplusplus
235
}
236
#endif
237
238
#endif /* _ELF_XTENSA_H */