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