Commit | Line | Data |
---|---|---|
3922de1d C |
1 | |
2 | ||
3 | ||
4 | STAB(5) 1986 STAB(5) | |
5 | ||
6 | ||
7 | ||
8 | N\bNA\bAM\bME\bE | |
9 | stab - symbol table types | |
10 | ||
11 | S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS | |
12 | #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bst\bta\bab\bb.\b.h\bh>\b> | |
13 | ||
14 | D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN | |
15 | _\bS_\bt_\ba_\bb._\bh defines some values of the n_type field of the symbol | |
16 | table of a.out files. These are the types for permanent | |
17 | symbols (i.e. not local labels, etc.) used by the old | |
18 | debugger _\bs_\bd_\bb and the Berkeley Pascal compiler _\bp_\bc(1). Symbol | |
19 | table entries can be produced by the ._\bs_\bt_\ba_\bb_\bs assembler direc- | |
20 | tive. This allows one to specify a double-quote delimited | |
21 | name, a symbol type, one char and one short of information | |
22 | about the symbol, and an unsigned long (usually an address). | |
23 | To avoid having to produce an explicit label for the address | |
24 | field, the ._\bs_\bt_\ba_\bb_\bd directive can be used to implicitly | |
25 | address the current location. If no name is needed, symbol | |
26 | table entries can be generated using the ._\bs_\bt_\ba_\bb_\bn directive. | |
27 | The loader promises to preserve the order of symbol table | |
28 | entries produced by ._\bs_\bt_\ba_\bb directives. As described in | |
29 | _\ba._\bo_\bu_\bt(5), an element of the symbol table consists of the | |
30 | following structure: | |
31 | ||
32 | /* | |
33 | * Format of a symbol table entry. | |
34 | */ | |
35 | struct nlist { | |
36 | union { | |
37 | char *n_name; /* for use when in-core */ | |
38 | long n_strx; /* index into file string table */ | |
39 | } n_un; | |
40 | unsigned char n_type; /* type flag */ | |
41 | char n_other; /* unused */ | |
42 | short n_desc; /* see struct desc, below */ | |
43 | unsigned n_value; /* address or offset or line */ | |
44 | }; | |
45 | ||
46 | The low bits of the n_type field are used to place a symbol | |
47 | into at most one segment, according to the following masks, | |
48 | defined in <_\ba._\bo_\bu_\bt._\bh>. A symbol can be in none of these seg- | |
49 | ments by having none of these segment bits set. | |
50 | ||
51 | /* | |
52 | * Simple values for n_type. | |
53 | */ | |
54 | #define N_UNDF 0x0 /* undefined */ | |
55 | #define N_ABS 0x2 /* absolute */ | |
56 | #define N_TEXT 0x4 /* text */ | |
57 | #define N_DATA 0x6 /* data */ | |
58 | #define N_BSS 0x8 /* bss */ | |
59 | ||
60 | ||
61 | ||
62 | ||
63 | Printed 7/27/90 May 1 | |
64 | ||
65 | ||
66 | ||
67 | ||
68 | ||
69 | ||
70 | STAB(5) 1986 STAB(5) | |
71 | ||
72 | ||
73 | ||
74 | #define N_EXT 01 /* external bit, or'ed in */ | |
75 | ||
76 | The n_value field of a symbol is relocated by the linker, | |
77 | _\bl_\bd(1) as an address within the appropriate segment. N_value | |
78 | fields of symbols not in any segment are unchanged by the | |
79 | linker. In addition, the linker will discard certain sym- | |
80 | bols, according to rules of its own, unless the n_type field | |
81 | has one of the following bits set: | |
82 | ||
83 | /* | |
84 | * Other permanent symbol table entries have some of the N_STAB bits set. | |
85 | * These are given in <stab.h> | |
86 | */ | |
87 | #define N_STAB 0xe0/* if any of these bits set, don't discard */ | |
88 | ||
89 | ||
90 | This allows up to 112 (7 * 16) symbol types, split between | |
91 | the various segments. Some of these have already been | |
92 | claimed. The old symbolic debugger, _\bs_\bd_\bb, uses the following | |
93 | n_type values: | |
94 | ||
95 | #define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ | |
96 | #define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */ | |
97 | #define N_FUN 0x24 /* procedure: name,,0,linenumber,address */ | |
98 | #define N_STSYM 0x26 /* static symbol: name,,0,type,address */ | |
99 | #define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */ | |
100 | #define N_RSYM 0x40 /* register sym: name,,0,type,register */ | |
101 | #define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */ | |
102 | #define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */ | |
103 | #define N_SO 0x64 /* source file name: name,,0,0,address */ | |
104 | #define N_LSYM 0x80 /* local sym: name,,0,type,offset */ | |
105 | #define N_SOL 0x84 /* #included file name: name,,0,0,address */ | |
106 | #define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ | |
107 | #define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */ | |
108 | #define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */ | |
109 | #define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */ | |
110 | #define N_BCOMM 0xe2 /* begin common: name,, */ | |
111 | #define N_ECOMM 0xe4 /* end common: name,, */ | |
112 | #define N_ECOML 0xe8 /* end common (local name): ,,address */ | |
113 | #define N_LENG 0xfe /* second stab entry with length information */ | |
114 | ||
115 | where the comments give _\bs_\bd_\bb conventional use for ._\bs_\bt_\ba_\bbs and | |
116 | the n_name, n_other, n_desc, and n_value fields of the given | |
117 | n_type. _\bS_\bd_\bb uses the n_desc field to hold a type specifier | |
118 | in the form used by the Portable C Compiler, _\bc_\bc(1); see the | |
119 | header file _\bp_\bc_\bc._\bh for details on the format of these type | |
120 | values. | |
121 | ||
122 | The Berkeley Pascal compiler, _\bp_\bc(1), uses the following | |
123 | n_type value: | |
124 | ||
125 | ||
126 | ||
127 | ||
128 | ||
129 | Printed 7/27/90 May 2 | |
130 | ||
131 | ||
132 | ||
133 | ||
134 | ||
135 | ||
136 | STAB(5) 1986 STAB(5) | |
137 | ||
138 | ||
139 | ||
140 | #define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */ | |
141 | ||
142 | and uses the following subtypes to do type checking across | |
143 | separately compiled files: | |
144 | 1 source file name | |
145 | 2 included file name | |
146 | 3 global label | |
147 | 4 global constant | |
148 | 5 global type | |
149 | 6 global variable | |
150 | 7 global function | |
151 | 8 global procedure | |
152 | 9 external function | |
153 | 10 external procedure | |
154 | 11 library variable | |
155 | 12 library routine | |
156 | ||
157 | S\bSE\bEE\bE A\bAL\bLS\bSO\bO | |
158 | as(1), ld(1), dbx(1), a.out(5) | |
159 | ||
160 | B\bBU\bUG\bGS\bS | |
161 | More basic types are needed. | |
162 | ||
163 | ||
164 | ||
165 | ||
166 | ||
167 | ||
168 | ||
169 | ||
170 | ||
171 | ||
172 | ||
173 | ||
174 | ||
175 | ||
176 | ||
177 | ||
178 | ||
179 | ||
180 | ||
181 | ||
182 | ||
183 | ||
184 | ||
185 | ||
186 | ||
187 | ||
188 | ||
189 | ||
190 | ||
191 | ||
192 | ||
193 | ||
194 | ||
195 | Printed 7/27/90 May 3 | |
196 | ||
197 | ||
198 |