Commit | Line | Data |
---|---|---|
6483bedd C |
1 | .TH STAB 5 "1 April 1983" |
2 | .UC 4 | |
3 | .SH NAME | |
4 | stab \- symbol table types | |
5 | .SH SYNOPSIS | |
6 | .B "#include <stab.h>" | |
7 | .SH DESCRIPTION | |
8 | .I Stab.h | |
9 | defines some values of the n_type field of the symbol table of a.out files. | |
10 | These are the types for permanent symbols (i.e. not local labels, etc.) | |
11 | used by the old debugger | |
12 | .I sdb | |
13 | and the Berkeley Pascal compiler | |
14 | .IR pc (1). | |
15 | Symbol table entries can be produced by the | |
16 | .I .stabs | |
17 | assembler directive. | |
18 | This allows one to specify a double-quote delimited name, a symbol type, | |
19 | one char and one short of information about the symbol, and an unsigned | |
20 | long (usually an address). | |
21 | To avoid having to produce an explicit label for the address field, | |
22 | the | |
23 | .I .stabd | |
24 | directive can be used to implicitly address the current location. | |
25 | If no name is needed, symbol table entries can be generated using the | |
26 | .I .stabn | |
27 | directive. | |
28 | The loader promises to preserve the order of symbol table entries produced | |
29 | by | |
30 | .I .stab | |
31 | directives. | |
32 | As described in | |
33 | .IR a.out (5), | |
34 | an element of the symbol table | |
35 | consists of the following structure: | |
36 | .PP | |
37 | .nf | |
38 | /* | |
39 | .ti +\w'/'u | |
40 | * Format of a symbol table entry. | |
41 | .ti +\w'/'u | |
42 | */ | |
43 | .ta \w'#define\ 'u +\w'unsigned 'u +\w'char\ \ 'u +\w'n_name;\ \ 'u | |
44 | struct nlist { | |
45 | union { | |
46 | char *n_name; /* for use when in-core */ | |
47 | long n_strx; /* index into file string table */ | |
48 | } n_un; | |
49 | unsigned char n_type; /* type flag */ | |
50 | char n_other; /* unused */ | |
51 | short n_desc; /* see struct desc, below */ | |
52 | unsigned n_value; /* address or offset or line */ | |
53 | }; | |
54 | .fi | |
55 | .DT | |
56 | .PP | |
57 | The low bits of the n_type field are used to place a symbol into | |
58 | at most one segment, according to | |
59 | the following masks, defined in | |
60 | .RI < a.out.h >. | |
61 | A symbol can be in none of these segments by having none of these segment | |
62 | bits set. | |
63 | .PP | |
64 | .nf | |
65 | /* | |
66 | .ti +\w'/'u | |
67 | * Simple values for n_type. | |
68 | .ti +\w'/'u | |
69 | */ | |
70 | .ta \w'#define\ 'u +\w'N_FNAME\ 'u +\w'0x0\ \ \ 'u | |
71 | #define N_UNDF 0x0 /* undefined */ | |
72 | #define N_ABS 0x2 /* absolute */ | |
73 | #define N_TEXT 0x4 /* text */ | |
74 | #define N_DATA 0x6 /* data */ | |
75 | #define N_BSS 0x8 /* bss */ | |
76 | ||
77 | #define N_EXT 01 /* external bit, or'ed in */ | |
78 | .DT | |
79 | .fi | |
80 | .PP | |
81 | The n_value field of a symbol is relocated by the linker, | |
82 | .IR ld (1) | |
83 | as an address within the appropriate segment. | |
84 | N_value fields of symbols not in any segment are unchanged by the linker. | |
85 | In addition, the linker will discard certain symbols, according to rules | |
86 | of its own, unless the n_type field has one of the following bits set: | |
87 | .PP | |
88 | .nf | |
89 | /* | |
90 | .ti +\w'/'u | |
91 | * Other permanent symbol table entries have some of the N_STAB bits set. | |
92 | .ti +\w'/'u | |
93 | * These are given in <stab.h> | |
94 | .ti +\w'/'u | |
95 | */ | |
96 | .ta \w'#define\ 'u +\w'N_FNAME\ 'u +\w'0x0\ \ \ 'u | |
97 | #define N_STAB 0xe0 /* if any of these bits set, don't discard */ | |
98 | ||
99 | .DT | |
100 | .fi | |
101 | .PP | |
102 | This allows up to 112 (7 \(** 16) symbol types, split between the various | |
103 | segments. | |
104 | Some of these have already been claimed. | |
105 | The old symbolic debugger, | |
106 | .IR sdb , | |
107 | uses the following n_type values: | |
108 | .PP | |
109 | .nf | |
110 | .ta \w'#define\ 'u +\w'N_FNAME\ 'u +\w'0x0\ \ \ 'u | |
111 | #define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ | |
112 | #define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */ | |
113 | #define N_FUN 0x24 /* procedure: name,,0,linenumber,address */ | |
114 | #define N_STSYM 0x26 /* static symbol: name,,0,type,address */ | |
115 | #define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */ | |
116 | #define N_RSYM 0x40 /* register sym: name,,0,type,register */ | |
117 | #define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */ | |
118 | #define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */ | |
119 | #define N_SO 0x64 /* source file name: name,,0,0,address */ | |
120 | #define N_LSYM 0x80 /* local sym: name,,0,type,offset */ | |
121 | #define N_SOL 0x84 /* #included file name: name,,0,0,address */ | |
122 | #define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ | |
123 | #define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */ | |
124 | #define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */ | |
125 | #define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */ | |
126 | #define N_BCOMM 0xe2 /* begin common: name,, */ | |
127 | #define N_ECOMM 0xe4 /* end common: name,, */ | |
128 | #define N_ECOML 0xe8 /* end common (local name): ,,address */ | |
129 | #define N_LENG 0xfe /* second stab entry with length information */ | |
130 | .fi | |
131 | .PP | |
132 | where the comments give | |
133 | .I sdb | |
134 | conventional use for | |
135 | .IR .stab s | |
136 | and the n_name, n_other, n_desc, and n_value fields | |
137 | of the given n_type. | |
138 | .I Sdb | |
139 | uses the n_desc field to hold a type specifier in the form used | |
140 | by the Portable C Compiler, | |
141 | .IR cc (1), | |
142 | in which a base type is qualified in the following structure: | |
143 | .PP | |
144 | .nf | |
145 | .ta \w'#define\ 'u +\w'short\ \ 'u | |
146 | struct desc { | |
147 | short q6:2, | |
148 | q5:2, | |
149 | q4:2, | |
150 | q3:2, | |
151 | q2:2, | |
152 | q1:2, | |
153 | basic:4; | |
154 | }; | |
155 | .DT | |
156 | .fi | |
157 | .PP | |
158 | There are four qualifications, with q1 the most significant and q6 the least | |
159 | significant: | |
160 | .nf | |
161 | 0 none | |
162 | 1 pointer | |
163 | 2 function | |
164 | 3 array | |
165 | .fi | |
166 | The sixteen basic types are assigned as follows: | |
167 | .nf | |
168 | 0 undefined | |
169 | 1 function argument | |
170 | 2 character | |
171 | 3 short | |
172 | 4 int | |
173 | 5 long | |
174 | 6 float | |
175 | 7 double | |
176 | 8 structure | |
177 | 9 union | |
178 | 10 enumeration | |
179 | 11 member of enumeration | |
180 | 12 unsigned character | |
181 | 13 unsigned short | |
182 | 14 unsigned int | |
183 | 15 unsigned long | |
184 | .fi | |
185 | .PP | |
186 | The Berkeley Pascal compiler, | |
187 | .IR pc (1), | |
188 | uses the following n_type value: | |
189 | .PP | |
190 | .nf | |
191 | #define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */ | |
192 | .fi | |
193 | .PP | |
194 | and uses the following subtypes to do type checking across separately | |
195 | compiled files: | |
196 | .nf | |
197 | 1 source file name | |
198 | 2 included file name | |
199 | 3 global label | |
200 | 4 global constant | |
201 | 5 global type | |
202 | 6 global variable | |
203 | 7 global function | |
204 | 8 global procedure | |
205 | 9 external function | |
206 | 10 external procedure | |
207 | 11 library variable | |
208 | 12 library routine | |
209 | .fi | |
210 | .SH "SEE ALSO" | |
211 | as(1), ld(1), dbx(1), a.out(5) | |
212 | .SH BUGS | |
213 | .PP | |
214 | .I Sdb | |
215 | assumes that a symbol of type N_GSYM with name | |
216 | .I name | |
217 | is located at address | |
218 | .IR _\|name . | |
219 | .PP | |
220 | More basic types are needed. |