1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 1618 rie * Common Development and Distribution License (the "License"). 6 1618 rie * You may not use this file except in compliance with the License. 7 0 stevel * 8 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 0 stevel * or http://www.opensolaris.org/os/licensing. 10 0 stevel * See the License for the specific language governing permissions 11 0 stevel * and limitations under the License. 12 0 stevel * 13 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 14 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 0 stevel * If applicable, add the following below this CDDL HEADER, with the 16 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 17 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 18 0 stevel * 19 0 stevel * CDDL HEADER END 20 0 stevel */ 21 1618 rie 22 0 stevel /* 23 0 stevel * Copyright (c) 1988 AT&T 24 0 stevel * All Rights Reserved 25 0 stevel * 26 9085 Ali * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27 1618 rie * Use is subject to license terms. 28 0 stevel */ 29 0 stevel 30 0 stevel #ifndef _CONV_H 31 0 stevel #define _CONV_H 32 0 stevel 33 0 stevel /* 34 0 stevel * Global include file for conversion library. 35 0 stevel */ 36 0 stevel 37 0 stevel #include <stdlib.h> 38 0 stevel #include <libelf.h> 39 0 stevel #include <dlfcn.h> 40 0 stevel #include <libld.h> 41 0 stevel #include <sgs.h> 42 9273 Ali #include <sgsmsg.h> 43 0 stevel 44 0 stevel #ifdef __cplusplus 45 0 stevel extern "C" { 46 0 stevel #endif 47 0 stevel 48 0 stevel /* 49 0 stevel * Configuration features available - maintained here (instead of debug.h) 50 0 stevel * to save libconv from having to include debug.h which results in numerous 51 0 stevel * "declared but not used or defined" lint errors. 52 0 stevel */ 53 0 stevel #define CONF_EDLIBPATH 0x000100 /* ELF default library path */ 54 0 stevel #define CONF_ESLIBPATH 0x000200 /* ELF secure library path */ 55 0 stevel #define CONF_ADLIBPATH 0x000400 /* AOUT default library path */ 56 0 stevel #define CONF_ASLIBPATH 0x000800 /* AOUT secure library path */ 57 0 stevel #define CONF_DIRCFG 0x001000 /* directory configuration available */ 58 0 stevel #define CONF_OBJALT 0x002000 /* object alternatives available */ 59 0 stevel #define CONF_MEMRESV 0x004000 /* memory reservation required */ 60 0 stevel #define CONF_ENVS 0x008000 /* environment variables available */ 61 0 stevel #define CONF_FLTR 0x010000 /* filter information available */ 62 0 stevel #define CONF_FEATMSK 0xffff00 63 9406 Ali 64 9406 Ali 65 9406 Ali /* 66 9406 Ali * Valid flags for conv_strproc_extract_value(). 67 9406 Ali */ 68 9406 Ali #define CONV_SPEXV_F_NOTRIM 0x0001 /* Do not trim whitespace around '=' */ 69 9406 Ali #define CONV_SPEXV_F_UCASE 0x0002 /* Convert value to uppercase */ 70 9406 Ali #define CONV_SPEXV_F_NULLOK 0x0004 /* Empty ("") value is OK */ 71 0 stevel 72 0 stevel /* 73 4734 ab196087 * Buffer types: 74 4734 ab196087 * 75 4734 ab196087 * Many of the routines in this module require the user to supply a 76 4734 ab196087 * buffer into which the desired strings may be written. These are 77 4734 ab196087 * all arrays of characters, and might be defined as simple arrays 78 4734 ab196087 * of char. The problem with that approach is that when such an array 79 4734 ab196087 * is passed to a function, the C language considers it to have the 80 4734 ab196087 * type (char *), without any regard to its length. Not all of our 81 4734 ab196087 * buffers have the same length, and we want to ensure that the compiler 82 4734 ab196087 * will refuse to compile code that passes the wrong type of buffer to 83 4734 ab196087 * a given routine. The solution is to define the buffers as unions 84 4734 ab196087 * that contain the needed array, and then to pass the given union 85 4734 ab196087 * by address. The compiler will catch attempts to pass the wrong type 86 4734 ab196087 * of pointer, and the size of a structure/union is implicit in its type. 87 4734 ab196087 * 88 4734 ab196087 * A nice side effect of this approach is that we can use a union with 89 4734 ab196087 * multiple buffers to handle the cases where a given routine needs 90 4734 ab196087 * more than one type of buffer. The end result is a single buffer large 91 4734 ab196087 * enough to handle any of the subcases, but no larger. 92 4734 ab196087 */ 93 4734 ab196087 94 4734 ab196087 /* 95 4734 ab196087 * Size of buffer used by conv_invalid_val(): 96 4734 ab196087 * 97 1618 rie * Various values that can't be matched to a symbolic definition are converted 98 4734 ab196087 * to a numeric string. 99 1618 rie * 100 4734 ab196087 * The buffer size reflects the maximum number of digits needed to 101 4734 ab196087 * display an integer as text, plus a trailing null, and with room for 102 4734 ab196087 * a leading "0x" if hexidecimal display is selected. 103 9273 Ali * 104 9273 Ali * The 32-bit version of this requires 12 characters, and the 64-bit version 105 9273 Ali * needs 22. By using the larger value for both, we can have a single 106 9273 Ali * definition, which is necessary for code that is ELFCLASS independent. A 107 9273 Ali * nice side benefit is that it lets us dispense with a large number of 32/64 108 9273 Ali * buffer size definitions that build off CONV_INV_BUFSIZE, and the macros 109 9273 Ali * that would then be needed. 110 4734 ab196087 */ 111 9273 Ali #define CONV_INV_BUFSIZE 22 112 4734 ab196087 typedef union { 113 9273 Ali char buf[CONV_INV_BUFSIZE]; 114 9273 Ali } Conv_inv_buf_t; 115 4734 ab196087 116 4734 ab196087 /* conv_ehdr_flags() */ 117 9273 Ali #define CONV_EHDR_FLAGS_BUFSIZE 91 118 4734 ab196087 typedef union { 119 9273 Ali Conv_inv_buf_t inv_buf; 120 9273 Ali char buf[CONV_EHDR_FLAGS_BUFSIZE]; 121 9273 Ali } Conv_ehdr_flags_buf_t; 122 4734 ab196087 123 4734 ab196087 /* conv_reject_desc() */ 124 4734 ab196087 typedef union { 125 9273 Ali Conv_inv_buf_t inv_buf; 126 9273 Ali Conv_ehdr_flags_buf_t flags_buf; 127 9273 Ali } Conv_reject_desc_buf_t; 128 4734 ab196087 129 4734 ab196087 /* 130 4734 ab196087 * conv_cap_val_hw1() 131 4734 ab196087 * 132 4734 ab196087 * This size is based on the maximum number of hardware capabilities 133 4734 ab196087 * that exist. See common/elfcap. 134 4734 ab196087 */ 135 4734 ab196087 #define CONV_CAP_VAL_HW1_BUFSIZE 195 136 4734 ab196087 typedef union { 137 9273 Ali Conv_inv_buf_t inv_buf; 138 9273 Ali char buf[CONV_CAP_VAL_HW1_BUFSIZE]; 139 9273 Ali } Conv_cap_val_hw1_buf_t; 140 4734 ab196087 141 4734 ab196087 /* 142 4734 ab196087 * conv_cap_val_sf1() 143 4734 ab196087 * 144 4734 ab196087 * This size is based on the maximum number of software capabilities 145 4734 ab196087 * that exist. See common/elfcap. 146 4734 ab196087 */ 147 4734 ab196087 #define CONV_CAP_VAL_SF1_BUFSIZE 45 148 4734 ab196087 typedef union { 149 9273 Ali Conv_inv_buf_t inv_buf; 150 9273 Ali char buf[CONV_CAP_VAL_SF1_BUFSIZE]; 151 9273 Ali } Conv_cap_val_sf1_buf_t; 152 4734 ab196087 153 4734 ab196087 /* conv_cap_val_buf() */ 154 4734 ab196087 typedef union { 155 9273 Ali Conv_inv_buf_t inv_buf; 156 9273 Ali Conv_cap_val_hw1_buf_t cap_val_hw1_buf; 157 9273 Ali Conv_cap_val_sf1_buf_t cap_val_sf1_buf; 158 9273 Ali } Conv_cap_val_buf_t; 159 4734 ab196087 160 4734 ab196087 /* conv_config_feat() */ 161 9273 Ali #define CONV_CONFIG_FEAT_BUFSIZE 204 162 4734 ab196087 typedef union { 163 9273 Ali Conv_inv_buf_t inv_buf; 164 9273 Ali char buf[CONV_CONFIG_FEAT_BUFSIZE]; 165 9273 Ali } Conv_config_feat_buf_t; 166 4734 ab196087 167 4734 ab196087 /* conv_config_obj() */ 168 9273 Ali #define CONV_CONFIG_OBJ_BUFSIZE 164 169 4734 ab196087 typedef union { 170 9273 Ali Conv_inv_buf_t inv_buf; 171 9273 Ali char buf[CONV_CONFIG_OBJ_BUFSIZE]; 172 9273 Ali } Conv_config_obj_buf_t; 173 4734 ab196087 174 4734 ab196087 /* conv_dl_mode() */ 175 9273 Ali #define CONV_DL_MODE_BUFSIZE 132 176 4734 ab196087 typedef union { 177 9273 Ali Conv_inv_buf_t inv_buf; 178 9273 Ali char buf[CONV_DL_MODE_BUFSIZE]; 179 9273 Ali } Conv_dl_mode_buf_t; 180 4734 ab196087 181 4734 ab196087 /* conv_dl_flag() */ 182 9273 Ali #define CONV_DL_FLAG_BUFSIZE 185 183 4734 ab196087 typedef union { 184 9273 Ali Conv_inv_buf_t inv_buf; 185 9273 Ali char buf[CONV_DL_FLAG_BUFSIZE]; 186 9273 Ali } Conv_dl_flag_buf_t; 187 4734 ab196087 188 4734 ab196087 /* conv_grphdl_flags() */ 189 9963 Rod #define CONV_GRPHDL_FLAGS_BUFSIZE 78 190 4734 ab196087 typedef union { 191 9273 Ali Conv_inv_buf_t inv_buf; 192 9273 Ali char buf[CONV_GRPHDL_FLAGS_BUFSIZE]; 193 9273 Ali } Conv_grphdl_flags_buf_t; 194 4734 ab196087 195 4734 ab196087 /* conv_grpdesc_flags() */ 196 9577 Rod #define CONV_GRPDESC_FLAGS_BUFSIZE 91 197 4734 ab196087 typedef union { 198 9273 Ali Conv_inv_buf_t inv_buf; 199 9273 Ali char buf[CONV_GRPDESC_FLAGS_BUFSIZE]; 200 9273 Ali } Conv_grpdesc_flags_buf_t; 201 4734 ab196087 202 4734 ab196087 /* conv_seg_flags() */ 203 9273 Ali #define CONV_SEG_FLAGS_BUFSIZE 196 204 4734 ab196087 typedef union { 205 9273 Ali Conv_inv_buf_t inv_buf; 206 9273 Ali char buf[CONV_SEG_FLAGS_BUFSIZE]; 207 9273 Ali } Conv_seg_flags_buf_t; 208 4734 ab196087 209 4734 ab196087 /* conv_dyn_posflag1() */ 210 9273 Ali #define CONV_DYN_POSFLAG1_BUFSIZE 57 211 4734 ab196087 typedef union { 212 9273 Ali Conv_inv_buf_t inv_buf; 213 9273 Ali char buf[CONV_DYN_POSFLAG1_BUFSIZE]; 214 9273 Ali } Conv_dyn_posflag1_buf_t; 215 4734 ab196087 216 4734 ab196087 /* conv_dyn_flag() */ 217 9273 Ali #define CONV_DYN_FLAG_BUFSIZE 85 218 4734 ab196087 typedef union { 219 9273 Ali Conv_inv_buf_t inv_buf; 220 9273 Ali char buf[CONV_DYN_FLAG_BUFSIZE]; 221 9273 Ali } Conv_dyn_flag_buf_t; 222 4734 ab196087 223 4734 ab196087 /* conv_dyn_flag1() */ 224 9273 Ali #define CONV_DYN_FLAG1_BUFSIZE 361 225 4734 ab196087 typedef union { 226 9273 Ali Conv_inv_buf_t inv_buf; 227 9273 Ali char buf[CONV_DYN_FLAG1_BUFSIZE]; 228 9273 Ali } Conv_dyn_flag1_buf_t; 229 4734 ab196087 230 4734 ab196087 /* conv_dyn_feature1() */ 231 9273 Ali #define CONV_DYN_FEATURE1_BUFSIZE 54 232 4734 ab196087 typedef union { 233 9273 Ali Conv_inv_buf_t inv_buf; 234 9273 Ali char buf[CONV_DYN_FEATURE1_BUFSIZE]; 235 9273 Ali } Conv_dyn_feature1_buf_t; 236 4734 ab196087 237 4734 ab196087 /* conv_bnd_type() */ 238 9273 Ali #define CONV_BND_TYPE_BUFSIZE 51 239 4734 ab196087 typedef union { 240 9273 Ali Conv_inv_buf_t inv_buf; 241 9273 Ali char buf[CONV_BND_TYPE_BUFSIZE]; 242 9273 Ali } Conv_bnd_type_buf_t; 243 4734 ab196087 244 4734 ab196087 /* conv_bnd_obj() */ 245 9273 Ali #define CONV_BND_OBJ_BUFSIZE 60 246 4734 ab196087 typedef union { 247 9273 Ali Conv_inv_buf_t inv_buf; 248 9273 Ali char buf[CONV_BND_OBJ_BUFSIZE]; 249 9273 Ali } Conv_bnd_obj_buf_t; 250 4734 ab196087 251 4734 ab196087 /* conv_phdr_flags() */ 252 9273 Ali #define CONV_PHDR_FLAGS_BUFSIZE 57 253 4734 ab196087 typedef union { 254 9577 Rod Conv_inv_buf_t inv_buf; 255 9577 Rod char buf[CONV_PHDR_FLAGS_BUFSIZE]; 256 9273 Ali } Conv_phdr_flags_buf_t; 257 4734 ab196087 258 4734 ab196087 /* conv_sec_flags() */ 259 9273 Ali #define CONV_SEC_FLAGS_BUFSIZE 190 260 4734 ab196087 typedef union { 261 9273 Ali Conv_inv_buf_t inv_buf; 262 9273 Ali char buf[CONV_SEC_FLAGS_BUFSIZE]; 263 9273 Ali } Conv_sec_flags_buf_t; 264 4734 ab196087 265 4734 ab196087 /* conv_dwarf_ehe() */ 266 9273 Ali #define CONV_DWARF_EHE_BUFSIZE 43 267 4734 ab196087 typedef union { 268 9273 Ali Conv_inv_buf_t inv_buf; 269 9273 Ali char buf[CONV_DWARF_EHE_BUFSIZE]; 270 9273 Ali } Conv_dwarf_ehe_buf_t; 271 5088 ab196087 272 5088 ab196087 /* conv_syminfo_flags() */ 273 9273 Ali #define CONV_SYMINFO_FLAGS_BUFSIZE 193 274 5088 ab196087 typedef union { 275 9273 Ali Conv_inv_buf_t inv_buf; 276 9273 Ali char buf[CONV_SYMINFO_FLAGS_BUFSIZE]; 277 9273 Ali } Conv_syminfo_flags_buf_t; 278 4734 ab196087 279 6635 ab196087 /* conv_cnote_pr_flags() */ 280 9273 Ali #define CONV_CNOTE_PR_FLAGS_BUFSIZE 254 281 6635 ab196087 typedef union { 282 9273 Ali Conv_inv_buf_t inv_buf; 283 9273 Ali char buf[CONV_CNOTE_PR_FLAGS_BUFSIZE]; 284 9273 Ali } Conv_cnote_pr_flags_buf_t; 285 6635 ab196087 286 6635 ab196087 /* conv_cnote_old_pr_flags() */ 287 9273 Ali #define CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE 174 288 6635 ab196087 typedef union { 289 9273 Ali Conv_inv_buf_t inv_buf; 290 9273 Ali char buf[CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE]; 291 9273 Ali } Conv_cnote_old_pr_flags_buf_t; 292 6635 ab196087 293 6635 ab196087 /* conv_cnote_proc_flag() */ 294 9273 Ali #define CONV_CNOTE_PROC_FLAG_BUFSIZE 39 295 6635 ab196087 typedef union { 296 9273 Ali Conv_inv_buf_t inv_buf; 297 9273 Ali char buf[CONV_CNOTE_PROC_FLAG_BUFSIZE]; 298 9273 Ali } Conv_cnote_proc_flag_buf_t; 299 6635 ab196087 300 6635 ab196087 301 6635 ab196087 /* conv_cnote_sigset() */ 302 9273 Ali #define CONV_CNOTE_SIGSET_BUFSIZE 639 303 6635 ab196087 typedef union { 304 9273 Ali Conv_inv_buf_t inv_buf; 305 9273 Ali char buf[CONV_CNOTE_SIGSET_BUFSIZE]; 306 9273 Ali } Conv_cnote_sigset_buf_t; 307 6635 ab196087 308 6635 ab196087 /* conv_cnote_fltset() */ 309 9273 Ali #define CONV_CNOTE_FLTSET_BUFSIZE 511 310 6635 ab196087 typedef union { 311 9273 Ali Conv_inv_buf_t inv_buf; 312 9273 Ali char buf[CONV_CNOTE_FLTSET_BUFSIZE]; 313 9273 Ali } Conv_cnote_fltset_buf_t; 314 6635 ab196087 315 6635 ab196087 /* conv_cnote_sysset() */ 316 9273 Ali #define CONV_CNOTE_SYSSET_BUFSIZE 3222 317 6635 ab196087 typedef union { 318 9273 Ali Conv_inv_buf_t inv_buf; 319 9273 Ali char buf[CONV_CNOTE_SYSSET_BUFSIZE]; 320 9273 Ali } Conv_cnote_sysset_buf_t; 321 6635 ab196087 322 6635 ab196087 /* conv_cnote_sa_flags() */ 323 9273 Ali #define CONV_CNOTE_SA_FLAGS_BUFSIZE 109 324 6635 ab196087 typedef union { 325 9273 Ali Conv_inv_buf_t inv_buf; 326 9273 Ali char buf[CONV_CNOTE_SA_FLAGS_BUFSIZE]; 327 9273 Ali } Conv_cnote_sa_flags_buf_t; 328 6635 ab196087 329 6635 ab196087 /* conv_cnote_ss_flags() */ 330 9273 Ali #define CONV_CNOTE_SS_FLAGS_BUFSIZE 48 331 6635 ab196087 typedef union { 332 9273 Ali Conv_inv_buf_t inv_buf; 333 9273 Ali char buf[CONV_CNOTE_SS_FLAGS_BUFSIZE]; 334 9273 Ali } Conv_cnote_ss_flags_buf_t; 335 6635 ab196087 336 6635 ab196087 /* conv_cnote_cc_content() */ 337 9273 Ali #define CONV_CNOTE_CC_CONTENT_BUFSIZE 97 338 6635 ab196087 typedef union { 339 9273 Ali Conv_inv_buf_t inv_buf; 340 9273 Ali char buf[CONV_CNOTE_CC_CONTENT_BUFSIZE]; 341 9273 Ali } Conv_cnote_cc_content_buf_t; 342 6635 ab196087 343 6635 ab196087 /* conv_cnote_auxv_af() */ 344 9273 Ali #define CONV_CNOTE_AUXV_AF_BUFSIZE 73 345 6635 ab196087 typedef union { 346 9273 Ali Conv_inv_buf_t inv_buf; 347 9273 Ali char buf[CONV_CNOTE_AUXV_AF_BUFSIZE]; 348 9273 Ali } Conv_cnote_auxv_af_buf_t; 349 6635 ab196087 350 7682 Ali /* conv_ver_flags() */ 351 9273 Ali #define CONV_VER_FLAGS_BUFSIZE 41 352 7682 Ali typedef union { 353 9273 Ali Conv_inv_buf_t inv_buf; 354 9273 Ali char buf[CONV_VER_FLAGS_BUFSIZE]; 355 9273 Ali } Conv_ver_flags_buf_t; 356 4734 ab196087 357 9577 Rod /* 358 9577 Rod * conv_time() 359 9577 Rod * 360 9577 Rod * This size is based on the maximum "hour.min.sec.fraction: " time that 361 9577 Rod * would be expected of ld(). 362 9577 Rod */ 363 9577 Rod #define CONV_TIME_BUFSIZE 18 364 9577 Rod typedef union { 365 9577 Rod char buf[CONV_TIME_BUFSIZE]; 366 9577 Rod } Conv_time_buf_t; 367 5088 ab196087 368 5088 ab196087 /* 369 5088 ab196087 * Many conversion routines accept a fmt_flags argument of this type 370 5088 ab196087 * to allow the caller to modify the output. There are two parts to 371 5088 ab196087 * this value: 372 5088 ab196087 * 373 5088 ab196087 * (1) Format requests (decimal vs hex, etc...) 374 5088 ab196087 * (2) The low order bits specified by CONV_MASK_FMT_ALT 375 5088 ab196087 * and retrieved by CONV_TYPE_FMT_ALT are integer 376 5088 ab196087 * values that specify that an alternate set of 377 9273 Ali * strings should be used. 378 5088 ab196087 * 379 9273 Ali * The fmt_flags value is designed such that a caller can always 380 9273 Ali * supply a 0 in order to receive default behavior. 381 5088 ab196087 */ 382 5088 ab196087 typedef int Conv_fmt_flags_t; 383 5088 ab196087 384 5088 ab196087 /* 385 9273 Ali * Type used to represent ELF constants within libconv. This relies on 386 9273 Ali * the fact that there are no ELF constants that need more than 32-bits, 387 9273 Ali * nor are there any signed values. 388 9273 Ali */ 389 9273 Ali typedef uint32_t Conv_elfvalue_t; 390 9273 Ali 391 9273 Ali /* 392 9273 Ali * Most conversion routines are able to provide strings in one of 393 9273 Ali * several alternative styles. The bottom 8 bits of Conv_fmt_flags_t 394 9273 Ali * are used to specify which strings should be used for a given call 395 9273 Ali * to a conversion routine: 396 5088 ab196087 * 397 9273 Ali * DEFAULT 398 9273 Ali * The default string style used by a given conversion routine is 399 9273 Ali * an independent choice made by that routine. Different routines 400 9273 Ali * make different choices, based largely on historical usage and 401 9273 Ali * the perceived common case. It may be an alias for one of the 402 9273 Ali * specific styles listed below, or it may be unique. 403 9273 Ali * 404 9273 Ali * DUMP 405 9273 Ali * Style of strings used by dump(1). 406 9273 Ali * 407 9273 Ali * FILE 408 9273 Ali * Style of strings used by file(1). 409 9273 Ali * 410 9273 Ali * CRLE 411 9273 Ali * Style of strings used by crle(1). 412 9273 Ali * 413 9273 Ali * CF 414 9273 Ali * Canonical Form: The string is exactly the same as the name 415 9273 Ali * of the #define macro that defines it in the public header files. 416 9273 Ali * (e.g. STB_LOCAL, not LOCL, LOCAL, LOC, or any other variation). 417 9273 Ali * 418 9273 Ali * CFNP 419 9273 Ali * No Prefix Canonical Form: The same strings supplied by CF, 420 9273 Ali * but without their standard prefix. (e.g. LOCAL, instead of STT_LOCAL). 421 9273 Ali * 422 9273 Ali * NF 423 9273 Ali * Natural Form: The form of the strings that might typically be entered 424 9273 Ali * via a keyboard by an interactive user. These are usually the strings 425 9273 Ali * from CFNP, converted to lowercase, although in some cases they may 426 9273 Ali * take some other "natural" form. In command completion applications, 427 9273 Ali * lowercase strings appear less formal, and are easier on the eye. 428 9273 Ali * 429 9273 Ali * Every routine is required to have a default style. The others are optional, 430 9273 Ali * and may not be provided if not needed. If a given conversion routine does 431 9273 Ali * not support alternative strings for a given CONV_FMT_ALT type, it silently 432 9273 Ali * ignores the request and supplies the default set. This means that a utility 433 9273 Ali * like dump(1) is free to specify a style like DUMP to every conversion 434 5088 ab196087 * routine. It will receive its special strings if there are any, and 435 5088 ab196087 * the defaults otherwise. 436 5088 ab196087 */ 437 5088 ab196087 #define CONV_MASK_FMT_ALT 0xff 438 5088 ab196087 #define CONV_TYPE_FMT_ALT(fmt_flags) (fmt_flags & CONV_MASK_FMT_ALT) 439 5088 ab196087 440 5088 ab196087 #define CONV_FMT_ALT_DEFAULT 0 /* "Standard" strings */ 441 9273 Ali #define CONV_FMT_ALT_DUMP 1 /* dump(1) */ 442 9273 Ali #define CONV_FMT_ALT_FILE 2 /* file(1) */ 443 9273 Ali #define CONV_FMT_ALT_CRLE 3 /* crle(1) */ 444 9273 Ali #define CONV_FMT_ALT_CF 4 /* Canonical Form */ 445 9273 Ali #define CONV_FMT_ALT_CFNP 5 /* No Prefix Canonical Form */ 446 9273 Ali #define CONV_FMT_ALT_NF 6 /* Natural Form */ 447 2850 rie 448 2850 rie /* 449 1976 ab196087 * Flags that alter standard formatting for conversion routines. 450 5088 ab196087 * These bits start after the range occupied by CONV_MASK_FMT_ALT. 451 1618 rie */ 452 5088 ab196087 #define CONV_FMT_DECIMAL 0x0100 /* conv_invalid_val() should print */ 453 1976 ab196087 /* integer print as decimal */ 454 1976 ab196087 /* (default is hex) */ 455 5088 ab196087 #define CONV_FMT_SPACE 0x0200 /* conv_invalid_val() should append */ 456 1976 ab196087 /* a space after the number. */ 457 5088 ab196087 #define CONV_FMT_NOBKT 0x0400 /* conv_expn_field() should omit */ 458 5088 ab196087 /* prefix and suffix strings */ 459 1976 ab196087 460 9273 Ali /* 461 9273 Ali * A Val_desc structure is used to associate an ELF constant and 462 9273 Ali * the message code (Msg) for the string that corresponds to it. 463 9273 Ali * 464 9273 Ali * Val_desc2 adds v_osabi and v_mach fields to Val_desc, which allows 465 9273 Ali * for non-generic mappings that apply only to a specific OSABI/machine. 466 9273 Ali * Setting v_osabi to 0 (ELFOSABI_NONE) specifies that any OSABI matches. 467 9273 Ali * Similarly, setting v_mach to 0 (EM_MACH) matches any machine. Hence, 468 9273 Ali * setting v_osabi and v_mach to 0 in a Val_desc2 results in a generic item, 469 9273 Ali * and is equivalent to simply using a Val_desc. 470 9273 Ali * 471 9273 Ali * These structs are used in two different contexts: 472 9273 Ali * 473 9273 Ali * 1) To expand bit-field data items, using conv_expn_field() to 474 9273 Ali * process a NULL terminated array of Val_desc, or conv_expn_field2() 475 9273 Ali * to process a null terminated array of Val_desc2. 476 9273 Ali * 477 9273 Ali * 2) To represent sparse ranges of non-bitfield values, referenced via 478 9273 Ali * conv_ds_vd_t or conv_ds_vd2_t descriptors, as described below. 479 9273 Ali */ 480 9273 Ali typedef struct { 481 9273 Ali Conv_elfvalue_t v_val; /* expansion value */ 482 9273 Ali Msg v_msg; /* associated message string code */ 483 9273 Ali } Val_desc; 484 9273 Ali typedef struct { 485 9273 Ali Conv_elfvalue_t v_val; /* expansion value */ 486 9273 Ali uchar_t v_osabi; /* OSABI to which entry applies */ 487 9273 Ali Half v_mach; /* Machine to which entry applies */ 488 9273 Ali Msg v_msg; /* associated message string code */ 489 9273 Ali } Val_desc2; 490 1618 rie 491 1618 rie /* 492 9273 Ali * The conv_ds_XXX_t structs are used to pull together the information used 493 9273 Ali * to map non-bitfield values to strings. They are a variant family, sharing 494 9273 Ali * the same initial fields, with a generic "header" definition that can be 495 9273 Ali * used to read those common fields and determine which subcase is being 496 9273 Ali * seen. We do this instead of using a single struct containing a type code 497 9273 Ali * and a union in order to allow for static compile-time initialization. 498 9273 Ali * 499 9273 Ali * conv_ds_t is the base type, containing the initial fields common to all 500 9273 Ali * the variants. Variables of type conv_ds_t are never instantiated. This 501 9273 Ali * type exists only to provide a common pointer type that can reference 502 9273 Ali * any of the variants safely. In C++, it would be a virtual base class. 503 9273 Ali * The fields common to all the variants are: 504 9273 Ali * 505 9273 Ali * ds_type: Identifies the variant 506 9273 Ali * ds_baseval/ds_topval: The lower and upper bound of the range 507 9273 Ali * of values represented by this conv_ds_XXX_t descriptor. 508 9273 Ali * 509 9273 Ali * There are three different variants: 510 9273 Ali * conv_ds_msg_t (ds_type == CONV_DS_MSGARR) 511 9273 Ali * This structure references an array of message codes corresponding 512 9273 Ali * to consecutive ELF values. The first item in the array is the Msg 513 9273 Ali * code for the value given by ds_baseval. Consecutive strings follow 514 9273 Ali * in consecutive order. The final item corresponds to the value given 515 9273 Ali * by ds_topval. Zero (0) Msg values can be used to represent missing 516 9273 Ali * values. Entries with a 0 are quietly ignored. 517 9273 Ali * 518 9273 Ali * conv_ds_vd_t (ds_type == CONV_DS_VD) 519 9273 Ali * This structure employs a NULL terminated array of Val_desc structs. 520 9273 Ali * Each Val_desc supplies a mapping from a value in the range 521 9273 Ali * (ds_baseval <= value <= ds_topval). The values described need not 522 9273 Ali * be consecutive, and can be sparse. ds_baseval does not need to 523 9273 Ali * correspond to the first item, and ds_topval need not correspond to 524 9273 Ali * the final item. 525 9273 Ali * 526 9273 Ali * conv_ds_vd2_t (ds_type == CONV_DS_VD2) 527 9273 Ali * This structure employs a NULL terminated array of Val_desc2 structs, 528 9273 Ali * rather than Val_desc, adding the ability to specify OSABI and machine 529 9273 Ali * as part of the value/string mapping. It is otherwise the same thing 530 9273 Ali * as CONV_DS_VD. 531 9273 Ali */ 532 9273 Ali typedef enum { 533 9273 Ali CONV_DS_MSGARR = 0, /* Array of Msg */ 534 9273 Ali CONV_DS_VD = 1, /* Null terminated array of Val_desc */ 535 9273 Ali CONV_DS_VD2 = 2, /* Null terminated array of Val_desc2 */ 536 9273 Ali } conv_ds_type_t; 537 9273 Ali 538 9273 Ali #define CONV_DS_COMMON_FIELDS \ 539 9273 Ali conv_ds_type_t ds_type; /* Type of data structure used */ \ 540 9273 Ali uint32_t ds_baseval; /* Value of first item */ \ 541 9273 Ali uint32_t ds_topval /* Value of last item */ 542 9273 Ali 543 9273 Ali typedef struct { /* Virtual base type --- do not instantiate */ 544 9273 Ali CONV_DS_COMMON_FIELDS; 545 9273 Ali } conv_ds_t; 546 9273 Ali typedef struct { 547 9273 Ali CONV_DS_COMMON_FIELDS; 548 9273 Ali const Msg *ds_msg; 549 9273 Ali } conv_ds_msg_t; 550 9273 Ali typedef struct { 551 9273 Ali CONV_DS_COMMON_FIELDS; 552 9273 Ali const Val_desc *ds_vd; 553 9273 Ali } conv_ds_vd_t; 554 9273 Ali typedef struct { 555 9273 Ali CONV_DS_COMMON_FIELDS; 556 9273 Ali const Val_desc2 *ds_vd2; 557 9273 Ali } conv_ds_vd2_t; 558 9273 Ali 559 9273 Ali /* 560 9273 Ali * The initialization of conv_ds_msg_t can be completely derived from 561 9273 Ali * its base value and the array of Msg codes. CONV_DS_MSG_INIT() is used 562 9273 Ali * to do that. 563 9273 Ali */ 564 9273 Ali #define CONV_DS_MSG_INIT(_baseval, _arr) \ 565 9273 Ali CONV_DS_MSGARR, _baseval, \ 566 9273 Ali _baseval + (sizeof (_arr) / sizeof (_arr[0])) - 1, _arr 567 9273 Ali 568 9273 Ali /* 569 9273 Ali * Null terminated arrays of pointers to conv_ds_XXX_t structs are processed 570 9273 Ali * by conv_map_ds() to convert ELF constants to their symbolic names, and by 571 9273 Ali * conv_iter_ds() to iterate over all the available value/name combinations. 572 9273 Ali * 573 9273 Ali * These pointers are formed by casting the address of the specific 574 9273 Ali * variant types (described above) to generic base type pointer. 575 9273 Ali * CONV_DS_ADDR() is a convenience macro to take the address of 576 9273 Ali * one of these variants and turn it into a generic pointer. 577 9273 Ali */ 578 9273 Ali #define CONV_DS_ADDR(_item) ((conv_ds_t *)&(_item)) 579 9273 Ali 580 9273 Ali /* 581 9273 Ali * Type used by libconv to represent osabi values passed to iteration 582 9273 Ali * functions. The type in the ELF header is uchar_t. However, every possible 583 9273 Ali * value 0-255 has a valid meaning, leaving us no extra value to assign 584 9273 Ali * to mean "ALL". Using Half for osabi leaves us the top byte to use for 585 9273 Ali * out of bound values. 586 9273 Ali * 587 9273 Ali * Non-iteration functions, and any code that does not need to use 588 9273 Ali * CONV_OSABI_ALL, should use uchar_t for osabi. 589 9273 Ali */ 590 9273 Ali typedef Half conv_iter_osabi_t; 591 9273 Ali 592 9273 Ali /* 593 9273 Ali * Many of the iteration functions accept an osabi or mach argument, 594 9273 Ali * used to specify the type of object being processed. The following 595 9273 Ali * values can be used to specify a wildcard that matches any item. Their 596 9273 Ali * values are carefully chosen to ensure that they cannot be interpreted 597 9273 Ali * as an otherwise valid osabi or machine. 598 9273 Ali */ 599 9273 Ali #define CONV_OSABI_ALL 1024 /* Larger than can be represented by uchar_t */ 600 9273 Ali #define CONV_MACH_ALL EM_NUM /* Never a valid machine type */ 601 9273 Ali 602 9273 Ali /* 603 9273 Ali * We compare Val_Desc2 descriptors with a specified osabi and machine 604 9273 Ali * to determine whether to use it or not. This macro encapsulates that logic. 605 9273 Ali * 606 9273 Ali * We consider an osabi to match when any of the following things hold: 607 9273 Ali * 608 9273 Ali * - The descriptor osabi is ELFOSABI_NONE. 609 9273 Ali * - The supplied osabi and the descriptor osabi match 610 9273 Ali * - The supplied osabi is ELFOSABI_NONE, and the descriptor osabi is 611 9273 Ali * ELFOSABI_SOLARIS. Many operating systems, Solaris included, 612 9273 Ali * produce or have produced ELFOSABI_NONE native objects, if only 613 9273 Ali * because OSABI ranges are not an original ELF feature. We 614 9273 Ali * give our own objects the home field advantage. 615 9273 Ali * - Iteration Only: An osabi value of CONV_OSABI_ALL is specified. 616 9273 Ali * 617 9273 Ali * We consider a machine to match when any of the following things hold: 618 9273 Ali * 619 9273 Ali * - The descriptor mach is EM_NONE. 620 9273 Ali * - The supplied mach and the descriptor mach match 621 9273 Ali * - Iteration Only: A mach value of CONV_MACH_ALL is specified. 622 9273 Ali * 623 9273 Ali * The special extra _ALL case for iteration is handled by defining a separate 624 9273 Ali * macro with the extra CONV_xxx_ALL tests. 625 9273 Ali */ 626 9273 Ali #define CONV_VD2_SKIP_OSABI(_osabi, _vdp) \ 627 9273 Ali ((_vdp->v_osabi != ELFOSABI_NONE) && (_vdp->v_osabi != osabi) && \ 628 9273 Ali ((_osabi != ELFOSABI_NONE) || (_vdp->v_osabi != ELFOSABI_SOLARIS))) 629 9273 Ali 630 9273 Ali #define CONV_VD2_SKIP_MACH(_mach, _vdp) \ 631 9273 Ali ((_vdp->v_mach != EM_NONE) && (_vdp->v_mach != _mach)) 632 9273 Ali 633 9273 Ali #define CONV_VD2_SKIP(_osabi, _mach, _vdp) \ 634 9273 Ali (CONV_VD2_SKIP_OSABI(_osabi, _vdp) || CONV_VD2_SKIP_MACH(_mach, _vdp)) 635 9273 Ali 636 9273 Ali #define CONV_ITER_VD2_SKIP(_osabi, _mach, _vdp) \ 637 9273 Ali ((CONV_VD2_SKIP_OSABI(_osabi, _vdp) && (_osabi != CONV_OSABI_ALL)) || \ 638 9273 Ali (CONV_VD2_SKIP_MACH(_mach, _vdp) && (_mach != CONV_MACH_ALL))) 639 9273 Ali 640 9273 Ali 641 9273 Ali /* 642 9273 Ali * Possible return values from iteration functions. 643 9273 Ali */ 644 9273 Ali typedef enum { 645 9273 Ali CONV_ITER_DONE, /* Stop: No more iterations are desired */ 646 9273 Ali CONV_ITER_CONT /* Continue with following iterations */ 647 9273 Ali } conv_iter_ret_t; 648 9273 Ali 649 9273 Ali /* 650 9273 Ali * Prototype for caller supplied callback function to iteration functions. 651 9273 Ali */ 652 9273 Ali typedef conv_iter_ret_t (* conv_iter_cb_t)(const char *str, 653 9273 Ali Conv_elfvalue_t value, void *uvalue); 654 9273 Ali 655 9273 Ali /* 656 9273 Ali * User value block employed by conv_iter_strtol() 657 1618 rie */ 658 1618 rie typedef struct { 659 9273 Ali const char *csl_str; /* String to search for */ 660 9273 Ali size_t csl_strlen; /* # chars in csl_str to examine */ 661 9273 Ali int csl_found; /* Init to 0, set to 1 if item found */ 662 9273 Ali Conv_elfvalue_t csl_value; /* If csl_found, resulting value */ 663 9273 Ali } conv_strtol_uvalue_t; 664 2352 ab196087 665 2352 ab196087 /* 666 2352 ab196087 * conv_expn_field() is willing to supply default strings for the 667 2352 ab196087 * prefix, separator, and suffix arguments, if they are passed as NULL. 668 2352 ab196087 * The caller needs to know how much room to allow for these items. 669 2352 ab196087 * These values supply those sizes. 670 2352 ab196087 */ 671 2352 ab196087 #define CONV_EXPN_FIELD_DEF_PREFIX_SIZE 2 /* Default is "[ " */ 672 2352 ab196087 #define CONV_EXPN_FIELD_DEF_SEP_SIZE 1 /* Default is " " */ 673 2352 ab196087 #define CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 2 /* Default is " ]" */ 674 2352 ab196087 675 2352 ab196087 /* 676 2352 ab196087 * conv_expn_field() requires a large number of inputs, many of which 677 2352 ab196087 * can be NULL to accept default behavior. An argument of the following 678 2352 ab196087 * type is used to supply them. 679 2352 ab196087 */ 680 2352 ab196087 typedef struct { 681 2352 ab196087 char *buf; /* Buffer to receive generated string */ 682 2352 ab196087 size_t bufsize; /* sizeof(buf) */ 683 2352 ab196087 const char **lead_str; /* NULL, or array of pointers to strings to */ 684 2352 ab196087 /* be output at the head of the list. */ 685 2352 ab196087 /* Last entry must be NULL. */ 686 2352 ab196087 Xword oflags; /* Bits for which output strings are desired */ 687 2352 ab196087 Xword rflags; /* Bits for which a numeric value should be */ 688 2352 ab196087 /* output if vdp does not provide str. */ 689 2352 ab196087 /* Must be a proper subset of oflags */ 690 2352 ab196087 const char *prefix; /* NULL, or string to prefix output with */ 691 2352 ab196087 /* If NULL, "[ " is used. */ 692 2352 ab196087 const char *sep; /* NULL, or string to separate output items */ 693 2352 ab196087 /* with. If NULL, " " is used. */ 694 2352 ab196087 const char *suffix; /* NULL, or string to suffix output with */ 695 2352 ab196087 /* If NULL, " ]" is used. */ 696 2352 ab196087 } CONV_EXPN_FIELD_ARG; 697 1618 rie 698 6635 ab196087 /* 699 6635 ab196087 * Callback function for conv_str_to_c_literal(). A user supplied function 700 6635 ab196087 * of this type is called by conv_str_to_c_literal() in order to dispatch 701 6635 ab196087 * the translated output characters. 702 6635 ab196087 * 703 6635 ab196087 * buf - Pointer to output text 704 6635 ab196087 * n - # of characters to output 705 6635 ab196087 * uvalue - User value argument to conv_str_to_c_literal(), 706 6635 ab196087 * passed through without interpretation. 707 6635 ab196087 */ 708 6635 ab196087 typedef void Conv_str_to_c_literal_func_t(const void *ptr, 709 6635 ab196087 size_t size, void *uvalue); 710 6635 ab196087 711 1618 rie /* 712 9273 Ali * Generic miscellaneous interfaces 713 0 stevel */ 714 2647 rie extern uchar_t conv_check_native(char **, char **); 715 9273 Ali extern const char *conv_lddstub(int); 716 9406 Ali extern int conv_strproc_isspace(int); 717 9406 Ali extern char *conv_strproc_trim(char *); 718 9406 Ali extern Boolean conv_strproc_extract_value(char *, size_t, int, 719 9406 Ali const char **); 720 9406 Ali extern int conv_sys_eclass(void); 721 9273 Ali 722 9273 Ali /* 723 9273 Ali * Generic core formatting and iteration functionality 724 9273 Ali */ 725 9273 Ali extern conv_iter_ret_t _conv_iter_ds(conv_iter_osabi_t, Half, 726 9273 Ali const conv_ds_t **, conv_iter_cb_t, void *, 727 9273 Ali const char *); 728 9273 Ali extern conv_iter_ret_t _conv_iter_ds_msg(const conv_ds_msg_t *, 729 9273 Ali conv_iter_cb_t, void *, const char *); 730 9273 Ali extern conv_iter_ret_t _conv_iter_vd(const Val_desc *, conv_iter_cb_t, 731 9273 Ali void *, const char *); 732 9273 Ali extern conv_iter_ret_t _conv_iter_vd2(conv_iter_osabi_t, Half, 733 9273 Ali const Val_desc2 *, conv_iter_cb_t, void *, 734 9273 Ali const char *); 735 9273 Ali extern int conv_iter_strtol_init(const char *, 736 9273 Ali conv_strtol_uvalue_t *); 737 9273 Ali extern conv_iter_ret_t conv_iter_strtol(const char *, Conv_elfvalue_t, void *); 738 9273 Ali extern const char *_conv_map_ds(uchar_t, Half, Conv_elfvalue_t, 739 9273 Ali const conv_ds_t **, Conv_fmt_flags_t, 740 9273 Ali Conv_inv_buf_t *, const char *); 741 9273 Ali 742 9273 Ali 743 9273 Ali /* 744 9273 Ali * Generic formatting interfaces. 745 9273 Ali */ 746 9273 Ali extern const char *conv_bnd_obj(uint_t, Conv_bnd_obj_buf_t *); 747 9273 Ali extern const char *conv_bnd_type(uint_t, Conv_bnd_type_buf_t *); 748 4734 ab196087 extern const char *conv_config_feat(int, Conv_config_feat_buf_t *); 749 4734 ab196087 extern const char *conv_config_obj(ushort_t, Conv_config_obj_buf_t *); 750 1618 rie extern const char *conv_config_upm(const char *, const char *, 751 1618 rie const char *, size_t); 752 6635 ab196087 extern const char *conv_cnote_auxv_af(Word, Conv_fmt_flags_t, 753 6635 ab196087 Conv_cnote_auxv_af_buf_t *); 754 6635 ab196087 extern const char *conv_cnote_auxv_type(Word, Conv_fmt_flags_t, 755 6635 ab196087 Conv_inv_buf_t *); 756 6635 ab196087 extern const char *conv_cnote_cc_content(Lword, Conv_fmt_flags_t, 757 6635 ab196087 Conv_cnote_cc_content_buf_t *); 758 6635 ab196087 extern const char *conv_cnote_errno(int, Conv_fmt_flags_t, 759 6635 ab196087 Conv_inv_buf_t *); 760 6635 ab196087 extern const char *conv_cnote_fault(Word, Conv_fmt_flags_t, 761 6635 ab196087 Conv_inv_buf_t *); 762 6635 ab196087 extern const char *conv_cnote_fltset(uint32_t *, int, 763 6635 ab196087 Conv_fmt_flags_t, Conv_cnote_fltset_buf_t *); 764 6635 ab196087 extern const char *conv_cnote_old_pr_flags(int, Conv_fmt_flags_t, 765 6635 ab196087 Conv_cnote_old_pr_flags_buf_t *); 766 6635 ab196087 extern const char *conv_cnote_pr_dmodel(Word, Conv_fmt_flags_t, 767 6635 ab196087 Conv_inv_buf_t *); 768 6635 ab196087 extern const char *conv_cnote_pr_flags(int, Conv_fmt_flags_t, 769 6635 ab196087 Conv_cnote_pr_flags_buf_t *); 770 6635 ab196087 extern const char *conv_cnote_proc_flag(int, Conv_fmt_flags_t, 771 6635 ab196087 Conv_cnote_proc_flag_buf_t *); 772 6635 ab196087 extern const char *conv_cnote_pr_regname(Half, int, Conv_fmt_flags_t, 773 6635 ab196087 Conv_inv_buf_t *inv_buf); 774 6635 ab196087 extern const char *conv_cnote_pr_stype(Word, Conv_fmt_flags_t, 775 6635 ab196087 Conv_inv_buf_t *); 776 6635 ab196087 extern const char *conv_cnote_pr_what(short, short, Conv_fmt_flags_t, 777 6635 ab196087 Conv_inv_buf_t *); 778 6635 ab196087 extern const char *conv_cnote_pr_why(short, Conv_fmt_flags_t, 779 6635 ab196087 Conv_inv_buf_t *); 780 6635 ab196087 extern const char *conv_cnote_priv(int, Conv_fmt_flags_t, 781 6635 ab196087 Conv_inv_buf_t *); 782 6635 ab196087 extern const char *conv_cnote_psetid(int, Conv_fmt_flags_t, 783 6635 ab196087 Conv_inv_buf_t *); 784 6635 ab196087 extern const char *conv_cnote_sa_flags(int, Conv_fmt_flags_t, 785 6635 ab196087 Conv_cnote_sa_flags_buf_t *); 786 6635 ab196087 extern const char *conv_cnote_signal(Word, Conv_fmt_flags_t, 787 6635 ab196087 Conv_inv_buf_t *); 788 6635 ab196087 extern const char *conv_cnote_si_code(Half, int, int, Conv_fmt_flags_t, 789 6635 ab196087 Conv_inv_buf_t *); 790 6635 ab196087 extern const char *conv_cnote_sigset(uint32_t *, int, 791 6635 ab196087 Conv_fmt_flags_t, Conv_cnote_sigset_buf_t *); 792 6635 ab196087 extern const char *conv_cnote_ss_flags(int, Conv_fmt_flags_t, 793 6635 ab196087 Conv_cnote_ss_flags_buf_t *); 794 6635 ab196087 extern const char *conv_cnote_syscall(Word, Conv_fmt_flags_t, 795 6635 ab196087 Conv_inv_buf_t *); 796 6635 ab196087 extern const char *conv_cnote_sysset(uint32_t *, int, 797 6635 ab196087 Conv_fmt_flags_t, Conv_cnote_sysset_buf_t *); 798 6635 ab196087 extern const char *conv_cnote_type(Word, Conv_fmt_flags_t, 799 6635 ab196087 Conv_inv_buf_t *); 800 4734 ab196087 extern const char *conv_def_tag(Symref, Conv_inv_buf_t *); 801 1618 rie extern const char *conv_demangle_name(const char *); 802 5088 ab196087 extern const char *conv_dl_flag(int, Conv_fmt_flags_t, 803 5088 ab196087 Conv_dl_flag_buf_t *); 804 4734 ab196087 extern const char *conv_dl_mode(int, int, Conv_dl_mode_buf_t *); 805 9085 Ali extern const char *conv_dwarf_cfa(uchar_t, Conv_fmt_flags_t, 806 9085 Ali Conv_inv_buf_t *); 807 4734 ab196087 extern const char *conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *); 808 9085 Ali extern const char *conv_dwarf_regname(Half, Word, Conv_fmt_flags_t, 809 9085 Ali int *, Conv_inv_buf_t *); 810 9273 Ali extern const char *conv_ehdr_abivers(uchar_t, Word, Conv_fmt_flags_t, 811 5088 ab196087 Conv_inv_buf_t *); 812 5088 ab196087 extern const char *conv_ehdr_class(uchar_t, Conv_fmt_flags_t, 813 5088 ab196087 Conv_inv_buf_t *); 814 5088 ab196087 extern const char *conv_ehdr_data(uchar_t, Conv_fmt_flags_t, 815 5088 ab196087 Conv_inv_buf_t *); 816 5088 ab196087 extern const char *conv_ehdr_flags(Half, Word, Conv_fmt_flags_t, 817 5088 ab196087 Conv_ehdr_flags_buf_t *); 818 5088 ab196087 extern const char *conv_ehdr_mach(Half, Conv_fmt_flags_t, 819 5088 ab196087 Conv_inv_buf_t *); 820 5088 ab196087 extern const char *conv_ehdr_osabi(uchar_t, Conv_fmt_flags_t, 821 5088 ab196087 Conv_inv_buf_t *); 822 9273 Ali extern const char *conv_ehdr_type(uchar_t, Half, Conv_fmt_flags_t, 823 5088 ab196087 Conv_inv_buf_t *); 824 5088 ab196087 extern const char *conv_ehdr_vers(Word, Conv_fmt_flags_t, 825 5088 ab196087 Conv_inv_buf_t *); 826 9273 Ali extern const char *conv_elfdata_type(Elf_Type, Conv_inv_buf_t *); 827 9273 Ali extern const char *conv_grphdl_flags(uint_t, Conv_grphdl_flags_buf_t *); 828 9273 Ali extern const char *conv_grpdesc_flags(uint_t, Conv_grpdesc_flags_buf_t *); 829 9273 Ali extern Isa_desc *conv_isalist(void); 830 9273 Ali extern const char *conv_phdr_flags(uchar_t, Word, Conv_fmt_flags_t, 831 5088 ab196087 Conv_phdr_flags_buf_t *); 832 9273 Ali extern const char *conv_phdr_type(uchar_t, Half, Word, Conv_fmt_flags_t, 833 5088 ab196087 Conv_inv_buf_t *); 834 6206 ab196087 extern const char *conv_reject_desc(Rej_desc *, Conv_reject_desc_buf_t *, 835 6206 ab196087 Half mach); 836 5088 ab196087 extern const char *conv_reloc_type(Half, Word, Conv_fmt_flags_t, 837 5088 ab196087 Conv_inv_buf_t *); 838 5088 ab196087 extern const char *conv_reloc_type_static(Half, Word, Conv_fmt_flags_t); 839 5088 ab196087 extern const char *conv_reloc_386_type(Word, Conv_fmt_flags_t, 840 5088 ab196087 Conv_inv_buf_t *); 841 5088 ab196087 extern const char *conv_reloc_amd64_type(Word, Conv_fmt_flags_t, 842 5088 ab196087 Conv_inv_buf_t *); 843 5088 ab196087 extern const char *conv_reloc_SPARC_type(Word, Conv_fmt_flags_t, 844 5088 ab196087 Conv_inv_buf_t *); 845 9273 Ali extern const char *conv_sec_type(uchar_t, Half, Word, Conv_fmt_flags_t, 846 5088 ab196087 Conv_inv_buf_t *); 847 9273 Ali extern const char *conv_seg_flags(Half, Conv_seg_flags_buf_t *); 848 9273 Ali extern void conv_str_to_c_literal(const char *buf, size_t n, 849 9273 Ali Conv_str_to_c_literal_func_t *cb_func, 850 9273 Ali void *uvalue); 851 5088 ab196087 extern const char *conv_sym_info_bind(uchar_t, Conv_fmt_flags_t, 852 5088 ab196087 Conv_inv_buf_t *); 853 5088 ab196087 extern const char *conv_sym_info_type(Half, uchar_t, Conv_fmt_flags_t, 854 4734 ab196087 Conv_inv_buf_t *); 855 9273 Ali extern const char *conv_sym_shndx(uchar_t, Half, Half, Conv_fmt_flags_t, 856 9273 Ali Conv_inv_buf_t *); 857 4734 ab196087 extern const char *conv_sym_other(uchar_t, Conv_inv_buf_t *); 858 5088 ab196087 extern const char *conv_sym_other_vis(uchar_t, Conv_fmt_flags_t, 859 5088 ab196087 Conv_inv_buf_t *); 860 9273 Ali extern const char *conv_syminfo_boundto(Half, Conv_fmt_flags_t, 861 9273 Ali Conv_inv_buf_t *); 862 9273 Ali extern const char *conv_syminfo_flags(Half, Conv_fmt_flags_t, 863 9273 Ali Conv_syminfo_flags_buf_t *); 864 9577 Rod extern const char *conv_time(struct timeval *, struct timeval *, 865 9577 Rod Conv_time_buf_t *); 866 9273 Ali extern Uts_desc *conv_uts(void); 867 9273 Ali extern const char *conv_ver_flags(Half, Conv_fmt_flags_t, 868 9273 Ali Conv_ver_flags_buf_t *); 869 9273 Ali extern const char *conv_ver_index(Versym, int, Conv_inv_buf_t *); 870 9273 Ali 871 9273 Ali 872 9273 Ali /* 873 9273 Ali * Generic iteration interfaces. 874 9273 Ali */ 875 9273 Ali extern conv_iter_ret_t conv_iter_cap_tags(Conv_fmt_flags_t, conv_iter_cb_t, 876 9273 Ali void *); 877 9273 Ali extern conv_iter_ret_t conv_iter_cap_val_hw1(Half, Conv_fmt_flags_t, 878 9273 Ali conv_iter_cb_t, void *); 879 9273 Ali extern conv_iter_ret_t conv_iter_cap_val_sf1(Conv_fmt_flags_t, conv_iter_cb_t, 880 9273 Ali void *); 881 9273 Ali 882 9273 Ali extern conv_iter_ret_t conv_iter_dyn_feature1(Conv_fmt_flags_t, conv_iter_cb_t, 883 9273 Ali void *); 884 9273 Ali extern conv_iter_ret_t conv_iter_dyn_flag(Conv_fmt_flags_t, conv_iter_cb_t, 885 9273 Ali void *); 886 9273 Ali extern conv_iter_ret_t conv_iter_dyn_flag1(Conv_fmt_flags_t, conv_iter_cb_t, 887 9273 Ali void *); 888 9273 Ali extern conv_iter_ret_t conv_iter_dyn_posflag1(Conv_fmt_flags_t, conv_iter_cb_t, 889 9273 Ali void *); 890 9273 Ali extern conv_iter_ret_t conv_iter_dyn_tag(conv_iter_osabi_t, Half, 891 9273 Ali Conv_fmt_flags_t, conv_iter_cb_t, void *); 892 9273 Ali 893 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_abivers(conv_iter_osabi_t, 894 9273 Ali Conv_fmt_flags_t, conv_iter_cb_t, void *); 895 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_class(Conv_fmt_flags_t, conv_iter_cb_t, 896 9273 Ali void *); 897 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_data(Conv_fmt_flags_t, conv_iter_cb_t, 898 9273 Ali void *); 899 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_eident(Conv_fmt_flags_t, conv_iter_cb_t, 900 9273 Ali void *); 901 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_flags(Half, Conv_fmt_flags_t, 902 9273 Ali conv_iter_cb_t, void *); 903 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_mach(Conv_fmt_flags_t, conv_iter_cb_t, 904 9273 Ali void *); 905 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_osabi(Conv_fmt_flags_t, conv_iter_cb_t, 906 9273 Ali void *); 907 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_type(conv_iter_osabi_t, Conv_fmt_flags_t, 908 9273 Ali conv_iter_cb_t, void *); 909 9273 Ali extern conv_iter_ret_t conv_iter_ehdr_vers(Conv_fmt_flags_t, conv_iter_cb_t, 910 9273 Ali void *); 911 9273 Ali 912 9273 Ali extern conv_iter_ret_t conv_iter_phdr_flags(conv_iter_osabi_t, 913 9273 Ali Conv_fmt_flags_t, conv_iter_cb_t, void *); 914 9273 Ali extern conv_iter_ret_t conv_iter_phdr_type(conv_iter_osabi_t, Conv_fmt_flags_t, 915 9273 Ali conv_iter_cb_t, void *); 916 9273 Ali 917 9273 Ali extern conv_iter_ret_t conv_iter_sec_flags(conv_iter_osabi_t, Half, 918 9273 Ali Conv_fmt_flags_t, conv_iter_cb_t, void *); 919 9273 Ali extern conv_iter_ret_t conv_iter_sec_symtab(conv_iter_osabi_t, 920 9273 Ali Conv_fmt_flags_t, conv_iter_cb_t, void *); 921 9273 Ali extern conv_iter_ret_t conv_iter_sec_type(conv_iter_osabi_t, Half, 922 9273 Ali Conv_fmt_flags_t, conv_iter_cb_t, void *); 923 9273 Ali 924 9273 Ali extern conv_iter_ret_t conv_iter_sym_info_bind(Conv_fmt_flags_t, 925 9273 Ali conv_iter_cb_t, void *); 926 9273 Ali extern conv_iter_ret_t conv_iter_sym_other_vis(Conv_fmt_flags_t, 927 9273 Ali conv_iter_cb_t, void *); 928 9273 Ali extern conv_iter_ret_t conv_iter_sym_shndx(conv_iter_osabi_t, Half, 929 9273 Ali Conv_fmt_flags_t, conv_iter_cb_t, void *); 930 9273 Ali extern conv_iter_ret_t conv_iter_sym_info_type(Half, Conv_fmt_flags_t, 931 9273 Ali conv_iter_cb_t, void *); 932 9273 Ali 933 9273 Ali extern conv_iter_ret_t conv_iter_syminfo_boundto(Conv_fmt_flags_t, 934 9273 Ali conv_iter_cb_t, void *); 935 9273 Ali extern conv_iter_ret_t conv_iter_syminfo_flags(Conv_fmt_flags_t, 936 9273 Ali conv_iter_cb_t, void *); 937 9273 Ali 938 9273 Ali /* 939 9273 Ali * Define all class specific routines. 940 9273 Ali */ 941 9273 Ali #if defined(_ELF64) 942 9273 Ali #define conv_cap_tag conv64_cap_tag 943 9273 Ali #define conv_cap_val conv64_cap_val 944 9273 Ali #define conv_cap_val_hw1 conv64_cap_val_hw1 945 9273 Ali #define conv_cap_val_sf1 conv64_cap_val_sf1 946 9273 Ali #define conv_dyn_feature1 conv64_dyn_feature1 947 9273 Ali #define conv_dyn_flag1 conv64_dyn_flag1 948 9273 Ali #define conv_dyn_flag conv64_dyn_flag 949 9273 Ali #define conv_dyn_posflag1 conv64_dyn_posflag1 950 9273 Ali #define conv_dyn_tag conv64_dyn_tag 951 9273 Ali #define _conv_expn_field _conv64_expn_field 952 9273 Ali #define _conv_expn_field2 _conv64_expn_field2 953 9273 Ali #define conv_invalid_val conv64_invalid_val 954 9273 Ali #define conv_sec_flags conv64_sec_flags 955 9273 Ali #define conv_sec_linkinfo conv64_sec_linkinfo 956 9273 Ali #define conv_sym_value conv64_sym_value 957 9273 Ali #define conv_sym_SPARC_value conv64_sym_SPARC_value 958 9273 Ali #else 959 9273 Ali #define conv_cap_tag conv32_cap_tag 960 9273 Ali #define conv_cap_val conv32_cap_val 961 9273 Ali #define conv_cap_val_hw1 conv32_cap_val_hw1 962 9273 Ali #define conv_cap_val_sf1 conv32_cap_val_sf1 963 9273 Ali #define conv_dyn_feature1 conv32_dyn_feature1 964 9273 Ali #define conv_dyn_flag1 conv32_dyn_flag1 965 9273 Ali #define conv_dyn_flag conv32_dyn_flag 966 9273 Ali #define conv_dyn_posflag1 conv32_dyn_posflag1 967 9273 Ali #define conv_dyn_tag conv32_dyn_tag 968 9273 Ali #define _conv_expn_field _conv32_expn_field 969 9273 Ali #define _conv_expn_field2 _conv32_expn_field2 970 9273 Ali #define conv_invalid_val conv32_invalid_val 971 9273 Ali #define conv_sec_flags conv32_sec_flags 972 9273 Ali #define conv_sec_linkinfo conv32_sec_linkinfo 973 9273 Ali #define conv_sym_value conv32_sym_value 974 9273 Ali #define conv_sym_SPARC_value conv32_sym_SPARC_value 975 9273 Ali #endif 976 9273 Ali 977 9273 Ali /* 978 9273 Ali * ELFCLASS-specific core formatting functionality 979 9273 Ali */ 980 9273 Ali extern int _conv_expn_field(CONV_EXPN_FIELD_ARG *, 981 9273 Ali const Val_desc *, Conv_fmt_flags_t, const char *); 982 9273 Ali extern int _conv_expn_field2(CONV_EXPN_FIELD_ARG *, uchar_t, 983 9273 Ali Half, const Val_desc2 *, Conv_fmt_flags_t, 984 9273 Ali const char *); 985 9273 Ali extern const char *conv_invalid_val(Conv_inv_buf_t *, Xword, 986 9273 Ali Conv_fmt_flags_t); 987 9273 Ali 988 9273 Ali /* 989 9273 Ali * ELFCLASS-specific formatting interfaces. 990 9273 Ali */ 991 9273 Ali extern const char *conv_cap_tag(Xword, Conv_fmt_flags_t, 992 9273 Ali Conv_inv_buf_t *); 993 9273 Ali extern const char *conv_cap_val(Xword, Xword, Half, Conv_cap_val_buf_t *); 994 9273 Ali extern const char *conv_cap_val_hw1(Xword, Half, Conv_fmt_flags_t, 995 9273 Ali Conv_cap_val_hw1_buf_t *); 996 9273 Ali extern const char *conv_cap_val_sf1(Xword, Half, Conv_fmt_flags_t, 997 9273 Ali Conv_cap_val_sf1_buf_t *); 998 9273 Ali extern const char *conv_dyn_flag1(Xword, Conv_fmt_flags_t, 999 9273 Ali Conv_dyn_flag1_buf_t *); 1000 9273 Ali extern const char *conv_dyn_flag(Xword, Conv_fmt_flags_t, 1001 9273 Ali Conv_dyn_flag_buf_t *); 1002 9273 Ali extern const char *conv_dyn_posflag1(Xword, Conv_fmt_flags_t, 1003 9273 Ali Conv_dyn_posflag1_buf_t *); 1004 9273 Ali extern const char *conv_dyn_tag(Xword, uchar_t, Half, Conv_fmt_flags_t, 1005 9273 Ali Conv_inv_buf_t *); 1006 9273 Ali extern const char *conv_dyn_feature1(Xword, Conv_fmt_flags_t, 1007 9273 Ali Conv_dyn_feature1_buf_t *); 1008 9273 Ali extern const char *conv_sec_flags(uchar_t osabi, Half mach, Xword, 1009 9273 Ali Conv_fmt_flags_t, Conv_sec_flags_buf_t *); 1010 9273 Ali extern const char *conv_sec_linkinfo(Word, Xword, Conv_inv_buf_t *); 1011 4734 ab196087 extern const char *conv_sym_value(Half, uchar_t, Addr, Conv_inv_buf_t *); 1012 5088 ab196087 extern const char *conv_sym_SPARC_value(Addr, Conv_fmt_flags_t, 1013 5088 ab196087 Conv_inv_buf_t *); 1014 9273 Ali 1015 9273 Ali /* 1016 9273 Ali * Define macros for _conv_XXX() routines that accept local_sgs_msg as the 1017 9273 Ali * final argument. The macros hide that argument from the caller's view and 1018 9273 Ali * supply the SGS message array for the file from which the macro is used 1019 9273 Ali * in its place. This trick is used to allow these functions to access the 1020 9273 Ali * message strings from any source file they are called from. 1021 9273 Ali */ 1022 9273 Ali #define conv_expn_field(_arg, _vdp, _fmt_flags) \ 1023 9273 Ali _conv_expn_field(_arg, _vdp, _fmt_flags, MSG_SGS_LOCAL_ARRAY) 1024 9273 Ali 1025 9273 Ali #define conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags) \ 1026 9273 Ali _conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags, \ 1027 9273 Ali MSG_SGS_LOCAL_ARRAY) 1028 9273 Ali 1029 9273 Ali #define conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue) \ 1030 9273 Ali _conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY) 1031 9273 Ali 1032 9273 Ali #define conv_iter_vd(_vdp, _func, _uvalue) \ 1033 9273 Ali _conv_iter_vd(_vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY) 1034 9273 Ali 1035 9273 Ali #define conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue) \ 1036 9273 Ali _conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY) 1037 9273 Ali 1038 9273 Ali #define conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf) \ 1039 9273 Ali _conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf, \ 1040 9273 Ali MSG_SGS_LOCAL_ARRAY) 1041 9273 Ali 1042 0 stevel 1043 0 stevel #ifdef __cplusplus 1044 0 stevel } 1045 0 stevel #endif 1046 0 stevel 1047 0 stevel #endif /* _CONV_H */ 1048