stupid boo boos
[unix-history] / usr / src / share / man / man5 / stab.5
CommitLineData
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
17The file
18.Aq Pa stab.h
19defines some of the symbol table
20.Fa n_type
21field values for a.out files.
52cc64d3 22These are the types for permanent symbols (i.e. not local labels, etc.)
98b4d9a7 23used by the old debugger
eadcc84a 24.Em sdb
52cc64d3 25and the Berkeley Pascal compiler
eadcc84a 26.Xr pc 1 .
52cc64d3 27Symbol table entries can be produced by the
eadcc84a 28.Pa .stabs
52cc64d3
KM
29assembler directive.
30This allows one to specify a double-quote delimited name, a symbol type,
31one char and one short of information about the symbol, and an unsigned
32long (usually an address).
33To avoid having to produce an explicit label for the address field,
34the
eadcc84a 35.Pa .stabd
52cc64d3
KM
36directive can be used to implicitly address the current location.
37If no name is needed, symbol table entries can be generated using the
eadcc84a 38.Pa .stabn
52cc64d3
KM
39directive.
40The loader promises to preserve the order of symbol table entries produced
41by
eadcc84a 42.Pa .stab
52cc64d3 43directives.
98b4d9a7 44As described in
eadcc84a 45.Xr a.out 5 ,
98b4d9a7 46an element of the symbol table
52cc64d3 47consists of the following structure:
eadcc84a 48.Bd -literal
52cc64d3 49/*
52cc64d3 50* Format of a symbol table entry.
52cc64d3 51*/
eadcc84a 52
52cc64d3
KM
53struct 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
65The low bits of the
66.Fa n_type
67field are used to place a symbol into
52cc64d3
KM
68at most one segment, according to
69the following masks, defined in
eadcc84a 70.Aq Pa a.out.h .
52cc64d3
KM
71A symbol can be in none of these segments by having none of these segment
72bits 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
87The
88.Fa n_value
89field of a symbol is relocated by the linker,
90.Xr ld 1
52cc64d3 91as an address within the appropriate segment.
eadcc84a
CL
92.Fa N_value
93fields of symbols not in any segment are unchanged by the linker.
52cc64d3 94In addition, the linker will discard certain symbols, according to rules
eadcc84a
CL
95of its own, unless the
96.Fa n_type
97field 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
107This allows up to 112 (7 \(** 16) symbol types, split between the various
108segments.
109Some of these have already been claimed.
98b4d9a7 110The old symbolic debugger,
eadcc84a 111.Em sdb ,
52cc64d3 112uses 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 135where the comments give
eadcc84a 136.Em sdb
52cc64d3 137conventional use for
eadcc84a
CL
138.Pa .stab
139.Fa s
140and the
141.Fa n_name ,
142.Fa n_other ,
143.Fa n_desc ,
144and
145.Fa n_value
146fields
147of the given
148.Fa n_type .
149.Em Sdb
150uses the
151.Fa n_desc
152field to hold a type specifier in the form used
52cc64d3 153by the Portable C Compiler,
eadcc84a
CL
154.Xr cc 1 ;
155see the header file
156.Pa pcc.h
d6bd8742 157for details on the format of these type values.
eadcc84a 158.Pp
52cc64d3 159The Berkeley Pascal compiler,
eadcc84a
CL
160.Xr pc 1 ,
161uses the following
162.Fa n_type
163value:
164.Bd -literal
52cc64d3 165#define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */
eadcc84a
CL
166.Ed
167.Pp
52cc64d3
KM
168and uses the following subtypes to do type checking across separately
169compiled files:
eadcc84a
CL
170.Bd -unfilled -offset indent
1711 source file name
1722 included file name
1733 global label
1744 global constant
1755 global type
1766 global variable
1777 global function
1788 global procedure
1799 external function
18010 external procedure
18111 library variable
18212 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 191More basic types are needed.
eadcc84a
CL
192.Sh HISTORY
193The
194.Nm stab
195file appeared in
196.Bx 4.0 .