xref: /freebsd/share/man/man5/stab.5 (revision 97759ccc715c4b365432c16d763c50eecfcb1100)
1afe61c15SRodney W. Grimes.\" Copyright (c) 1980, 1991, 1993
2afe61c15SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3afe61c15SRodney W. Grimes.\"
4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6afe61c15SRodney W. Grimes.\" are met:
7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11afe61c15SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12dda5b397SEitan Adler.\" 3. Neither the name of the University nor the names of its contributors
13afe61c15SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
14afe61c15SRodney W. Grimes.\"    without specific prior written permission.
15afe61c15SRodney W. Grimes.\"
16afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19afe61c15SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26afe61c15SRodney W. Grimes.\" SUCH DAMAGE.
27afe61c15SRodney W. Grimes.\"
2854e57c81SBjoern A. Zeeb.Dd June 10, 2010
29afe61c15SRodney W. Grimes.Dt STAB 5
303d45e180SRuslan Ermilov.Os
31afe61c15SRodney W. Grimes.Sh NAME
32afe61c15SRodney W. Grimes.Nm stab
33afe61c15SRodney W. Grimes.Nd symbol table types
34afe61c15SRodney W. Grimes.Sh SYNOPSIS
3532eef9aeSRuslan Ermilov.In stab.h
36afe61c15SRodney W. Grimes.Sh DESCRIPTION
37afe61c15SRodney W. GrimesThe file
38fe08efe6SRuslan Ermilov.In stab.h
39afe61c15SRodney W. Grimesdefines some of the symbol table
40afe61c15SRodney W. Grimes.Fa n_type
41afe61c15SRodney W. Grimesfield values for a.out files.
42*2e17a50fSBenjamin KadukThese are the types for permanent symbols (i.e., not local labels, etc.\&)
43afe61c15SRodney W. Grimesused by the old debugger
44afe61c15SRodney W. Grimes.Em sdb
45afe61c15SRodney W. Grimesand the Berkeley Pascal compiler
46afe61c15SRodney W. Grimes.Xr pc 1 .
47afe61c15SRodney W. GrimesSymbol table entries can be produced by the
48afe61c15SRodney W. Grimes.Pa .stabs
49afe61c15SRodney W. Grimesassembler directive.
50afe61c15SRodney W. GrimesThis allows one to specify a double-quote delimited name, a symbol type,
51afe61c15SRodney W. Grimesone char and one short of information about the symbol, and an unsigned
52afe61c15SRodney W. Grimeslong (usually an address).
53afe61c15SRodney W. GrimesTo avoid having to produce an explicit label for the address field,
54afe61c15SRodney W. Grimesthe
55afe61c15SRodney W. Grimes.Pa .stabd
56afe61c15SRodney W. Grimesdirective can be used to implicitly address the current location.
57afe61c15SRodney W. GrimesIf no name is needed, symbol table entries can be generated using the
58afe61c15SRodney W. Grimes.Pa .stabn
59afe61c15SRodney W. Grimesdirective.
60afe61c15SRodney W. GrimesThe loader promises to preserve the order of symbol table entries produced
61afe61c15SRodney W. Grimesby
62afe61c15SRodney W. Grimes.Pa .stab
63afe61c15SRodney W. Grimesdirectives.
64afe61c15SRodney W. GrimesAs described in
65afe61c15SRodney W. Grimes.Xr a.out 5 ,
66afe61c15SRodney W. Grimesan element of the symbol table
67afe61c15SRodney W. Grimesconsists of the following structure:
68afe61c15SRodney W. Grimes.Bd -literal
69afe61c15SRodney W. Grimes/*
70afe61c15SRodney W. Grimes* Format of a symbol table entry.
71afe61c15SRodney W. Grimes*/
72afe61c15SRodney W. Grimes
73afe61c15SRodney W. Grimesstruct nlist {
74afe61c15SRodney W. Grimes	union {
7554e57c81SBjoern A. Zeeb		const char *n_name;	/* for use when in-core */
76afe61c15SRodney W. Grimes		long	n_strx;		/* index into file string table */
77afe61c15SRodney W. Grimes	} n_un;
78afe61c15SRodney W. Grimes	unsigned char	n_type;		/* type flag */
79afe61c15SRodney W. Grimes	char		n_other;	/* unused */
80afe61c15SRodney W. Grimes	short		n_desc;		/* see struct desc, below */
81afe61c15SRodney W. Grimes	unsigned	n_value;	/* address or offset or line */
82afe61c15SRodney W. Grimes};
83afe61c15SRodney W. Grimes.Ed
84afe61c15SRodney W. Grimes.Pp
85afe61c15SRodney W. GrimesThe low bits of the
86afe61c15SRodney W. Grimes.Fa n_type
87afe61c15SRodney W. Grimesfield are used to place a symbol into
88afe61c15SRodney W. Grimesat most one segment, according to
89afe61c15SRodney W. Grimesthe following masks, defined in
90fe08efe6SRuslan Ermilov.In a.out.h .
91afe61c15SRodney W. GrimesA symbol can be in none of these segments by having none of these segment
92afe61c15SRodney W. Grimesbits set.
93afe61c15SRodney W. Grimes.Bd -literal
94afe61c15SRodney W. Grimes/*
95afe61c15SRodney W. Grimes* Simple values for n_type.
96afe61c15SRodney W. Grimes*/
97afe61c15SRodney W. Grimes
98afe61c15SRodney W. Grimes#define	N_UNDF	0x0	/* undefined */
99afe61c15SRodney W. Grimes#define	N_ABS	0x2	/* absolute */
100afe61c15SRodney W. Grimes#define	N_TEXT	0x4	/* text */
101afe61c15SRodney W. Grimes#define	N_DATA	0x6	/* data */
102afe61c15SRodney W. Grimes#define	N_BSS	0x8	/* bss */
103afe61c15SRodney W. Grimes
104afe61c15SRodney W. Grimes#define	N_EXT	01	/* external bit, or'ed in */
105afe61c15SRodney W. Grimes.Ed
106afe61c15SRodney W. Grimes.Pp
107afe61c15SRodney W. GrimesThe
108afe61c15SRodney W. Grimes.Fa n_value
109afe61c15SRodney W. Grimesfield of a symbol is relocated by the linker,
110afe61c15SRodney W. Grimes.Xr ld 1
111afe61c15SRodney W. Grimesas an address within the appropriate segment.
112afe61c15SRodney W. Grimes.Fa N_value
113afe61c15SRodney W. Grimesfields of symbols not in any segment are unchanged by the linker.
114afe61c15SRodney W. GrimesIn addition, the linker will discard certain symbols, according to rules
115afe61c15SRodney W. Grimesof its own, unless the
116afe61c15SRodney W. Grimes.Fa n_type
117afe61c15SRodney W. Grimesfield has one of the following bits set:
118afe61c15SRodney W. Grimes.Bd -literal
119afe61c15SRodney W. Grimes/*
120afe61c15SRodney W. Grimes* Other permanent symbol table entries have some of the N_STAB bits set.
121afe61c15SRodney W. Grimes* These are given in <stab.h>
122afe61c15SRodney W. Grimes*/
123afe61c15SRodney W. Grimes
124afe61c15SRodney W. Grimes#define	N_STAB	0xe0	/* if any of these bits set, don't discard */
125afe61c15SRodney W. Grimes.Ed
126afe61c15SRodney W. Grimes.Pp
127afe61c15SRodney W. GrimesThis allows up to 112 (7 \(** 16) symbol types, split between the various
128afe61c15SRodney W. Grimessegments.
129afe61c15SRodney W. GrimesSome of these have already been claimed.
130afe61c15SRodney W. GrimesThe old symbolic debugger,
131afe61c15SRodney W. Grimes.Em sdb ,
132afe61c15SRodney W. Grimesuses the following n_type values:
133afe61c15SRodney W. Grimes.Bd -literal
134afe61c15SRodney W. Grimes#define	N_GSYM	0x20	/* global symbol: name,,0,type,0 */
135afe61c15SRodney W. Grimes#define	N_FNAME	0x22	/* procedure name (f77 kludge): name,,0 */
136afe61c15SRodney W. Grimes#define	N_FUN	0x24	/* procedure: name,,0,linenumber,address */
137afe61c15SRodney W. Grimes#define	N_STSYM	0x26	/* static symbol: name,,0,type,address */
138afe61c15SRodney W. Grimes#define	N_LCSYM	0x28	/* .lcomm symbol: name,,0,type,address */
139afe61c15SRodney W. Grimes#define	N_RSYM	0x40	/* register sym: name,,0,type,register */
140afe61c15SRodney W. Grimes#define	N_SLINE	0x44	/* src line: 0,,0,linenumber,address */
141afe61c15SRodney W. Grimes#define	N_SSYM	0x60	/* structure elt: name,,0,type,struct_offset */
142afe61c15SRodney W. Grimes#define	N_SO	0x64	/* source file name: name,,0,0,address */
143afe61c15SRodney W. Grimes#define	N_LSYM	0x80	/* local sym: name,,0,type,offset */
144afe61c15SRodney W. Grimes#define	N_SOL	0x84	/* #included file name: name,,0,0,address */
145afe61c15SRodney W. Grimes#define	N_PSYM	0xa0	/* parameter: name,,0,type,offset */
146afe61c15SRodney W. Grimes#define	N_ENTRY	0xa4	/* alternate entry: name,linenumber,address */
147afe61c15SRodney W. Grimes#define	N_LBRAC	0xc0	/* left bracket: 0,,0,nesting level,address */
148afe61c15SRodney W. Grimes#define	N_RBRAC	0xe0	/* right bracket: 0,,0,nesting level,address */
149afe61c15SRodney W. Grimes#define	N_BCOMM	0xe2	/* begin common: name,, */
150afe61c15SRodney W. Grimes#define	N_ECOMM	0xe4	/* end common: name,, */
151afe61c15SRodney W. Grimes#define	N_ECOML	0xe8	/* end common (local name): ,,address */
152afe61c15SRodney W. Grimes#define	N_LENG	0xfe	/* second stab entry with length information */
153afe61c15SRodney W. Grimes.Ed
154afe61c15SRodney W. Grimes.Pp
155afe61c15SRodney W. Grimeswhere the comments give
156afe61c15SRodney W. Grimes.Em sdb
157afe61c15SRodney W. Grimesconventional use for
158afe61c15SRodney W. Grimes.Pa .stab
159afe61c15SRodney W. Grimes.Fa s
160afe61c15SRodney W. Grimesand the
161afe61c15SRodney W. Grimes.Fa n_name ,
162afe61c15SRodney W. Grimes.Fa n_other ,
163afe61c15SRodney W. Grimes.Fa n_desc ,
164afe61c15SRodney W. Grimesand
165afe61c15SRodney W. Grimes.Fa n_value
166afe61c15SRodney W. Grimesfields
167afe61c15SRodney W. Grimesof the given
168afe61c15SRodney W. Grimes.Fa n_type .
169afe61c15SRodney W. Grimes.Em Sdb
170afe61c15SRodney W. Grimesuses the
171afe61c15SRodney W. Grimes.Fa n_desc
172afe61c15SRodney W. Grimesfield to hold a type specifier in the form used
173afe61c15SRodney W. Grimesby the Portable C Compiler,
174afe61c15SRodney W. Grimes.Xr cc 1 ;
175afe61c15SRodney W. Grimessee the header file
176afe61c15SRodney W. Grimes.Pa pcc.h
177afe61c15SRodney W. Grimesfor details on the format of these type values.
178afe61c15SRodney W. Grimes.Pp
179afe61c15SRodney W. GrimesThe Berkeley Pascal compiler,
180afe61c15SRodney W. Grimes.Xr pc 1 ,
181afe61c15SRodney W. Grimesuses the following
182afe61c15SRodney W. Grimes.Fa n_type
183afe61c15SRodney W. Grimesvalue:
184afe61c15SRodney W. Grimes.Bd -literal
185afe61c15SRodney W. Grimes#define	N_PC	0x30	/* global pascal symbol: name,,0,subtype,line */
186afe61c15SRodney W. Grimes.Ed
187afe61c15SRodney W. Grimes.Pp
188afe61c15SRodney W. Grimesand uses the following subtypes to do type checking across separately
189afe61c15SRodney W. Grimescompiled files:
190afe61c15SRodney W. Grimes.Bd -unfilled -offset indent
191afe61c15SRodney W. Grimes1	source file name
192afe61c15SRodney W. Grimes2	included file name
193afe61c15SRodney W. Grimes3	global label
194afe61c15SRodney W. Grimes4	global constant
195afe61c15SRodney W. Grimes5	global type
196afe61c15SRodney W. Grimes6	global variable
197afe61c15SRodney W. Grimes7	global function
198afe61c15SRodney W. Grimes8	global procedure
199afe61c15SRodney W. Grimes9	external function
200afe61c15SRodney W. Grimes10	external procedure
201afe61c15SRodney W. Grimes11	library variable
202afe61c15SRodney W. Grimes12	library routine
203afe61c15SRodney W. Grimes.Ed
204afe61c15SRodney W. Grimes.Sh SEE ALSO
205afe61c15SRodney W. Grimes.Xr as 1 ,
206afe61c15SRodney W. Grimes.Xr ld 1 ,
207afe61c15SRodney W. Grimes.Xr a.out 5
208afe61c15SRodney W. Grimes.Sh HISTORY
209afe61c15SRodney W. GrimesThe
2104b66483fSRuslan Ermilov.Nm
211afe61c15SRodney W. Grimesfile appeared in
212afe61c15SRodney W. Grimes.Bx 4.0 .
2139cbda590SRuslan Ermilov.Sh BUGS
2149cbda590SRuslan ErmilovMore basic types are needed.
215