1 /* 2 * CDDL HEADER START 3 * 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 7 * with the License. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1988 AT&T */ 23 /* All Rights Reserved */ 24 25 26 #ifndef _SYMS_H 27 #define _SYMS_H 28 29 /* Storage Classes are defined in storclass.h */ 30 #include <storclass.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* Number of characters in a symbol name */ 37 #define SYMNMLEN 8 38 /* Number of characters in a file name */ 39 #define FILNMLEN 14 40 /* Number of array dimensions in auxiliary entry */ 41 #define DIMNUM 4 42 43 struct syment 44 { 45 union 46 { 47 char _n_name[SYMNMLEN]; /* old COFF version */ 48 struct 49 { 50 long _n_zeroes; /* new == 0 */ 51 long _n_offset; /* offset into string table */ 52 } _n_n; 53 char *_n_nptr[2]; /* allows for overlaying */ 54 } _n; 55 unsigned long n_value; /* value of symbol */ 56 short n_scnum; /* section number */ 57 unsigned short n_type; /* type and derived type */ 58 char n_sclass; /* storage class */ 59 char n_numaux; /* number of aux. entries */ 60 }; 61 62 #define n_name _n._n_name 63 #define n_nptr _n._n_nptr[1] 64 #define n_zeroes _n._n_n._n_zeroes 65 #define n_offset _n._n_n._n_offset 66 67 /* 68 * Relocatable symbols have a section number of the 69 * section in which they are defined. Otherwise, section 70 * numbers have the following meanings: 71 */ 72 /* undefined symbol */ 73 #define N_UNDEF 0 74 /* value of symbol is absolute */ 75 #define N_ABS -1 76 /* special debugging symbol -- value of symbol is meaningless */ 77 #define N_DEBUG -2 78 /* indicates symbol needs transfer vector (preload) */ 79 #define N_TV (unsigned short)-3 80 81 /* indicates symbol needs transfer vector (postload) */ 82 83 #define P_TV (unsigned short)-4 84 85 /* 86 * The fundamental type of a symbol packed into the low 87 * 4 bits of the word. 88 */ 89 90 #define _EF ".ef" 91 92 #define T_NULL 0 93 #define T_ARG 1 /* function argument (only used by compiler) */ 94 #define T_CHAR 2 /* character */ 95 #define T_SHORT 3 /* short integer */ 96 #define T_INT 4 /* integer */ 97 #define T_LONG 5 /* long integer */ 98 #define T_FLOAT 6 /* floating point */ 99 #define T_DOUBLE 7 /* double word */ 100 #define T_STRUCT 8 /* structure */ 101 #define T_UNION 9 /* union */ 102 #define T_ENUM 10 /* enumeration */ 103 #define T_MOE 11 /* member of enumeration */ 104 #define T_UCHAR 12 /* unsigned character */ 105 #define T_USHORT 13 /* unsigned short */ 106 #define T_UINT 14 /* unsigned integer */ 107 #define T_ULONG 15 /* unsigned long */ 108 109 /* 110 * derived types are: 111 */ 112 113 #define DT_NON 0 /* no derived type */ 114 #define DT_PTR 1 /* pointer */ 115 #define DT_FCN 2 /* function */ 116 #define DT_ARY 3 /* array */ 117 118 /* 119 * type packing constants 120 */ 121 122 #define N_BTMASK 017 123 #define N_TMASK 060 124 #define N_TMASK1 0300 125 #define N_TMASK2 0360 126 #define N_BTSHFT 4 127 #define N_TSHIFT 2 128 129 /* 130 * MACROS 131 */ 132 133 /* Basic Type of x */ 134 135 #define BTYPE(x) ((x) & N_BTMASK) 136 137 /* Is x a pointer ? */ 138 139 #define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) 140 141 /* Is x a function ? */ 142 143 #define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) 144 145 /* Is x an array ? */ 146 147 #define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) 148 149 /* Is x a structure, union, or enumeration TAG? */ 150 151 #define ISTAG(x) ((x) == C_STRTAG || (x) == C_UNTAG || (x) == C_ENTAG) 152 153 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(DT_PTR<<N_BTSHFT)|(x&N_BTMASK)) 154 155 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) 156 157 /* 158 * AUXILIARY ENTRY FORMAT 159 */ 160 161 union auxent 162 { 163 struct 164 { 165 long x_tagndx; /* str, un, or enum tag indx */ 166 union 167 { 168 struct 169 { 170 unsigned short x_lnno; /* declaration line */ 171 /* number */ 172 unsigned short x_size; /* str, union, array */ 173 /* size */ 174 } x_lnsz; 175 long x_fsize; /* size of function */ 176 } x_misc; 177 union 178 { 179 struct /* if ISFCN, tag, or .bb */ 180 { 181 long x_lnnoptr; /* ptr to fcn line # */ 182 long x_endndx; /* entry ndx past */ 183 /* block end */ 184 } x_fcn; 185 struct /* if ISARY, up to 4 dimen. */ 186 { 187 unsigned short x_dimen[DIMNUM]; 188 } x_ary; 189 } x_fcnary; 190 unsigned short x_tvndx; /* tv index */ 191 } x_sym; 192 struct 193 { 194 char x_fname[FILNMLEN]; 195 } x_file; 196 struct 197 { 198 long x_scnlen; /* section length */ 199 unsigned short x_nreloc; /* number of reloc entries */ 200 unsigned short x_nlinno; /* number of line numbers */ 201 } x_scn; 202 203 struct 204 { 205 long x_tvfill; /* tv fill value */ 206 unsigned short x_tvlen; /* length of .tv */ 207 unsigned short x_tvran[2]; /* tv range */ 208 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ 209 }; 210 211 #define SYMENT struct syment 212 #define SYMESZ 18 /* sizeof(SYMENT) */ 213 214 #define AUXENT union auxent 215 #define AUXESZ 18 /* sizeof(AUXENT) */ 216 217 /* Defines for "special" symbols */ 218 219 #define _ETEXT "etext" 220 #define _EDATA "edata" 221 #define _END "end" 222 #define _START "_start" 223 224 #ifdef __cplusplus 225 } 226 #endif 227 228 #endif /* _SYMS_H */ 229