1*fae548d3Szrj /* Public attributes of the .gdb_index section. 2*fae548d3Szrj Copyright (C) 2012-2020 Free Software Foundation, Inc. 3*fae548d3Szrj 4*fae548d3Szrj This file is part of GDB. 5*fae548d3Szrj 6*fae548d3Szrj This program is free software; you can redistribute it and/or modify 7*fae548d3Szrj it under the terms of the GNU General Public License as published by 8*fae548d3Szrj the Free Software Foundation; either version 3 of the License, or 9*fae548d3Szrj (at your option) any later version. 10*fae548d3Szrj 11*fae548d3Szrj This program is distributed in the hope that it will be useful, 12*fae548d3Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of 13*fae548d3Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*fae548d3Szrj GNU General Public License for more details. 15*fae548d3Szrj 16*fae548d3Szrj You should have received a copy of the GNU General Public License 17*fae548d3Szrj along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18*fae548d3Szrj 19*fae548d3Szrj /* This file contains values for understanding the .gdb_index section 20*fae548d3Szrj needed by more than just GDB, e.g. readelf. */ 21*fae548d3Szrj 22*fae548d3Szrj #ifndef GDB_INDEX_H 23*fae548d3Szrj #define GDB_INDEX_H 24*fae548d3Szrj 25*fae548d3Szrj /* Each symbol in .gdb_index refers to a set of CUs that defines the symbol. 26*fae548d3Szrj Each CU is represented by a 32 bit number that is the index of the CU in 27*fae548d3Szrj the CU table, plus some attributes of the use of the symbol in that CU. 28*fae548d3Szrj 29*fae548d3Szrj The values are defined such that if all the bits are zero, then no 30*fae548d3Szrj special meaning is assigned to any of them. This is done to preserve 31*fae548d3Szrj compatibility with older indices. The way this is done is to specify 32*fae548d3Szrj that if the GDB_INDEX_SYMBOL_KIND value is zero then all other attribute 33*fae548d3Szrj bits must be zero. 34*fae548d3Szrj 35*fae548d3Szrj 0-23 CU index 36*fae548d3Szrj 24-27 reserved 37*fae548d3Szrj 28-30 symbol kind 38*fae548d3Szrj 31 0 == global, 1 == static 39*fae548d3Szrj 40*fae548d3Szrj Bits 24-27 are reserved because it's easier to relax restrictions than 41*fae548d3Szrj it is to impose them after the fact. At present 24 bits to represent 42*fae548d3Szrj the CU index is plenty. If we need more bits for the CU index or for 43*fae548d3Szrj attributes then we have them. */ 44*fae548d3Szrj 45*fae548d3Szrj /* Whether the symbol is in GLOBAL_BLOCK (== 0) or STATIC_BLOCK (== 1). */ 46*fae548d3Szrj #define GDB_INDEX_SYMBOL_STATIC_SHIFT 31 47*fae548d3Szrj #define GDB_INDEX_SYMBOL_STATIC_MASK 1 48*fae548d3Szrj #define GDB_INDEX_SYMBOL_STATIC_VALUE(cu_index) \ 49*fae548d3Szrj (((cu_index) >> GDB_INDEX_SYMBOL_STATIC_SHIFT) & GDB_INDEX_SYMBOL_STATIC_MASK) 50*fae548d3Szrj #define GDB_INDEX_SYMBOL_STATIC_SET_VALUE(cu_index, value) \ 51*fae548d3Szrj do { \ 52*fae548d3Szrj (cu_index) |= (((value) & GDB_INDEX_SYMBOL_STATIC_MASK) \ 53*fae548d3Szrj << GDB_INDEX_SYMBOL_STATIC_SHIFT); \ 54*fae548d3Szrj } while (0) 55*fae548d3Szrj 56*fae548d3Szrj /* The kind of the symbol. 57*fae548d3Szrj We don't use GDB's internal values as these numbers are published 58*fae548d3Szrj so that other tools can build and read .gdb_index. */ 59*fae548d3Szrj 60*fae548d3Szrj typedef enum { 61*fae548d3Szrj /* Special value to indicate no attributes are present. */ 62*fae548d3Szrj GDB_INDEX_SYMBOL_KIND_NONE = 0, 63*fae548d3Szrj GDB_INDEX_SYMBOL_KIND_TYPE = 1, 64*fae548d3Szrj GDB_INDEX_SYMBOL_KIND_VARIABLE = 2, 65*fae548d3Szrj GDB_INDEX_SYMBOL_KIND_FUNCTION = 3, 66*fae548d3Szrj GDB_INDEX_SYMBOL_KIND_OTHER = 4, 67*fae548d3Szrj /* We currently allocate 3 bits to record the symbol kind. 68*fae548d3Szrj Give the unused bits a value so gdb will print them sensibly. */ 69*fae548d3Szrj GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5, 70*fae548d3Szrj GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6, 71*fae548d3Szrj GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7 72*fae548d3Szrj } gdb_index_symbol_kind; 73*fae548d3Szrj 74*fae548d3Szrj #define GDB_INDEX_SYMBOL_KIND_SHIFT 28 75*fae548d3Szrj #define GDB_INDEX_SYMBOL_KIND_MASK 7 76*fae548d3Szrj #define GDB_INDEX_SYMBOL_KIND_VALUE(cu_index) \ 77*fae548d3Szrj ((gdb_index_symbol_kind) (((cu_index) >> GDB_INDEX_SYMBOL_KIND_SHIFT) \ 78*fae548d3Szrj & GDB_INDEX_SYMBOL_KIND_MASK)) 79*fae548d3Szrj #define GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \ 80*fae548d3Szrj do { \ 81*fae548d3Szrj (cu_index) |= (((value) & GDB_INDEX_SYMBOL_KIND_MASK) \ 82*fae548d3Szrj << GDB_INDEX_SYMBOL_KIND_SHIFT); \ 83*fae548d3Szrj } while (0) 84*fae548d3Szrj 85*fae548d3Szrj #define GDB_INDEX_RESERVED_SHIFT 24 86*fae548d3Szrj #define GDB_INDEX_RESERVED_MASK 15 87*fae548d3Szrj #define GDB_INDEX_RESERVED_VALUE(cu_index) \ 88*fae548d3Szrj (((cu_index) >> GDB_INDEX_RESERVED_SHIFT) & GDB_INDEX_RESERVED_MASK) 89*fae548d3Szrj 90*fae548d3Szrj /* CU index. */ 91*fae548d3Szrj #define GDB_INDEX_CU_BITSIZE 24 92*fae548d3Szrj #define GDB_INDEX_CU_MASK ((1 << GDB_INDEX_CU_BITSIZE) - 1) 93*fae548d3Szrj #define GDB_INDEX_CU_VALUE(cu_index) ((cu_index) & GDB_INDEX_CU_MASK) 94*fae548d3Szrj #define GDB_INDEX_CU_SET_VALUE(cu_index, value) \ 95*fae548d3Szrj do { \ 96*fae548d3Szrj (cu_index) |= (value) & GDB_INDEX_CU_MASK; \ 97*fae548d3Szrj } while (0) 98*fae548d3Szrj 99*fae548d3Szrj #endif /* GDB_INDEX_H */ 100