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