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