|
|
1.1 ! root 1: /* GDB symbol table format definitions. ! 2: Copyright (C) 1986 Free Software Foundation, Inc. ! 3: ! 4: GDB is distributed in the hope that it will be useful, but WITHOUT ANY ! 5: WARRANTY. No author or distributor accepts responsibility to anyone ! 6: for the consequences of using it or for whether it serves any ! 7: particular purpose or works at all, unless he says so in writing. ! 8: Refer to the GDB General Public License for full details. ! 9: ! 10: Everyone is granted permission to copy, modify and redistribute GDB, ! 11: but only under the conditions described in the GDB General Public ! 12: License. A copy of this license is supposed to have been given to you ! 13: along with GDB so you can know your rights and responsibilities. It ! 14: should be in a file named COPYING. Among other things, the copyright ! 15: notice and this notice must be preserved on all copies. ! 16: ! 17: In other words, go ahead and share GDB, but don't try to stop ! 18: anyone else from sharing it farther. Help stamp out software hoarding! ! 19: */ ! 20: ! 21: /* Format of GDB symbol table data. ! 22: There is one symbol segment for each source file or ! 23: independant compilation. These segments are simply concatenated ! 24: to form the GDB symbol table. A zero word where the beginning ! 25: of a segment is expected indicates there are no more segments. ! 26: ! 27: Format of a symbol segment: ! 28: ! 29: The symbol segment begins with a word containing 1 ! 30: if it is in the format described here. Other formats may ! 31: be designed, with other code numbers. ! 32: ! 33: The segment contains many objects which point at each other. ! 34: The pointers are offsets in bytes from the beginning of the segment. ! 35: Thus, each segment can be loaded into core and its pointers relocated ! 36: to make valid in-core pointers. ! 37: ! 38: All the data objects in the segment can be found indirectly from ! 39: one of them, the root object, of type `struct symbol_root'. ! 40: It appears at the beginning of the segment. ! 41: ! 42: The total size of the segment, in bytes, appears as the `length' ! 43: field of this object. This size includes the size of the ! 44: root object. ! 45: ! 46: All the object data types are defined here to contain pointer types ! 47: appropriate for in-core use on a relocated symbol segment. ! 48: Casts to and from type int are required for working with ! 49: unrelocated symbol segments such as are found in the file. ! 50: ! 51: The ldsymaddr word is filled in by the loader to contain ! 52: the offset (in bytes) within the ld symbol table ! 53: of the first nonglobal symbol from this compilation. ! 54: This makes it possible to match those symbols ! 55: (which contain line number information) reliably with ! 56: the segment they go with. ! 57: ! 58: Core addresses within the program that appear in the symbol segment ! 59: are not relocated by the loader. They are inserted by the assembler ! 60: and apply to addresses as output by the assembler, so GDB must ! 61: relocate them when it loads the symbol segment. It gets the information ! 62: on how to relocate from the textrel, datarel, bssrel, databeg and bssbeg ! 63: words of the root object. ! 64: ! 65: The words textrel, datarel and bssrel ! 66: are filled in by ld with the amounts to relocate within-the-file ! 67: text, data and bss addresses by; databeg and bssbeg can be ! 68: used to tell which kind of relocation an address needs. */ ! 69: ! 70: enum language {language_c}; ! 71: ! 72: /* ! 73: * All symbol roots must have as their first two fields format and length ! 74: * fields. The total length of the symbol root must be a multiple of ! 75: * sizeof(long) and any padding must be zeroed. ! 76: */ ! 77: struct symbol_root_header ! 78: { ! 79: int format; /* type of symbol segment */ ! 80: int length; /* # bytes in this symbol segment, rounded to sizeof(long) */ ! 81: }; ! 82: ! 83: /* ! 84: * Constants for symbol root format fields ! 85: */ ! 86: #define SYMBOL_ROOT_FORMAT 1 ! 87: #define INDIRECT_ROOT_FORMAT 1002 ! 88: #define COMMON_ROOT_FORMAT 1003 ! 89: #define SHLIB_ROOT_FORMAT 1004 ! 90: #define ALIAS_ROOT_FORMAT 1005 ! 91: #define MACH_ROOT_FORMAT 2001 ! 92: #define MACH_INDIRECT_ROOT_FORMAT 2002 ! 93: #define MACH_SHLIB_ROOT_FORMAT 2004 ! 94: ! 95: ! 96: struct symbol_root ! 97: { ! 98: int format; /* SYMBOL_ROOT_FORMAT */ ! 99: int length; /* # bytes in this symbol segment */ ! 100: int ldsymoff; /* Offset in ld symtab of this file's syms */ ! 101: int textrel; /* Relocation for text addresses */ ! 102: int datarel; /* Relocation for data addresses */ ! 103: int bssrel; /* Relocation for bss addresses */ ! 104: char *filename; /* Name of main source file compiled */ ! 105: char *filedir; /* Name of directory it was reached from */ ! 106: struct blockvector *blockvector; /* Vector of all symbol-naming blocks */ ! 107: struct typevector *typevector; /* Vector of all data types */ ! 108: enum language language; /* Code identifying the language used */ ! 109: char *version; /* Version info. Not fully specified */ ! 110: char *compilation; /* Compilation info. Not fully specified */ ! 111: int databeg; /* Address within the file of data start */ ! 112: int bssbeg; /* Address within the file of bss start */ ! 113: struct sourcevector *sourcevector; /* Vector of line-number info */ ! 114: }; ! 115: ! 116: struct mach_root ! 117: { ! 118: int format; /* MACH_ROOT_FORMAT */ ! 119: int length; /* # bytes in this symbol segment */ ! 120: int ldsymoff; /* Offset in ld symtab of this file's syms */ ! 121: struct loadmap *loadmap; /* load map of the relocatable object */ ! 122: char *filename; /* Name of main source file compiled */ ! 123: char *filedir; /* Name of directory it was reached from */ ! 124: struct blockvector *blockvector; /* Vector of all symbol-naming blocks */ ! 125: struct typevector *typevector; /* Vector of all data types */ ! 126: enum language language; /* Code identifying the language used */ ! 127: char *version; /* Version info. Not fully specified */ ! 128: char *compilation; /* Compilation info. Not fully specified */ ! 129: struct sourcevector *sourcevector; /* Vector of line-number info */ ! 130: }; ! 131: ! 132: /* ! 133: * Indirect symbol root format. Written by ld when -g is used (the default). ! 134: * This is for lazy evaluation of the -gg symbol segments. ! 135: */ ! 136: struct indirect_root { ! 137: int format; /* INDIRECT_ROOT_FORMAT */ ! 138: int length; /* length of this struct, rounded to sizeof(long) */ ! 139: int ldsymoff; /* Offset in ld symtab of this file's syms */ ! 140: int textrel; /* Relocation for text addresses */ ! 141: int datarel; /* Relocation for data addresses */ ! 142: int bssrel; /* Relocation for bss addresses */ ! 143: int textsize; /* text size */ ! 144: int datasize; /* data size */ ! 145: int bsssize; /* bss size */ ! 146: int mtime; /* last modified time, as returned by stat(2) */ ! 147: int fileoffset; /* Offset in file that contains symbol_root */ ! 148: char filename[1]; /* variable length file name, zero padded */ ! 149: }; ! 150: ! 151: /* ! 152: * Mach indirect symbol root format. Written by ld when -g is used (the ! 153: * default). This is for lazy evaluation of the -gg symbol segments. ! 154: */ ! 155: struct mach_indirect_root { ! 156: int format; /* MACH_INDIRECT_ROOT_FORMAT */ ! 157: int length; /* length of this struct, rounded to sizeof(long) */ ! 158: int ldsymoff; /* Offset in ld symtab of this file's syms */ ! 159: struct loadmap *loadmap; /* load map of the relocatable object */ ! 160: int mtime; /* last modified time, as returned by stat(2) */ ! 161: int fileoffset; /* Offset in relocatable file that contains the ! 162: mach_root */ ! 163: char filename[1]; /* variable length file name, zero padded */ ! 164: }; ! 165: ! 166: /* ! 167: * common symbol root format. For each common symbol that the link editor ! 168: * defines the storage for that symbol name is recorded in here. ! 169: */ ! 170: struct common_root { ! 171: int format; /* COMMON_SYM_FORMAT */ ! 172: int length; /* length of this struct, rounded to sizeof(long) */ ! 173: int nsyms; /* the number of strings in the data[] field for the ! 174: common symbols names of this file */ ! 175: char data[1]; ! 176: /* Data looks like the following: ! 177: - Null terminated string for the filename. ! 178: - Null terminated stings for syms. ! 179: ... ! 180: - zero padded to round to sizeof(long) ! 181: */ ! 182: }; ! 183: ! 184: /* ! 185: * shlib_root: Written by ld for target shared library output. This has two ! 186: * fields for each of the data segment fields. The data segments of .o files ! 187: * that go into target shared libraries have all their static data first in ! 188: * the data segment followed by all the global data. When it is loaded into ! 189: * a target shared library the global data from all the .o files is placed ! 190: * first in the data segment then all of the static data. So this information ! 191: * is reflected in the {global,static}datarel and the {global,static}databeg ! 192: * fields. ! 193: * ! 194: * After one of these has been written for each object in the shared library ! 195: * then the symbol root from each object is written into the shared library. ! 196: */ ! 197: struct shlib_root { ! 198: int format; /* SHLIB_ROOT_FORMAT */ ! 199: int length; /* length of this struct, rounded to sizeof(long) */ ! 200: int ldsymoff; /* Offset in ld symtab of this file's syms */ ! 201: int textrel; /* Relocation for text addresses */ ! 202: int globaldatarel; /* Relocation for global data addresses */ ! 203: int staticdatarel; /* Relocation for static data addresses */ ! 204: int globaldatabeg; /* Address of the global data start */ ! 205: int staticdatabeg; /* Address of the static data start */ ! 206: int globaldatasize; /* global data size */ ! 207: int staticdatasize; /* static data size */ ! 208: int symreloffset; /* relitive offset, from the first SYMBOL_ROOT_FORMAT ! 209: of the symbol root for this file */ ! 210: char filename[1]; /* variable length file name, zero padded */ ! 211: }; ! 212: ! 213: struct mach_shlib_root { ! 214: int format; /* MACH_SHLIB_ROOT_FORMAT */ ! 215: int length; /* length of this struct, rounded to sizeof(long) */ ! 216: int ldsymoff; /* Offset in ld symtab of this file's syms */ ! 217: struct loadmap *loadmap; /* load map of the relocatable object */ ! 218: int symreloffset; /* relitive offset, from the first SYMBOL_ROOT_FORMAT ! 219: of the symbol root for this file */ ! 220: char filename[1]; /* variable length file name, zero padded */ ! 221: }; ! 222: ! 223: /* ! 224: * This format is used when the link-editor alias option -a original:alias ! 225: * is used when producing an output file. This option changes symbols in ! 226: * the .o file from 'original' to 'alias' in the a.out file. ! 227: */ ! 228: struct alias_root { ! 229: int format; /* ALIAS_SYM_FORMAT */ ! 230: int length; /* length of this struct, rounded to sizeof(long) */ ! 231: int naliases; /* number of pairs of aliased symbols */ ! 232: char data[1]; ! 233: /* Data looks like the following: ! 234: - Pairs of: ! 235: - Null terminated string for the original symbol ! 236: - Null terminated string for the aliased symbol ! 237: - zero padded to round to sizeof(long) ! 238: */ ! 239: }; ! 240: ! 241: /* ! 242: * The load map describes where the parts the relocatable object have been ! 243: * loaded in the executable. The enitre address space of the relocatable ! 244: * is to be covered by all the map entries. There may be multiple map entries ! 245: * for a single section or one map entry for multiple sections. This allows ! 246: * the link editor to scatter load a section based on information that improves ! 247: * performance by increasing the locality of reference. ! 248: */ ! 249: struct loadmap ! 250: { ! 251: /* Number of maps in the list. */ ! 252: int nmaps; ! 253: /* The maps themselves. */ ! 254: struct map *map[1]; ! 255: }; ! 256: struct map ! 257: { ! 258: /* The starting address in the relocatable object and size of part of the ! 259: object file. */ ! 260: int reladdr, size; ! 261: /* The address the loader loaded this part of the object file at */ ! 262: int ldaddr; ! 263: }; ! 264: ! 265: ! 266: /* All data types of symbols in the compiled program ! 267: are represented by `struct type' objects. ! 268: All of these objects are pointed to by the typevector. ! 269: The type vector may have empty slots that contain zero. */ ! 270: ! 271: struct typevector ! 272: { ! 273: int length; /* Number of types described */ ! 274: struct type *type[1]; ! 275: }; ! 276: ! 277: /* Different kinds of data types are distinguished by the `code' field. */ ! 278: ! 279: enum type_code ! 280: { ! 281: TYPE_CODE_UNDEF, /* Not used; catches errors */ ! 282: TYPE_CODE_PTR, /* Pointer type */ ! 283: TYPE_CODE_ARRAY, /* Array type, lower bound zero */ ! 284: TYPE_CODE_STRUCT, /* C struct or Pascal record */ ! 285: TYPE_CODE_UNION, /* C union or Pascal variant part */ ! 286: TYPE_CODE_ENUM, /* Enumeration type */ ! 287: TYPE_CODE_FUNC, /* Function type */ ! 288: TYPE_CODE_INT, /* Integer type */ ! 289: TYPE_CODE_FLT, /* Floating type */ ! 290: TYPE_CODE_VOID, /* Void type (values zero length) */ ! 291: TYPE_CODE_SET, /* Pascal sets */ ! 292: TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */ ! 293: TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */ ! 294: }; ! 295: ! 296: /* This appears in a type's flags word for an unsigned integer type. */ ! 297: #define TYPE_FLAG_UNSIGNED 1 ! 298: ! 299: /* Other flag bits are used with GDB. */ ! 300: ! 301: struct type ! 302: { ! 303: /* Code for kind of type */ ! 304: enum type_code code; ! 305: /* Name of this type, or zero if none. ! 306: This is used for printing only. ! 307: Type names specified as input are defined by symbols. */ ! 308: char *name; ! 309: /* Length in bytes of storage for a value of this type */ ! 310: int length; ! 311: /* For a pointer type, describes the type of object pointed to. ! 312: For an array type, describes the type of the elements. ! 313: For a function type, describes the type of the value. ! 314: Unused otherwise. */ ! 315: struct type *target_type; ! 316: /* Type that is a pointer to this type. ! 317: Zero if no such pointer-to type is known yet. ! 318: The debugger may add the address of such a type ! 319: if it has to construct one later. */ ! 320: struct type *pointer_type; ! 321: /* Type that is a function returning this type. ! 322: Zero if no such function type is known here. ! 323: The debugger may add the address of such a type ! 324: if it has to construct one later. */ ! 325: struct type *function_type; ! 326: /* Flags about this type. */ ! 327: short flags; ! 328: /* Number of fields described for this type */ ! 329: short nfields; ! 330: /* For structure and union types, a description of each field. ! 331: For set and pascal array types, there is one "field", ! 332: whose type is the domain type of the set or array. ! 333: For range types, there are two "fields", ! 334: the minimum and maximum values (both inclusive). ! 335: For enum types, each possible value is described by one "field". ! 336: For range types, there are two "fields", that record constant values ! 337: (inclusive) for the minimum and maximum. ! 338: ! 339: Using a pointer to a separate array of fields ! 340: allows all types to have the same size, which is useful ! 341: because we can allocate the space for a type before ! 342: we know what to put in it. */ ! 343: struct field ! 344: { ! 345: /* Position of this field, counting in bits from start of ! 346: containing structure. For a function type, this is the ! 347: position in the argument list of this argument. ! 348: For a range bound or enum value, this is the value itself. */ ! 349: int bitpos; ! 350: /* Size of this field, in bits, or zero if not packed. ! 351: For an unpacked field, the field's type's length ! 352: says how many bytes the field occupies. */ ! 353: int bitsize; ! 354: /* In a struct or enum type, type of this field. ! 355: In a function type, type of this argument. ! 356: In an array type, the domain-type of the array. */ ! 357: struct type *type; ! 358: /* Name of field, value or argument. ! 359: Zero for range bounds and array domains. */ ! 360: char *name; ! 361: } *fields; ! 362: }; ! 363: ! 364: /* All of the name-scope contours of the program ! 365: are represented by `struct block' objects. ! 366: All of these objects are pointed to by the blockvector. ! 367: ! 368: Each block represents one name scope. ! 369: Each lexical context has its own block. ! 370: ! 371: The first two blocks in the blockvector are special. ! 372: The first one contains all the symbols defined in this compilation ! 373: whose scope is the entire program linked together. ! 374: The second one contains all the symbols whose scope is the ! 375: entire compilation excluding other separate compilations. ! 376: In C, these correspond to global symbols and static symbols. ! 377: ! 378: Each block records a range of core addresses for the code that ! 379: is in the scope of the block. The first two special blocks ! 380: give, for the range of code, the entire range of code produced ! 381: by the compilation that the symbol segment belongs to. ! 382: ! 383: The blocks appear in the blockvector ! 384: in order of increasing starting-address, ! 385: and, within that, in order of decreasing ending-address. ! 386: ! 387: This implies that within the body of one function ! 388: the blocks appear in the order of a depth-first tree walk. */ ! 389: ! 390: struct blockvector ! 391: { ! 392: /* Number of blocks in the list. */ ! 393: int nblocks; ! 394: /* The blocks themselves. */ ! 395: struct block *block[1]; ! 396: }; ! 397: ! 398: struct block ! 399: { ! 400: /* Addresses in the executable code that are in this block. ! 401: Note: in an unrelocated symbol segment in a file, ! 402: these are always zero. They can be filled in from the ! 403: N_LBRAC and N_RBRAC symbols in the loader symbol table. */ ! 404: int startaddr, endaddr; ! 405: /* The symbol that names this block, ! 406: if the block is the body of a function; ! 407: otherwise, zero. ! 408: Note: In an unrelocated symbol segment in an object file, ! 409: this field may be zero even when the block has a name. ! 410: That is because the block is output before the name ! 411: (since the name resides in a higher block). ! 412: Since the symbol does point to the block (as its value), ! 413: it is possible to find the block and set its name properly. */ ! 414: struct symbol *function; ! 415: /* The `struct block' for the containing block, or 0 if none. */ ! 416: /* Note that in an unrelocated symbol segment in an object file ! 417: this pointer may be zero when the correct value should be ! 418: the second special block (for symbols whose scope is one compilation). ! 419: This is because the compiler ouptuts the special blocks at the ! 420: very end, after the other blocks. */ ! 421: struct block *superblock; ! 422: /* Number of local symbols. */ ! 423: int nsyms; ! 424: /* The symbols. */ ! 425: struct symbol *sym[1]; ! 426: }; ! 427: ! 428: /* Represent one symbol name; a variable, constant, function or typedef. */ ! 429: ! 430: /* Different name spaces for symbols. Looking up a symbol specifies ! 431: a namespace and ignores symbol definitions in other name spaces. ! 432: ! 433: VAR_NAMESPACE is the usual namespace. ! 434: In C, this contains variables, function names, typedef names ! 435: and enum type values. ! 436: ! 437: STRUCT_NAMESPACE is used in C to hold struct, union and enum type names. ! 438: Thus, if `struct foo' is used in a C program, ! 439: it produces a symbol named `foo' in the STRUCT_NAMESPACE. ! 440: ! 441: LABEL_NAMESPACE may be used for names of labels (for gotos); ! 442: currently it is not used and labels are not recorded at all. */ ! 443: ! 444: /* For a non-global symbol allocated statically, ! 445: the correct core address cannot be determined by the compiler. ! 446: The compiler puts an index number into the symbol's value field. ! 447: This index number can be matched with the "desc" field of ! 448: an entry in the loader symbol table. */ ! 449: ! 450: enum namespace ! 451: { ! 452: UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE, ! 453: }; ! 454: ! 455: /* An address-class says where to find the value of the symbol in core. */ ! 456: ! 457: enum address_class ! 458: { ! 459: LOC_UNDEF, /* Not used; catches errors */ ! 460: LOC_CONST, /* Value is constant int */ ! 461: LOC_STATIC, /* Value is at fixed address */ ! 462: LOC_REGISTER, /* Value is in register */ ! 463: LOC_ARG, /* Value is at spec'd position in arglist */ ! 464: LOC_LOCAL, /* Value is at spec'd pos in stack frame */ ! 465: LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE ! 466: Symbols in the namespace STRUCT_NAMESPACE ! 467: all have this class. */ ! 468: LOC_LABEL, /* Value is address in the code */ ! 469: LOC_BLOCK, /* Value is address of a `struct block'. ! 470: Function names have this class. */ ! 471: LOC_EXTERNAL, /* Value is at address not in this compilation. ! 472: This is used for .comm symbols ! 473: and for extern symbols within functions. ! 474: Inside GDB, this is changed to LOC_STATIC once the ! 475: real address is obtained from a loader symbol. */ ! 476: LOC_CONST_BYTES /* Value is a constant byte-sequence. */ ! 477: }; ! 478: ! 479: struct symbol ! 480: { ! 481: /* Symbol name */ ! 482: char *name; ! 483: /* Name space code. */ ! 484: enum namespace namespace; ! 485: /* Address class */ ! 486: enum address_class class; ! 487: /* Data type of value */ ! 488: struct type *type; ! 489: /* constant value, or address if static, or register number, ! 490: or offset in arguments, or offset in stack frame. */ ! 491: union ! 492: { ! 493: long value; ! 494: struct block *block; /* for LOC_BLOCK */ ! 495: char *bytes; /* for LOC_CONST_BYTES */ ! 496: } ! 497: value; ! 498: }; ! 499: ! 500: /* Source-file information. ! 501: This describes the relation between source files and line numbers ! 502: and addresses in the program text. */ ! 503: ! 504: struct sourcevector ! 505: { ! 506: int length; /* Number of source files described */ ! 507: struct source *source[1]; /* Descriptions of the files */ ! 508: }; ! 509: ! 510: /* Each item is either minus a line number, or a program counter. ! 511: If it represents a line number, that is the line described by the next ! 512: program counter value. If it is positive, it is the program ! 513: counter at which the code for the next line starts. ! 514: ! 515: Consecutive lines can be recorded by program counter entries ! 516: with no line number entries between them. Line number entries ! 517: are used when there are lines to skip with no code on them. ! 518: This is to make the table shorter. */ ! 519: ! 520: struct linetable ! 521: { ! 522: int nitems; ! 523: int item[1]; ! 524: }; ! 525: ! 526: /* All the information on one source file. */ ! 527: ! 528: struct source ! 529: { ! 530: char *name; /* Name of file */ ! 531: struct linetable contents; ! 532: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.