1STAB(5) 386BSD Programmer's Manual STAB(5) 2 3NNAAMMEE 4 ssttaabb - symbol table types 5 6SSYYNNOOPPSSIISS 7 ##iinncclluuddee <<ssttaabb..hh>> 8 9DDEESSCCRRIIPPTTIIOONN 10 The file <_s_t_a_b._h> defines some of the symbol table _n__t_y_p_e field values 11 for a.out files. These are the types for permanent symbols (i.e. not lo- 12 cal labels, etc.) used by the old debugger _s_d_b and the Berkeley Pascal 13 compiler pc(1). Symbol table entries can be produced by the ._s_t_a_b_s 14 assembler directive. This allows one to specify a double-quote delimited 15 name, a symbol type, one char and one short of information about the sym- 16 bol, and an unsigned long (usually an address). To avoid having to pro- 17 duce an explicit label for the address field, the ._s_t_a_b_d directive can be 18 used to implicitly address the current location. If no name is needed, 19 symbol table entries can be generated using the ._s_t_a_b_n directive. The 20 loader promises to preserve the order of symbol table entries produced by 21 ._s_t_a_b directives. As described in a.out(5), an element of the symbol 22 table consists of the following structure: 23 24 /* 25 * Format of a symbol table entry. 26 */ 27 28 struct nlist { 29 union { 30 char *n_name; /* for use when in-core */ 31 long n_strx; /* index into file string table */ 32 } n_un; 33 unsigned char n_type; /* type flag */ 34 char n_other; /* unused */ 35 short n_desc; /* see struct desc, below */ 36 unsigned n_value; /* address or offset or line */ 37 }; 38 39 The low bits of the _n__t_y_p_e field are used to place a symbol into at most 40 one segment, according to the following masks, defined in <_a._o_u_t._h>. A 41 symbol can be in none of these segments by having none of these segment 42 bits set. 43 44 /* 45 * Simple values for n_type. 46 */ 47 48 #define N_UNDF 0x0 /* undefined */ 49 #define N_ABS 0x2 /* absolute */ 50 #define N_TEXT 0x4 /* text */ 51 #define N_DATA 0x6 /* data */ 52 #define N_BSS 0x8 /* bss */ 53 54 #define N_EXT 01 /* external bit, or'ed in */ 55 56 The _n__v_a_l_u_e field of a symbol is relocated by the linker, ld(1) as an ad- 57 dress within the appropriate segment. _N__v_a_l_u_e fields of symbols not in 58 any segment are unchanged by the linker. In addition, the linker will 59 discard certain symbols, according to rules of its own, unless the _n__t_y_p_e 60 field has one of the following bits set: 61 62 /* 63 * Other permanent symbol table entries have some of the N_STAB bits set. 64 * These are given in <stab.h> 65 */ 66 67 #define N_STAB 0xe0 /* if any of these bits set, don't discard */ 68 69 This allows up to 112 (7 * 16) symbol types, split between the various 70 segments. Some of these have already been claimed. The old symbolic de- 71 bugger, _s_d_b, uses the following n_type values: 72 73 #define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ 74 #define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */ 75 #define N_FUN 0x24 /* procedure: name,,0,linenumber,address */ 76 #define N_STSYM 0x26 /* static symbol: name,,0,type,address */ 77 #define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */ 78 #define N_RSYM 0x40 /* register sym: name,,0,type,register */ 79 #define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */ 80 #define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */ 81 #define N_SO 0x64 /* source file name: name,,0,0,address */ 82 #define N_LSYM 0x80 /* local sym: name,,0,type,offset */ 83 #define N_SOL 0x84 /* #included file name: name,,0,0,address */ 84 #define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ 85 #define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */ 86 #define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */ 87 #define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */ 88 #define N_BCOMM 0xe2 /* begin common: name,, */ 89 #define N_ECOMM 0xe4 /* end common: name,, */ 90 #define N_ECOML 0xe8 /* end common (local name): ,,address */ 91 #define N_LENG 0xfe /* second stab entry with length information */ 92 93 where the comments give _s_d_b conventional use for ._s_t_a_b _s and the _n__n_a_m_e, 94 _n__o_t_h_e_r, _n__d_e_s_c, and _n__v_a_l_u_e fields of the given _n__t_y_p_e. _S_d_b uses the 95 _n__d_e_s_c field to hold a type specifier in the form used by the Portable C 96 Compiler, cc(1); see the header file _p_c_c._h for details on the format of 97 these type values. 98 99 The Berkeley Pascal compiler, pc(1), uses the following _n__t_y_p_e value: 100 101 #define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */ 102 103 and uses the following subtypes to do type checking across separately 104 compiled files: 105 106 1 source file name 107 2 included file name 108 3 global label 109 4 global constant 110 5 global type 111 6 global variable 112 7 global function 113 8 global procedure 114 9 external function 115 10 external procedure 116 11 library variable 117 12 library routine 118 119SSEEEE AALLSSOO 120 as(1), ld(1), dbx(1), a.out(5) 121 122BBUUGGSS 123 More basic types are needed. 124 125HHIISSTTOORRYY 126 The ssttaabb file appeared in 4.0BSD. 127 1284th Berkeley Distribution May 10, 1991 3 129 130 131 132 133