xref: /titanic_51/usr/src/lib/libbc/inc/include/sun4/a.out.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #ifndef _sparc_a_out_h
30*7c478bd9Sstevel@tonic-gate #define _sparc_a_out_h
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <sys/exec.h>
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate /*
35*7c478bd9Sstevel@tonic-gate  * memory management parameters
36*7c478bd9Sstevel@tonic-gate  */
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #define PAGSIZ		0x02000
39*7c478bd9Sstevel@tonic-gate #define SEGSIZ		PAGSIZ
40*7c478bd9Sstevel@tonic-gate #define	OLD_PAGSIZ	0x00800	/*  Page   size under Release 2.0 */
41*7c478bd9Sstevel@tonic-gate #define	OLD_SEGSIZ	0x08000	/* Segment size under Release 2.0 */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /*
44*7c478bd9Sstevel@tonic-gate  * returns 1 if an object file type is invalid, i.e., if the other macros
45*7c478bd9Sstevel@tonic-gate  * defined below will not yield the correct offsets.  Note that a file may
46*7c478bd9Sstevel@tonic-gate  * have N_BADMAG(x) = 0 and may be fully linked, but still may not be
47*7c478bd9Sstevel@tonic-gate  * executable.
48*7c478bd9Sstevel@tonic-gate  */
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #define	N_BADMAG(x) \
51*7c478bd9Sstevel@tonic-gate 	((x).a_magic!=OMAGIC && (x).a_magic!=NMAGIC && (x).a_magic!=ZMAGIC)
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate /*
54*7c478bd9Sstevel@tonic-gate  * relocation parameters. These are architecture-dependent
55*7c478bd9Sstevel@tonic-gate  * and can be deduced from the machine type.  They are used
56*7c478bd9Sstevel@tonic-gate  * to calculate offsets of segments within the object file;
57*7c478bd9Sstevel@tonic-gate  * See N_TXTOFF(x), etc. below.
58*7c478bd9Sstevel@tonic-gate  */
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate #define	N_PAGSIZ(x) \
61*7c478bd9Sstevel@tonic-gate 	((x).a_machtype == M_OLDSUN2? OLD_PAGSIZ : PAGSIZ)
62*7c478bd9Sstevel@tonic-gate #define	N_SEGSIZ(x) \
63*7c478bd9Sstevel@tonic-gate 	((x).a_machtype == M_OLDSUN2? OLD_SEGSIZ : SEGSIZ)
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate /*
66*7c478bd9Sstevel@tonic-gate  * offsets of various sections of an object file.
67*7c478bd9Sstevel@tonic-gate  */
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #define	N_TXTOFF(x) \
70*7c478bd9Sstevel@tonic-gate 	/* text segment */ \
71*7c478bd9Sstevel@tonic-gate 	( (x).a_machtype == M_OLDSUN2 \
72*7c478bd9Sstevel@tonic-gate 	? ((x).a_magic==ZMAGIC ? N_PAGSIZ(x) : sizeof (struct exec)) \
73*7c478bd9Sstevel@tonic-gate 	: ((x).a_magic==ZMAGIC ? 0 : sizeof (struct exec)) )
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate #define	N_DATOFF(x)   /* data segment */	\
76*7c478bd9Sstevel@tonic-gate 	(N_TXTOFF(x) + (x).a_text)
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate #define	N_TRELOFF(x)  /* text reloc'n */	\
79*7c478bd9Sstevel@tonic-gate 	(N_DATOFF(x) + (x).a_data)
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate #define	N_DRELOFF(x) /* data relocation*/	\
82*7c478bd9Sstevel@tonic-gate 	(N_TRELOFF(x) + (x).a_trsize)
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate #define	N_SYMOFF(x) \
85*7c478bd9Sstevel@tonic-gate 	/* symbol table */ \
86*7c478bd9Sstevel@tonic-gate 	(N_TXTOFF(x)+(x).a_text+(x).a_data+(x).a_trsize+(x).a_drsize)
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate #define	N_STROFF(x) \
89*7c478bd9Sstevel@tonic-gate 	/* string table */ \
90*7c478bd9Sstevel@tonic-gate 	(N_SYMOFF(x) + (x).a_syms)
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate /*
93*7c478bd9Sstevel@tonic-gate  * Macros which take exec structures as arguments and tell where the
94*7c478bd9Sstevel@tonic-gate  * various pieces will be loaded.
95*7c478bd9Sstevel@tonic-gate  */
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate #define	_N_BASEADDR(x) \
98*7c478bd9Sstevel@tonic-gate 	(((x).a_magic == ZMAGIC) && ((x).a_entry < N_PAGSIZ(x)) ? \
99*7c478bd9Sstevel@tonic-gate 	    0 : N_PAGSIZ(x))
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate #define N_TXTADDR(x) \
102*7c478bd9Sstevel@tonic-gate 	((x).a_machtype == M_OLDSUN2 ? N_SEGSIZ(x) : _N_BASEADDR(x))
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate #define N_DATADDR(x) \
105*7c478bd9Sstevel@tonic-gate 	(((x).a_magic==OMAGIC)? (N_TXTADDR(x)+(x).a_text) \
106*7c478bd9Sstevel@tonic-gate 	: (N_SEGSIZ(x)+((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZ(x)-1))))
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate #define N_BSSADDR(x)  (N_DATADDR(x)+(x).a_data)
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate /*
111*7c478bd9Sstevel@tonic-gate  * Format of a relocation datum.
112*7c478bd9Sstevel@tonic-gate  */
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate /*
115*7c478bd9Sstevel@tonic-gate  * Sparc relocation types
116*7c478bd9Sstevel@tonic-gate  */
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate enum reloc_type
119*7c478bd9Sstevel@tonic-gate {
120*7c478bd9Sstevel@tonic-gate 	RELOC_8,	RELOC_16,	RELOC_32,	/* simplest relocs    */
121*7c478bd9Sstevel@tonic-gate 	RELOC_DISP8,	RELOC_DISP16,	RELOC_DISP32,	/* Disp's (pc-rel)    */
122*7c478bd9Sstevel@tonic-gate 	RELOC_WDISP30,	RELOC_WDISP22,			/* SR word disp's     */
123*7c478bd9Sstevel@tonic-gate 	RELOC_HI22,	RELOC_22,			/* SR 22-bit relocs   */
124*7c478bd9Sstevel@tonic-gate 	RELOC_13,	RELOC_LO10,			/* SR 13&10-bit relocs*/
125*7c478bd9Sstevel@tonic-gate 	RELOC_SFA_BASE,	RELOC_SFA_OFF13,		/* SR S.F.A. relocs   */
126*7c478bd9Sstevel@tonic-gate 	RELOC_BASE10,	RELOC_BASE13,	RELOC_BASE22,	/* base_relative pic */
127*7c478bd9Sstevel@tonic-gate 	RELOC_PC10,	RELOC_PC22,			/* special pc-rel pic*/
128*7c478bd9Sstevel@tonic-gate 	RELOC_JMP_TBL,					/* jmp_tbl_rel in pic */
129*7c478bd9Sstevel@tonic-gate 	RELOC_SEGOFF16,					/* ShLib offset-in-seg*/
130*7c478bd9Sstevel@tonic-gate 	RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE, /* rtld relocs        */
131*7c478bd9Sstevel@tonic-gate };
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /*
134*7c478bd9Sstevel@tonic-gate  * Format of a relocation datum.
135*7c478bd9Sstevel@tonic-gate  */
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate struct reloc_info_sparc	/* used when header.a_machtype == M_SPARC */
138*7c478bd9Sstevel@tonic-gate {
139*7c478bd9Sstevel@tonic-gate 	unsigned long int r_address;	/* relocation addr (offset in segment)*/
140*7c478bd9Sstevel@tonic-gate 	unsigned int	r_index   :24;	/* segment index or symbol index      */
141*7c478bd9Sstevel@tonic-gate 	unsigned int	r_extern  : 1;	/* if F, r_index==SEG#; if T, SYM idx */
142*7c478bd9Sstevel@tonic-gate 	int			  : 2;	/* <unused>			      */
143*7c478bd9Sstevel@tonic-gate 	enum reloc_type r_type    : 5;	/* type of relocation to perform      */
144*7c478bd9Sstevel@tonic-gate 	long int	r_addend;	/* addend for relocation value	      */
145*7c478bd9Sstevel@tonic-gate };
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate /*
150*7c478bd9Sstevel@tonic-gate  * Format of a symbol table entry
151*7c478bd9Sstevel@tonic-gate  */
152*7c478bd9Sstevel@tonic-gate struct	nlist {
153*7c478bd9Sstevel@tonic-gate 	union {
154*7c478bd9Sstevel@tonic-gate 		char	*n_name;	/* for use when in-core */
155*7c478bd9Sstevel@tonic-gate 		long	n_strx;		/* index into file string table */
156*7c478bd9Sstevel@tonic-gate 	} n_un;
157*7c478bd9Sstevel@tonic-gate 	unsigned char	n_type;		/* type flag (N_TEXT,..)  */
158*7c478bd9Sstevel@tonic-gate 	char	n_other;		/* unused */
159*7c478bd9Sstevel@tonic-gate 	short	n_desc;			/* see <stab.h> */
160*7c478bd9Sstevel@tonic-gate 	unsigned long	n_value;	/* value of symbol (or sdb offset) */
161*7c478bd9Sstevel@tonic-gate };
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate /*
164*7c478bd9Sstevel@tonic-gate  * Simple values for n_type.
165*7c478bd9Sstevel@tonic-gate  */
166*7c478bd9Sstevel@tonic-gate #define	N_UNDF	0x0		/* undefined */
167*7c478bd9Sstevel@tonic-gate #define	N_ABS	0x2		/* absolute */
168*7c478bd9Sstevel@tonic-gate #define	N_TEXT	0x4		/* text */
169*7c478bd9Sstevel@tonic-gate #define	N_DATA	0x6		/* data */
170*7c478bd9Sstevel@tonic-gate #define	N_BSS	0x8		/* bss */
171*7c478bd9Sstevel@tonic-gate #define	N_COMM	0x12		/* common (internal to ld) */
172*7c478bd9Sstevel@tonic-gate #define	N_FN	0x1e		/* file name symbol */
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate #define	N_EXT	01		/* external bit, or'ed in */
175*7c478bd9Sstevel@tonic-gate #define	N_TYPE	0x1e		/* mask for all the type bits */
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate /*
178*7c478bd9Sstevel@tonic-gate  * Dbx entries have some of the N_STAB bits set.
179*7c478bd9Sstevel@tonic-gate  * These are given in <stab.h>
180*7c478bd9Sstevel@tonic-gate  */
181*7c478bd9Sstevel@tonic-gate #define	N_STAB	0xe0		/* if any of these bits set, a dbx symbol */
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate /*
184*7c478bd9Sstevel@tonic-gate  * Format for namelist values.
185*7c478bd9Sstevel@tonic-gate  */
186*7c478bd9Sstevel@tonic-gate #define	N_FORMAT	"%08x"
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate /*
189*7c478bd9Sstevel@tonic-gate  * secondary sections.
190*7c478bd9Sstevel@tonic-gate  * this stuff follows the string table.
191*7c478bd9Sstevel@tonic-gate  * not even its presence or absence is noted in the
192*7c478bd9Sstevel@tonic-gate  * exec header (?). the secondary header gives
193*7c478bd9Sstevel@tonic-gate  * the number of sections. following it is an
194*7c478bd9Sstevel@tonic-gate  * array of "extra_nsects" int's which give the
195*7c478bd9Sstevel@tonic-gate  * sizeof of the individual sections. the presence of
196*7c478bd9Sstevel@tonic-gate  * even the header is optional.
197*7c478bd9Sstevel@tonic-gate  */
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate #define EXTRA_MAGIC     1040            /* taxing concept  */
200*7c478bd9Sstevel@tonic-gate #define EXTRA_IDENT     0               /* ident's in 0th extra section */
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate struct extra_sections {
203*7c478bd9Sstevel@tonic-gate 	   	int     extra_magic;            /* should be EXTRA_MAGIC */
204*7c478bd9Sstevel@tonic-gate 	   	int     extra_nsects;           /* number of extra sections */
205*7c478bd9Sstevel@tonic-gate };
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate #endif /*!_sparc_a_out_h*/
208