nlist.h revision 93032
11539Srgrimes/*-
21539Srgrimes * Copyright (c) 1991, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes * (c) UNIX System Laboratories, Inc.
51539Srgrimes * All or some portions of this file are derived from material licensed
61539Srgrimes * to the University of California by American Telephone and Telegraph
71539Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81539Srgrimes * the permission of UNIX System Laboratories, Inc.
91539Srgrimes *
101539Srgrimes * Redistribution and use in source and binary forms, with or without
111539Srgrimes * modification, are permitted provided that the following conditions
121539Srgrimes * are met:
131539Srgrimes * 1. Redistributions of source code must retain the above copyright
141539Srgrimes *    notice, this list of conditions and the following disclaimer.
151539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161539Srgrimes *    notice, this list of conditions and the following disclaimer in the
171539Srgrimes *    documentation and/or other materials provided with the distribution.
181539Srgrimes * 3. All advertising materials mentioning features or use of this software
191539Srgrimes *    must display the following acknowledgement:
201539Srgrimes *	This product includes software developed by the University of
211539Srgrimes *	California, Berkeley and its contributors.
221539Srgrimes * 4. Neither the name of the University nor the names of its contributors
231539Srgrimes *    may be used to endorse or promote products derived from this software
241539Srgrimes *    without specific prior written permission.
251539Srgrimes *
261539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361539Srgrimes * SUCH DAMAGE.
371539Srgrimes *
381539Srgrimes *	@(#)nlist.h	8.2 (Berkeley) 1/21/94
395207Snate *
4050473Speter * $FreeBSD: head/include/nlist.h 93032 2002-03-23 17:24:55Z imp $
411539Srgrimes */
421539Srgrimes
431539Srgrimes#ifndef _NLIST_H_
441539Srgrimes#define	_NLIST_H_
451539Srgrimes
461539Srgrimes/*
4731584Sjdp * Symbol table entries in a.out files.
481539Srgrimes */
4931584Sjdp
5031584Sjdp/*
5131584Sjdp * Layout of each symbol.  The "#ifdef _AOUT_INCLUDE_" is so that
5231584Sjdp * programs including nlist.h can initialize nlist structures
5331584Sjdp * statically.
5431584Sjdp */
551539Srgrimesstruct nlist {
561539Srgrimes#ifdef _AOUT_INCLUDE_
571539Srgrimes	union {
581539Srgrimes		char *n_name;	/* symbol name (in memory) */
591539Srgrimes		long n_strx;	/* file string table offset (on disk) */
601539Srgrimes	} n_un;
611539Srgrimes#else
621539Srgrimes	char *n_name;		/* symbol name (in memory) */
631539Srgrimes#endif
6431584Sjdp	unsigned char n_type;	/* type defines */
6531584Sjdp	char n_other;		/* ".type" and binding information */
6631584Sjdp	short n_desc;		/* used by stab entries */
6731584Sjdp	unsigned long n_value;	/* address/value of the symbol */
6831584Sjdp};
691539Srgrimes
7031584Sjdp#define	n_hash	n_desc		/* used internally by ld(1); XXX */
7131584Sjdp
7231584Sjdp/*
7331584Sjdp * Defines for n_type.
7431584Sjdp */
751539Srgrimes#define	N_UNDF	0x00		/* undefined */
761539Srgrimes#define	N_ABS	0x02		/* absolute address */
771539Srgrimes#define	N_TEXT	0x04		/* text segment */
781539Srgrimes#define	N_DATA	0x06		/* data segment */
791539Srgrimes#define	N_BSS	0x08		/* bss segment */
805207Snate#define	N_INDR	0x0a		/* alias definition */
815207Snate#define	N_SIZE	0x0c		/* pseudo type, defines a symbol's size */
821539Srgrimes#define	N_COMM	0x12		/* common reference */
8318589Speter/* GNU extensions */
8418589Speter#define N_SETA	0x14		/* Absolute set element symbol */
8518589Speter#define N_SETT  0x16		/* Text set element symbol */
8618589Speter#define N_SETD  0x18		/* Data set element symbol */
8718589Speter#define N_SETB  0x1a		/* Bss set element symbol */
8818589Speter#define N_SETV  0x1c		/* Pointer to set vector in data area. */
8918589Speter/* end GNU extensions */
905207Snate#define	N_FN	0x1e		/* file name (N_EXT on) */
915207Snate#define	N_WARN	0x1e		/* warning message (N_EXT off) */
921539Srgrimes
931539Srgrimes#define	N_EXT	0x01		/* external (global) bit, OR'ed in */
941539Srgrimes#define	N_TYPE	0x1e		/* mask for all the type bits */
9531584Sjdp#define	N_STAB	0xe0		/* mask for debugger symbols -- stab(5) */
961539Srgrimes
9731584Sjdp/*
9831584Sjdp * Defines for n_other.  It contains the ".type" (AUX) field in the least
9931584Sjdp * significant 4 bits, and the binding (for weak symbols) in the most
10031584Sjdp * significant 4 bits.
10131584Sjdp */
10231584Sjdp#define N_AUX(p)	((p)->n_other & 0xf)
10331584Sjdp#define N_BIND(p)	(((unsigned int)(p)->n_other >> 4) & 0xf)
10431584Sjdp#define N_OTHER(r, v)	(((unsigned int)(r) << 4) | ((v) & 0xf))
1051539Srgrimes
10631584Sjdp#define AUX_OBJECT	1	/* data object */
10731584Sjdp#define AUX_FUNC	2	/* function */
10831584Sjdp
10931584Sjdp/*#define BIND_LOCAL	0	not used */
11031584Sjdp/*#define BIND_GLOBAL	1	not used */
11131584Sjdp#define BIND_WEAK	2	/* weak binding */
11231584Sjdp
1131539Srgrimes#define	N_FORMAT	"%08x"	/* namelist value format; XXX */
1141539Srgrimes
1151539Srgrimes#include <sys/cdefs.h>
1161539Srgrimes
1171539Srgrimes__BEGIN_DECLS
11893032Simpint nlist(const char *, struct nlist *);
1191539Srgrimes__END_DECLS
1201539Srgrimes
1211539Srgrimes#endif /* !_NLIST_H_ */
122