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