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