3 * This code is derived from software copyrighted by the Free Software
6 * from: @(#)symseg.h 5.4 (Berkeley) 4/30/91
7 * $FreeBSD: src/gnu/usr.bin/ld/symseg.h,v 1.7 1999/08/27 23:36:02 peter Exp $
10 /* GDB symbol table format definitions.
11 Copyright (C) 1987, 1988 Free Software Foundation, Inc.
13 This file is part of GNU CC.
15 GNU CC is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 1, or (at your option)
20 GNU CC is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with GNU CC; see the file COPYING. If not, write to
27 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
29 /* Format of GDB symbol table data.
30 There is one symbol segment for each source file or
31 independant compilation. These segments are simply concatenated
32 to form the GDB symbol table. A zero word where the beginning
33 of a segment is expected indicates there are no more segments.
35 Format of a symbol segment:
37 The symbol segment begins with a word containing 1
38 if it is in the format described here. Other formats may
39 be designed, with other code numbers.
41 The segment contains many objects which point at each other.
42 The pointers are offsets in bytes from the beginning of the segment.
43 Thus, each segment can be loaded into core and its pointers relocated
44 to make valid in-core pointers.
46 All the data objects in the segment can be found indirectly from
47 one of them, the root object, of type `struct symbol_root'.
48 It appears at the beginning of the segment.
50 The total size of the segment, in bytes, appears as the `length'
51 field of this object. This size includes the size of the
54 All the object data types are defined here to contain pointer types
55 appropriate for in-core use on a relocated symbol segment.
56 Casts to and from type int are required for working with
57 unrelocated symbol segments such as are found in the file.
59 The ldsymaddr word is filled in by the loader to contain
60 the offset (in bytes) within the ld symbol table
61 of the first nonglobal symbol from this compilation.
62 This makes it possible to match those symbols
63 (which contain line number information) reliably with
64 the segment they go with.
66 Core addresses within the program that appear in the symbol segment
67 are not relocated by the loader. They are inserted by the assembler
68 and apply to addresses as output by the assembler, so GDB must
69 relocate them when it loads the symbol segment. It gets the information
70 on how to relocate from the textrel, datarel, bssrel, databeg and bssbeg
71 words of the root object.
73 The words textrel, datarel and bssrel
74 are filled in by ld with the amounts to relocate within-the-file
75 text, data and bss addresses by; databeg and bssbeg can be
76 used to tell which kind of relocation an address needs. */
78 enum language {language_c};
82 int format; /* Data format version */
83 int length; /* # bytes in this symbol segment */
84 int ldsymoff; /* Offset in ld symtab of this file's syms */
85 int textrel; /* Relocation for text addresses */
86 int datarel; /* Relocation for data addresses */
87 int bssrel; /* Relocation for bss addresses */
88 char *filename; /* Name of main source file compiled */
89 char *filedir; /* Name of directory it was reached from */
90 struct blockvector *blockvector; /* Vector of all symbol-naming blocks */
91 struct typevector *typevector; /* Vector of all data types */
92 enum language language; /* Code identifying the language used */
93 char *version; /* Version info. Not fully specified */
94 char *compilation; /* Compilation info. Not fully specified */
95 int databeg; /* Address within the file of data start */
96 int bssbeg; /* Address within the file of bss start */
97 struct sourcevector *sourcevector; /* Vector of line-number info */
100 /* All data types of symbols in the compiled program
101 are represented by `struct type' objects.
102 All of these objects are pointed to by the typevector.
103 The type vector may have empty slots that contain zero. */
107 int length; /* Number of types described */
108 struct type *type[1];
111 /* Different kinds of data types are distinguished by the `code' field. */
115 TYPE_CODE_UNDEF, /* Not used; catches errors */
116 TYPE_CODE_PTR, /* Pointer type */
117 TYPE_CODE_ARRAY, /* Array type, lower bound zero */
118 TYPE_CODE_STRUCT, /* C struct or Pascal record */
119 TYPE_CODE_UNION, /* C union or Pascal variant part */
120 TYPE_CODE_ENUM, /* Enumeration type */
121 TYPE_CODE_FUNC, /* Function type */
122 TYPE_CODE_INT, /* Integer type */
123 TYPE_CODE_FLT, /* Floating type */
124 TYPE_CODE_VOID, /* Void type (values zero length) */
125 TYPE_CODE_SET, /* Pascal sets */
126 TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */
127 TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */
130 /* This appears in a type's flags word for an unsigned integer type. */
131 #define TYPE_FLAG_UNSIGNED 1
133 /* Other flag bits are used with GDB. */
137 /* Code for kind of type */
139 /* Name of this type, or zero if none.
140 This is used for printing only.
141 Type names specified as input are defined by symbols. */
143 /* Length in bytes of storage for a value of this type */
145 /* For a pointer type, describes the type of object pointed to.
146 For an array type, describes the type of the elements.
147 For a function type, describes the type of the value.
149 struct type *target_type;
150 /* Type that is a pointer to this type.
151 Zero if no such pointer-to type is known yet.
152 The debugger may add the address of such a type
153 if it has to construct one later. */
154 struct type *pointer_type;
155 /* Type that is a function returning this type.
156 Zero if no such function type is known here.
157 The debugger may add the address of such a type
158 if it has to construct one later. */
159 struct type *function_type;
160 /* Flags about this type. */
162 /* Number of fields described for this type */
164 /* For structure and union types, a description of each field.
165 For set and pascal array types, there is one "field",
166 whose type is the domain type of the set or array.
167 For range types, there are two "fields",
168 the minimum and maximum values (both inclusive).
169 For enum types, each possible value is described by one "field".
170 For range types, there are two "fields", that record constant values
171 (inclusive) for the minimum and maximum.
173 Using a pointer to a separate array of fields
174 allows all types to have the same size, which is useful
175 because we can allocate the space for a type before
176 we know what to put in it. */
179 /* Position of this field, counting in bits from start of
180 containing structure. For a function type, this is the
181 position in the argument list of this argument.
182 For a range bound or enum value, this is the value itself. */
184 /* Size of this field, in bits, or zero if not packed.
185 For an unpacked field, the field's type's length
186 says how many bytes the field occupies. */
188 /* In a struct or enum type, type of this field.
189 In a function type, type of this argument.
190 In an array type, the domain-type of the array. */
192 /* Name of field, value or argument.
193 Zero for range bounds and array domains. */
198 /* All of the name-scope contours of the program
199 are represented by `struct block' objects.
200 All of these objects are pointed to by the blockvector.
202 Each block represents one name scope.
203 Each lexical context has its own block.
205 The first two blocks in the blockvector are special.
206 The first one contains all the symbols defined in this compilation
207 whose scope is the entire program linked together.
208 The second one contains all the symbols whose scope is the
209 entire compilation excluding other separate compilations.
210 In C, these correspond to global symbols and static symbols.
212 Each block records a range of core addresses for the code that
213 is in the scope of the block. The first two special blocks
214 give, for the range of code, the entire range of code produced
215 by the compilation that the symbol segment belongs to.
217 The blocks appear in the blockvector
218 in order of increasing starting-address,
219 and, within that, in order of decreasing ending-address.
221 This implies that within the body of one function
222 the blocks appear in the order of a depth-first tree walk. */
226 /* Number of blocks in the list. */
228 /* The blocks themselves. */
229 struct block *block[1];
234 /* Addresses in the executable code that are in this block.
235 Note: in an unrelocated symbol segment in a file,
236 these are always zero. They can be filled in from the
237 N_LBRAC and N_RBRAC symbols in the loader symbol table. */
238 int startaddr, endaddr;
239 /* The symbol that names this block,
240 if the block is the body of a function;
242 Note: In an unrelocated symbol segment in an object file,
243 this field may be zero even when the block has a name.
244 That is because the block is output before the name
245 (since the name resides in a higher block).
246 Since the symbol does point to the block (as its value),
247 it is possible to find the block and set its name properly. */
248 struct symbol *function;
249 /* The `struct block' for the containing block, or 0 if none. */
250 /* Note that in an unrelocated symbol segment in an object file
251 this pointer may be zero when the correct value should be
252 the second special block (for symbols whose scope is one compilation).
253 This is because the compiler ouptuts the special blocks at the
254 very end, after the other blocks. */
255 struct block *superblock;
256 /* Number of local symbols. */
259 struct symbol *sym[1];
262 /* Represent one symbol name; a variable, constant, function or typedef. */
264 /* Different name spaces for symbols. Looking up a symbol specifies
265 a namespace and ignores symbol definitions in other name spaces.
267 VAR_NAMESPACE is the usual namespace.
268 In C, this contains variables, function names, typedef names
269 and enum type values.
271 STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
272 Thus, if `struct foo' is used in a C program,
273 it produces a symbol named `foo' in the STRUCT_NAMESPACE.
275 LABEL_NAMESPACE may be used for names of labels (for gotos);
276 currently it is not used and labels are not recorded at all. */
278 /* For a non-global symbol allocated statically,
279 the correct core address cannot be determined by the compiler.
280 The compiler puts an index number into the symbol's value field.
281 This index number can be matched with the "desc" field of
282 an entry in the loader symbol table. */
286 UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE,
289 /* An address-class says where to find the value of the symbol in core. */
293 LOC_UNDEF, /* Not used; catches errors */
294 LOC_CONST, /* Value is constant int */
295 LOC_STATIC, /* Value is at fixed address */
296 LOC_REGISTER, /* Value is in register */
297 LOC_ARG, /* Value is at spec'd position in arglist */
298 LOC_LOCAL, /* Value is at spec'd pos in stack frame */
299 LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE
300 Symbols in the namespace STRUCT_NAMESPACE
301 all have this class. */
302 LOC_LABEL, /* Value is address in the code */
303 LOC_BLOCK, /* Value is address of a `struct block'.
304 Function names have this class. */
305 LOC_EXTERNAL, /* Value is at address not in this compilation.
306 This is used for .comm symbols
307 and for extern symbols within functions.
308 Inside GDB, this is changed to LOC_STATIC once the
309 real address is obtained from a loader symbol. */
310 LOC_CONST_BYTES /* Value is a constant byte-sequence. */
317 /* Name space code. */
318 enum namespace namespace;
320 enum address_class class;
321 /* Data type of value */
323 /* constant value, or address if static, or register number,
324 or offset in arguments, or offset in stack frame. */
328 struct block *block; /* for LOC_BLOCK */
329 char *bytes; /* for LOC_CONST_BYTES */
334 /* Source-file information.
335 This describes the relation between source files and line numbers
336 and addresses in the program text. */
340 int length; /* Number of source files described */
341 struct source *source[1]; /* Descriptions of the files */
344 /* Line number and address of one line. */
352 /* All the information on one source file. */
356 char *name; /* Name of file */
357 int nlines; /* Number of lines that follow */
358 struct line lines[1]; /* Information on each line */