1 /* Public attributes of the .gdb_index section.
2 Copyright (C) 2012-2017 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program 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 of the License, or
9 (at your option) any later version.
11 This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
19 /* This file contains values for understanding the .gdb_index section
20 needed by more than just GDB, e.g. readelf. */
25 /* Each symbol in .gdb_index refers to a set of CUs that defines the symbol.
26 Each CU is represented by a 32 bit number that is the index of the CU in
27 the CU table, plus some attributes of the use of the symbol in that CU.
29 The values are defined such that if all the bits are zero, then no
30 special meaning is assigned to any of them. This is done to preserve
31 compatibility with older indices. The way this is done is to specify
32 that if the GDB_INDEX_SYMBOL_KIND value is zero then all other attribute
38 31 0 == global, 1 == static
40 Bits 24-27 are reserved because it's easier to relax restrictions than
41 it is to impose them after the fact. At present 24 bits to represent
42 the CU index is plenty. If we need more bits for the CU index or for
43 attributes then we have them. */
45 /* Whether the symbol is in GLOBAL_BLOCK (== 0) or STATIC_BLOCK (== 1). */
46 #define GDB_INDEX_SYMBOL_STATIC_SHIFT 31
47 #define GDB_INDEX_SYMBOL_STATIC_MASK 1
48 #define GDB_INDEX_SYMBOL_STATIC_VALUE(cu_index) \
49 (((cu_index) >> GDB_INDEX_SYMBOL_STATIC_SHIFT) & GDB_INDEX_SYMBOL_STATIC_MASK)
50 #define GDB_INDEX_SYMBOL_STATIC_SET_VALUE(cu_index, value) \
52 (cu_index) |= (((value) & GDB_INDEX_SYMBOL_STATIC_MASK) \
53 << GDB_INDEX_SYMBOL_STATIC_SHIFT); \
56 /* The kind of the symbol.
57 We don't use GDB's internal values as these numbers are published
58 so that other tools can build and read .gdb_index. */
61 /* Special value to indicate no attributes are present. */
62 GDB_INDEX_SYMBOL_KIND_NONE
= 0,
63 GDB_INDEX_SYMBOL_KIND_TYPE
= 1,
64 GDB_INDEX_SYMBOL_KIND_VARIABLE
= 2,
65 GDB_INDEX_SYMBOL_KIND_FUNCTION
= 3,
66 GDB_INDEX_SYMBOL_KIND_OTHER
= 4,
67 /* We currently allocate 3 bits to record the symbol kind.
68 Give the unused bits a value so gdb will print them sensibly. */
69 GDB_INDEX_SYMBOL_KIND_UNUSED5
= 5,
70 GDB_INDEX_SYMBOL_KIND_UNUSED6
= 6,
71 GDB_INDEX_SYMBOL_KIND_UNUSED7
= 7
72 } gdb_index_symbol_kind
;
74 #define GDB_INDEX_SYMBOL_KIND_SHIFT 28
75 #define GDB_INDEX_SYMBOL_KIND_MASK 7
76 #define GDB_INDEX_SYMBOL_KIND_VALUE(cu_index) \
77 ((gdb_index_symbol_kind) (((cu_index) >> GDB_INDEX_SYMBOL_KIND_SHIFT) \
78 & GDB_INDEX_SYMBOL_KIND_MASK))
79 #define GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \
81 (cu_index) |= (((value) & GDB_INDEX_SYMBOL_KIND_MASK) \
82 << GDB_INDEX_SYMBOL_KIND_SHIFT); \
85 #define GDB_INDEX_RESERVED_SHIFT 24
86 #define GDB_INDEX_RESERVED_MASK 15
87 #define GDB_INDEX_RESERVED_VALUE(cu_index) \
88 (((cu_index) >> GDB_INDEX_RESERVED_SHIFT) & GDB_INDEX_RESERVED_MASK)
91 #define GDB_INDEX_CU_BITSIZE 24
92 #define GDB_INDEX_CU_MASK ((1 << GDB_INDEX_CU_BITSIZE) - 1)
93 #define GDB_INDEX_CU_VALUE(cu_index) ((cu_index) & GDB_INDEX_CU_MASK)
94 #define GDB_INDEX_CU_SET_VALUE(cu_index, value) \
96 (cu_index) |= (value) & GDB_INDEX_CU_MASK; \
99 #endif /* GDB_INDEX_H */