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