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