Subversion Repositories Kolibri OS

Rev

Rev 5191 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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