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