1 .\" $OpenBSD: stab.5,v 1.14 2007/05/31 19:19:58 jmc Exp $
2 .\" $NetBSD: stab.5,v 1.3 1994/11/30 19:31:33 jtc Exp $
4 .\" Copyright (c) 1980, 1991, 1993
5 .\" The Regents of the University of California. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. Neither the name of the University nor the names of its contributors
16 .\" may be used to endorse or promote products derived from this software
17 .\" without specific prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" @(#)stab.5 8.1 (Berkeley) 6/5/93
33 .Dd $Mdocdate: May 31 2007 $
38 .Nd symbol table types
44 file defines some of the symbol table
49 These are the types for permanent symbols (i.e., not local labels, etc.\&)
50 used by the old debugger
52 and the Berkeley Pascal compiler pc.
54 Symbol table entries can be produced by the
57 This allows one to specify a double-quote delimited name, a symbol type, one
61 of information about the symbol, as well as an
65 To avoid having to produce an explicit label for the address field,
68 directive can be used to implicitly address the current location.
69 If no name is needed, symbol table entries can be generated using the
72 The loader promises to preserve the order of symbol table entries produced by
77 an element of the symbol table consists of the following structure:
80 * Format of a symbol table entry.
85 char *n_name; /* for use when in-core */
86 long n_strx; /* index into file string table */
88 unsigned char n_type; /* type flag */
89 char n_other; /* unused */
90 short n_desc; /* see struct desc, below */
91 unsigned n_value; /* address or offset or line */
97 field are used to place a symbol into
98 at most one segment, according to
99 the following masks, defined in
101 A symbol can be in none of these segments by having none of these segment
105 * Simple values for n_type.
108 #define N_UNDF 0x0 /* undefined */
109 #define N_ABS 0x2 /* absolute */
110 #define N_TEXT 0x4 /* text */
111 #define N_DATA 0x6 /* data */
112 #define N_BSS 0x8 /* bss */
114 #define N_EXT 01 /* external bit, or'ed in */
119 field of a symbol is relocated by the linker,
121 as an address within the appropriate segment.
123 fields of symbols not in any segment are unchanged by the linker.
124 In addition, the linker will discard certain symbols, according to rules
125 of its own, unless the
127 field has one of the following bits set:
130 * Other permanent symbol table entries have some of the N_STAB bits set.
131 * These are given in <stab.h>
134 #define N_STAB 0xe0 /* if any of these bits set, don't discard */
137 This allows up to 112 (7 \(** 16) symbol types, split between the various
139 Some of these have already been claimed.
140 The old symbolic debugger,
146 #define N_GSYM 0x20 /* global symbol: name,,0,type,0 */
147 #define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */
148 #define N_FUN 0x24 /* procedure: name,,0,linenumber,address */
149 #define N_STSYM 0x26 /* static symbol: name,,0,type,address */
150 #define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */
151 #define N_RSYM 0x40 /* register sym: name,,0,type,register */
152 #define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */
153 #define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */
154 #define N_SO 0x64 /* source file name: name,,0,0,address */
155 #define N_LSYM 0x80 /* local sym: name,,0,type,offset */
156 #define N_SOL 0x84 /* #included file name: name,,0,0,address */
157 #define N_PSYM 0xa0 /* parameter: name,,0,type,offset */
158 #define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */
159 #define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */
160 #define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */
161 #define N_BCOMM 0xe2 /* begin common: name,, */
162 #define N_ECOMM 0xe4 /* end common: name,, */
163 #define N_ECOML 0xe8 /* end common (local name): ,,address */
164 #define N_LENG 0xfe /* second stab entry with length information */
167 where the comments give
183 field to hold a type specifier in the form used
184 by the Portable C Compiler,
188 for details on the format of these type values.
190 The Berkeley Pascal compiler, pc, uses the following
194 #define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */
197 and uses the following subtypes to do type checking across separately
199 .Bd -unfilled -offset indent
209 10 external procedure
224 More basic types are needed.