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