10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51618Srie * Common Development and Distribution License (the "License"). 61618Srie * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211618Srie 220Sstevel@tonic-gate /* 233466Srie * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * String conversion routine for .dynamic tag entries. 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate #include <stdio.h> 320Sstevel@tonic-gate #include <string.h> 330Sstevel@tonic-gate #include <sys/elf_SPARC.h> 34280Srie #include "rtld.h" 350Sstevel@tonic-gate #include "_conv.h" 360Sstevel@tonic-gate #include "dynamic_msg.h" 370Sstevel@tonic-gate 383492Sab196087 393492Sab196087 403492Sab196087 /* Instantiate a local copy of conv_map2str() from _conv.h */ 413492Sab196087 DEFINE_conv_map2str 423492Sab196087 433492Sab196087 443492Sab196087 452352Sab196087 #define POSSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 462352Sab196087 MSG_DFP_LAZYLOAD_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 472352Sab196087 MSG_DFP_GROUPPERM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 484734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 494734Sab196087 504734Sab196087 /* 514734Sab196087 * Ensure that Conv_dyn_posflag1_buf_t is large enough: 524734Sab196087 * 534734Sab196087 * POSSZ is the real minimum size of the buffer required by conv_dyn_posflag1(). 544734Sab196087 * However, Conv_dyn_posflag1_buf_t uses CONV_DYN_POSFLAG1_BUFSIZE to set the 554734Sab196087 * buffer size. We do things this way because the definition of POSSZ uses 564734Sab196087 * information that is not available in the environment of other programs 574734Sab196087 * that include the conv.h header file. 584734Sab196087 */ 594734Sab196087 #if CONV_DYN_POSFLAG1_BUFSIZE < POSSZ 604734Sab196087 #error "CONV_DYN_POSFLAG1_BUFSIZE is not large enough" 614734Sab196087 #endif 620Sstevel@tonic-gate 630Sstevel@tonic-gate const char * 64*5088Sab196087 conv_dyn_posflag1(Xword flags, Conv_fmt_flags_t fmt_flags, 654734Sab196087 Conv_dyn_posflag1_buf_t *dyn_posflag1_buf) 660Sstevel@tonic-gate { 671618Srie static Val_desc vda[] = { 681618Srie { DF_P1_LAZYLOAD, MSG_ORIG(MSG_DFP_LAZYLOAD) }, 691618Srie { DF_P1_GROUPPERM, MSG_ORIG(MSG_DFP_GROUPPERM) }, 701618Srie { 0, 0 } 711618Srie }; 724734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 734734Sab196087 NULL, sizeof (dyn_posflag1_buf->buf), vda }; 742352Sab196087 static Val_desc vda_alt[] = { 752352Sab196087 { DF_P1_LAZYLOAD, MSG_ORIG(MSG_DFP_LAZYLOAD_ALT) }, 762352Sab196087 { DF_P1_GROUPPERM, MSG_ORIG(MSG_DFP_GROUPPERM) }, 772352Sab196087 { 0, 0 } 782352Sab196087 }; 794734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg_alt = { 804734Sab196087 NULL, sizeof (dyn_posflag1_buf->buf), vda_alt, NULL, 0, 0, 814734Sab196087 MSG_ORIG(MSG_STR_EMPTY), NULL, MSG_ORIG(MSG_STR_EMPTY) }; 822352Sab196087 832352Sab196087 CONV_EXPN_FIELD_ARG *arg; 841618Srie 850Sstevel@tonic-gate if (flags == 0) 860Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 870Sstevel@tonic-gate 88*5088Sab196087 arg = (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) ? 89*5088Sab196087 &conv_arg_alt : &conv_arg; 904734Sab196087 arg->buf = dyn_posflag1_buf->buf; 912352Sab196087 arg->oflags = arg->rflags = flags; 92*5088Sab196087 (void) conv_expn_field(arg, fmt_flags); 930Sstevel@tonic-gate 944734Sab196087 return ((const char *)dyn_posflag1_buf); 950Sstevel@tonic-gate } 960Sstevel@tonic-gate 972352Sab196087 #define FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 982352Sab196087 MSG_DF_ORIGIN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 992352Sab196087 MSG_DF_SYMBOLIC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1002352Sab196087 MSG_DF_TEXTREL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1012352Sab196087 MSG_DF_BIND_NOW_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1022352Sab196087 MSG_DF_STATIC_TLS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1034734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 1044734Sab196087 1054734Sab196087 /* 1064734Sab196087 * Ensure that Conv_dyn_flag_buf_t is large enough: 1074734Sab196087 * 1084734Sab196087 * FLAGSZ is the real minimum size of the buffer required by conv_dyn_flag(). 1094734Sab196087 * However, Conv_dyn_flag_buf_t uses CONV_DYN_FLAG_BUFSIZE to set the 1104734Sab196087 * buffer size. We do things this way because the definition of FLAGSZ uses 1114734Sab196087 * information that is not available in the environment of other programs 1124734Sab196087 * that include the conv.h header file. 1134734Sab196087 */ 1144734Sab196087 #if CONV_DYN_FLAG_BUFSIZE < FLAGSZ 1154734Sab196087 #error "CONV_DYN_FLAG_BUFSIZE is not large enough" 1164734Sab196087 #endif 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate const char * 119*5088Sab196087 conv_dyn_flag(Xword flags, Conv_fmt_flags_t fmt_flags, 120*5088Sab196087 Conv_dyn_flag_buf_t *dyn_flag_buf) 1210Sstevel@tonic-gate { 1221618Srie static Val_desc vda[] = { 1231618Srie { DF_ORIGIN, MSG_ORIG(MSG_DF_ORIGIN) }, 1241618Srie { DF_SYMBOLIC, MSG_ORIG(MSG_DF_SYMBOLIC) }, 1251618Srie { DF_TEXTREL, MSG_ORIG(MSG_DF_TEXTREL) }, 1261618Srie { DF_BIND_NOW, MSG_ORIG(MSG_DF_BIND_NOW) }, 1271618Srie { DF_STATIC_TLS, MSG_ORIG(MSG_DF_STATIC_TLS) }, 1281618Srie { 0, 0 } 1291618Srie }; 1304734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 1314734Sab196087 NULL, sizeof (dyn_flag_buf->buf), vda }; 1321618Srie 1330Sstevel@tonic-gate if (flags == 0) 1340Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 1350Sstevel@tonic-gate 1364734Sab196087 conv_arg.buf = dyn_flag_buf->buf; 1372352Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 138*5088Sab196087 if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) { 1392352Sab196087 conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY); 1402352Sab196087 } else { 1412352Sab196087 conv_arg.prefix = conv_arg.suffix = NULL; 1422352Sab196087 } 143*5088Sab196087 (void) conv_expn_field(&conv_arg, fmt_flags); 1440Sstevel@tonic-gate 1454734Sab196087 return ((const char *)dyn_flag_buf->buf); 1460Sstevel@tonic-gate } 1470Sstevel@tonic-gate 1482352Sab196087 #define FLAG1SZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 1492352Sab196087 MSG_DF1_NOW_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1502352Sab196087 MSG_DF1_GLOBAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1512352Sab196087 MSG_DF1_GROUP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1522352Sab196087 MSG_DF1_NODELETE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1532352Sab196087 MSG_DF1_LOADFLTR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1542352Sab196087 MSG_DF1_INITFIRST_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1552352Sab196087 MSG_DF1_NOOPEN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1562352Sab196087 MSG_DF1_ORIGIN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1572352Sab196087 MSG_DF1_DIRECT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1582352Sab196087 MSG_DF1_TRANS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1592352Sab196087 MSG_DF1_INTERPOSE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1602352Sab196087 MSG_DF1_NODEFLIB_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1612352Sab196087 MSG_DF1_NODUMP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1622352Sab196087 MSG_DF1_CONFALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1632352Sab196087 MSG_DF1_ENDFILTEE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1642352Sab196087 MSG_DF1_DISPRELPND_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1652352Sab196087 MSG_DF1_DISPRELDNE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1662352Sab196087 MSG_DF1_NODIRECT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1672352Sab196087 MSG_DF1_IGNMULDEF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1682352Sab196087 MSG_DF1_NOKSYMS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1693466Srie MSG_DF1_NOHDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1702352Sab196087 MSG_DF1_NORELOC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1713466Srie MSG_DF1_SYMINTPOSE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1724679Srie MSG_DF1_GLOBAUDIT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 1734734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 1744734Sab196087 1754734Sab196087 /* 1764734Sab196087 * Ensure that Conv_dyn_flag1_buf_t is large enough: 1774734Sab196087 * 1784734Sab196087 * FLAG1SZ is the real minimum size of the buffer required by conv_dyn_flag1(). 1794734Sab196087 * However, Conv_dyn_flag1_buf_t uses CONV_DYN_FLAG1_BUFSIZE to set the 1804734Sab196087 * buffer size. We do things this way because the definition of FLAG1SZ uses 1814734Sab196087 * information that is not available in the environment of other programs 1824734Sab196087 * that include the conv.h header file. 1834734Sab196087 */ 1844734Sab196087 #if CONV_DYN_FLAG1_BUFSIZE < FLAG1SZ 1854734Sab196087 #error "CONV_DYN_FLAG1_BUFSIZE is not large enough" 1864734Sab196087 #endif 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate const char * 189*5088Sab196087 conv_dyn_flag1(Xword flags, Conv_fmt_flags_t fmt_flags, 190*5088Sab196087 Conv_dyn_flag1_buf_t *dyn_flag1_buf) 1910Sstevel@tonic-gate { 1921618Srie static Val_desc vda[] = { 1932352Sab196087 { DF_1_NOW, MSG_ORIG(MSG_DF1_NOW) }, 1941618Srie { DF_1_GLOBAL, MSG_ORIG(MSG_DF1_GLOBAL) }, 1951618Srie { DF_1_GROUP, MSG_ORIG(MSG_DF1_GROUP) }, 1961618Srie { DF_1_NODELETE, MSG_ORIG(MSG_DF1_NODELETE) }, 1971618Srie { DF_1_LOADFLTR, MSG_ORIG(MSG_DF1_LOADFLTR) }, 1981618Srie { DF_1_INITFIRST, MSG_ORIG(MSG_DF1_INITFIRST) }, 1991618Srie { DF_1_NOOPEN, MSG_ORIG(MSG_DF1_NOOPEN) }, 2001618Srie { DF_1_ORIGIN, MSG_ORIG(MSG_DF1_ORIGIN) }, 2011618Srie { DF_1_DIRECT, MSG_ORIG(MSG_DF1_DIRECT) }, 2021618Srie { DF_1_TRANS, MSG_ORIG(MSG_DF1_TRANS) }, 2031618Srie { DF_1_INTERPOSE, MSG_ORIG(MSG_DF1_INTERPOSE) }, 2041618Srie { DF_1_NODEFLIB, MSG_ORIG(MSG_DF1_NODEFLIB) }, 2051618Srie { DF_1_NODUMP, MSG_ORIG(MSG_DF1_NODUMP) }, 2061618Srie { DF_1_CONFALT, MSG_ORIG(MSG_DF1_CONFALT) }, 2071618Srie { DF_1_ENDFILTEE, MSG_ORIG(MSG_DF1_ENDFILTEE) }, 2083850Sab196087 { DF_1_DISPRELDNE, MSG_ORIG(MSG_DF1_DISPRELDNE) }, 2091618Srie { DF_1_DISPRELPND, MSG_ORIG(MSG_DF1_DISPRELPND) }, 2101618Srie { DF_1_NODIRECT, MSG_ORIG(MSG_DF1_NODIRECT) }, 2111618Srie { DF_1_IGNMULDEF, MSG_ORIG(MSG_DF1_IGNMULDEF) }, 2121618Srie { DF_1_NOKSYMS, MSG_ORIG(MSG_DF1_NOKSYMS) }, 2133466Srie { DF_1_NOHDR, MSG_ORIG(MSG_DF1_NOHDR) }, 2143850Sab196087 { DF_1_EDITED, MSG_ORIG(MSG_DF1_EDITED) }, 2151618Srie { DF_1_NORELOC, MSG_ORIG(MSG_DF1_NORELOC) }, 2163466Srie { DF_1_SYMINTPOSE, MSG_ORIG(MSG_DF1_SYMINTPOSE) }, 2174679Srie { DF_1_GLOBAUDIT, MSG_ORIG(MSG_DF1_GLOBAUDIT) }, 2181618Srie { 0, 0 } 2191618Srie }; 2204734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 2214734Sab196087 NULL, sizeof (dyn_flag1_buf->buf), vda }; 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate if (flags == 0) 2240Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 2250Sstevel@tonic-gate 2262352Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 2274734Sab196087 conv_arg.buf = dyn_flag1_buf->buf; 228*5088Sab196087 (void) conv_expn_field(&conv_arg, fmt_flags); 2290Sstevel@tonic-gate 2304734Sab196087 return ((const char *)dyn_flag1_buf->buf); 2310Sstevel@tonic-gate } 2320Sstevel@tonic-gate 2332352Sab196087 #define FEATSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 2342352Sab196087 MSG_DTF_PARINIT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 2352352Sab196087 MSG_DTF_CONFEXP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 2364734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 2374734Sab196087 2384734Sab196087 /* 2394734Sab196087 * Ensure that Conv_dyn_feature1_buf_t is large enough: 2404734Sab196087 * 2414734Sab196087 * FEATSZ is the real min size of the buffer required by conv_dyn_feature1(). 2424734Sab196087 * However, Conv_dyn_feature1_buf_t uses CONV_DYN_FEATURE1_BUFSIZE to set the 2434734Sab196087 * buffer size. We do things this way because the definition of FEATSZ uses 2444734Sab196087 * information that is not available in the environment of other programs 2454734Sab196087 * that include the conv.h header file. 2464734Sab196087 */ 2474734Sab196087 #if CONV_DYN_FEATURE1_BUFSIZE < FEATSZ 2484734Sab196087 #error "CONV_DYN_FEATURE1_BUFSIZE is not large enough" 2494734Sab196087 #endif 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate const char * 252*5088Sab196087 conv_dyn_feature1(Xword flags, Conv_fmt_flags_t fmt_flags, 2534734Sab196087 Conv_dyn_feature1_buf_t *dyn_feature1_buf) 2540Sstevel@tonic-gate { 2551618Srie static Val_desc vda[] = { 2561618Srie { DTF_1_PARINIT, MSG_ORIG(MSG_DTF_PARINIT) }, 2571618Srie { DTF_1_CONFEXP, MSG_ORIG(MSG_DTF_CONFEXP) }, 2581618Srie { 0, 0 } 2591618Srie }; 2604734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 2614734Sab196087 NULL, sizeof (dyn_feature1_buf->buf), vda }; 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate if (flags == 0) 2640Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 2650Sstevel@tonic-gate 2664734Sab196087 conv_arg.buf = dyn_feature1_buf->buf; 2672352Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 268*5088Sab196087 if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) { 2692352Sab196087 conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY); 2702352Sab196087 } else { 2712352Sab196087 conv_arg.prefix = conv_arg.suffix = NULL; 2722352Sab196087 } 273*5088Sab196087 (void) conv_expn_field(&conv_arg, fmt_flags); 2740Sstevel@tonic-gate 2754734Sab196087 return ((const char *)dyn_feature1_buf->buf); 2760Sstevel@tonic-gate } 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate const char * 279*5088Sab196087 conv_dyn_tag(Xword tag, Half mach, Conv_fmt_flags_t fmt_flags, 280*5088Sab196087 Conv_inv_buf_t *inv_buf) 2810Sstevel@tonic-gate { 2823492Sab196087 /* 2833492Sab196087 * Dynamic tag values are sparse, cover a wide range, and have 2843492Sab196087 * holes. To handle this efficiently, we fall through a series 2853492Sab196087 * of tests below, in increasing tag order, returning at the first 2863492Sab196087 * match. 2873492Sab196087 * 2883492Sab196087 * If we fall all the way to the end, the tag is unknown, 2893492Sab196087 * and its numeric value is printed. 2903492Sab196087 */ 2913492Sab196087 2923492Sab196087 /* 2933492Sab196087 * Most of the tag values are clustered in contiguous ranges. 2943492Sab196087 * Each contiguous range of defined values is handled with 2953492Sab196087 * an array that contains the message index corresponding to 2963492Sab196087 * each value in that range. The DYN_RANGE macro checks the 2973492Sab196087 * tag value against range of values starting at _start_tag. 2983492Sab196087 * If there is a match, the index of the appropriate name is 2993492Sab196087 * pulled from _array and returned to the caller. 3003492Sab196087 */ 3013492Sab196087 #define DYN_RANGE(_start_tag, _array) \ 3023492Sab196087 if ((tag >= _start_tag) && (tag < (_start_tag + ARRAY_NELTS(_array)))) \ 3033492Sab196087 return (MSG_ORIG(_array[tag - _start_tag])); 3043492Sab196087 3053492Sab196087 3063492Sab196087 /* 3073492Sab196087 * Generic dynamic tags: 3083492Sab196087 * - Note hole between DT_FLAGS and DT_PREINIT_ARRAY 3093492Sab196087 * - The first range has alternative names for dump, 3103492Sab196087 * requiring a second array. 3113492Sab196087 */ 3123492Sab196087 static const Msg tags_null[] = { 3131618Srie MSG_DYN_NULL, MSG_DYN_NEEDED, 3141618Srie MSG_DYN_PLTRELSZ, MSG_DYN_PLTGOT, 3151618Srie MSG_DYN_HASH, MSG_DYN_STRTAB, 3161618Srie MSG_DYN_SYMTAB, MSG_DYN_RELA, 3171618Srie MSG_DYN_RELASZ, MSG_DYN_RELAENT, 3181618Srie MSG_DYN_STRSZ, MSG_DYN_SYMENT, 3191618Srie MSG_DYN_INIT, MSG_DYN_FINI, 3201618Srie MSG_DYN_SONAME, MSG_DYN_RPATH, 3211618Srie MSG_DYN_SYMBOLIC, MSG_DYN_REL, 3221618Srie MSG_DYN_RELSZ, MSG_DYN_RELENT, 3231618Srie MSG_DYN_PLTREL, MSG_DYN_DEBUG, 3241618Srie MSG_DYN_TEXTREL, MSG_DYN_JMPREL, 3251618Srie MSG_DYN_BIND_NOW, MSG_DYN_INIT_ARRAY, 3261618Srie MSG_DYN_FINI_ARRAY, MSG_DYN_INIT_ARRAYSZ, 3271618Srie MSG_DYN_FINI_ARRAYSZ, MSG_DYN_RUNPATH, 3283492Sab196087 MSG_DYN_FLAGS 3291618Srie }; 3303492Sab196087 static const Msg tags_null_alt[] = { 3311976Sab196087 MSG_DYN_NULL, MSG_DYN_NEEDED, 3321976Sab196087 MSG_DYN_PLTRELSZ_ALT, MSG_DYN_PLTGOT, 3331976Sab196087 MSG_DYN_HASH, MSG_DYN_STRTAB, 3341976Sab196087 MSG_DYN_SYMTAB, MSG_DYN_RELA, 3351976Sab196087 MSG_DYN_RELASZ, MSG_DYN_RELAENT, 3361976Sab196087 MSG_DYN_STRSZ, MSG_DYN_SYMENT, 3371976Sab196087 MSG_DYN_INIT, MSG_DYN_FINI, 3381976Sab196087 MSG_DYN_SONAME, MSG_DYN_RPATH, 3391976Sab196087 MSG_DYN_SYMBOLIC_ALT, MSG_DYN_REL, 3401976Sab196087 MSG_DYN_RELSZ, MSG_DYN_RELENT, 3411976Sab196087 MSG_DYN_PLTREL, MSG_DYN_DEBUG, 3421976Sab196087 MSG_DYN_TEXTREL, MSG_DYN_JMPREL, 3431976Sab196087 MSG_DYN_BIND_NOW, MSG_DYN_INIT_ARRAY, 3441976Sab196087 MSG_DYN_FINI_ARRAY, MSG_DYN_INIT_ARRAYSZ, 3451976Sab196087 MSG_DYN_FINI_ARRAYSZ, MSG_DYN_RUNPATH, 3463492Sab196087 MSG_DYN_FLAGS 3473492Sab196087 }; 3483492Sab196087 static const Msg tags_preinit_array[] = { 3491976Sab196087 MSG_DYN_PREINIT_ARRAY, MSG_DYN_PREINIT_ARRAYSZ 3501976Sab196087 }; 3510Sstevel@tonic-gate 3523492Sab196087 /* 3533850Sab196087 * SUNW: DT_LOOS -> DT_HIOS range. Note hole between DT_SUNW_TLSSORTSZ 3543850Sab196087 * and DT_SUNW_STRPAD. We handle DT_SUNW_STRPAD as a single value below. 3553492Sab196087 */ 3563492Sab196087 static const Msg tags_sunw_auxiliary[] = { 3573492Sab196087 MSG_DYN_SUNW_AUXILIARY, MSG_DYN_SUNW_RTLDINF, 3583492Sab196087 MSG_DYN_SUNW_FILTER, MSG_DYN_SUNW_CAP, 3593492Sab196087 MSG_DYN_SUNW_SYMTAB, MSG_DYN_SUNW_SYMSZ, 3603731Srie MSG_DYN_SUNW_SORTENT, MSG_DYN_SUNW_SYMSORT, 3613731Srie MSG_DYN_SUNW_SYMSORTSZ, MSG_DYN_SUNW_TLSSORT, 3623731Srie MSG_DYN_SUNW_TLSSORTSZ 3633492Sab196087 }; 3640Sstevel@tonic-gate 3653492Sab196087 /* 3663492Sab196087 * SUNW: DT_VALRNGLO - DT_VALRNGHI range. 3673492Sab196087 */ 3683492Sab196087 static const Msg tags_checksum[] = { 3693492Sab196087 MSG_DYN_CHECKSUM, MSG_DYN_PLTPADSZ, 3703492Sab196087 MSG_DYN_MOVEENT, MSG_DYN_MOVESZ, 3713492Sab196087 MSG_DYN_FEATURE_1, MSG_DYN_POSFLAG_1, 3723492Sab196087 MSG_DYN_SYMINSZ, MSG_DYN_SYMINENT 3733492Sab196087 }; 3743492Sab196087 3753492Sab196087 /* 3763492Sab196087 * SUNW: DT_ADDRRNGLO - DT_ADDRRNGHI range. 3773492Sab196087 */ 3783492Sab196087 static const Msg tags_config[] = { 3793492Sab196087 MSG_DYN_CONFIG, MSG_DYN_DEPAUDIT, 3803492Sab196087 MSG_DYN_AUDIT, MSG_DYN_PLTPAD, 3813492Sab196087 MSG_DYN_MOVETAB, MSG_DYN_SYMINFO 3823492Sab196087 }; 3830Sstevel@tonic-gate 3843492Sab196087 /* 3853492Sab196087 * SUNW: generic range. Note hole between DT_VERSYM and DT_RELACOUNT. 3863492Sab196087 * We handle DT_VERSYM as a single value below. 3873492Sab196087 */ 3883492Sab196087 static const Msg tags_relacount[] = { 3893492Sab196087 MSG_DYN_RELACOUNT, MSG_DYN_RELCOUNT, 3903492Sab196087 MSG_DYN_FLAGS_1, MSG_DYN_VERDEF, 3913492Sab196087 MSG_DYN_VERDEFNUM, MSG_DYN_VERNEED, 3923492Sab196087 MSG_DYN_VERNEEDNUM 3933492Sab196087 }; 3943492Sab196087 3953492Sab196087 /* 3963492Sab196087 * DT_LOPROC - DT_HIPROC range. 3973492Sab196087 */ 3983492Sab196087 static const Msg tags_auxiliary[] = { 3993492Sab196087 MSG_DYN_AUXILIARY, MSG_DYN_USED, 4003492Sab196087 MSG_DYN_FILTER 4013492Sab196087 }; 4023492Sab196087 4033492Sab196087 4043492Sab196087 4050Sstevel@tonic-gate 406*5088Sab196087 if (tag <= DT_FLAGS) { 407*5088Sab196087 /* use 'dump' style? */ 408*5088Sab196087 if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) 409*5088Sab196087 return (conv_map2str(inv_buf, tag, fmt_flags, 410*5088Sab196087 ARRAY_NELTS(tags_null_alt), tags_null_alt)); 411*5088Sab196087 /* Standard style */ 4124734Sab196087 return (conv_map2str(inv_buf, tag, fmt_flags, 413*5088Sab196087 ARRAY_NELTS(tags_null), tags_null)); 414*5088Sab196087 } 4153492Sab196087 DYN_RANGE(DT_PREINIT_ARRAY, tags_preinit_array); 4163492Sab196087 DYN_RANGE(DT_SUNW_AUXILIARY, tags_sunw_auxiliary); 4173850Sab196087 if (tag == DT_SUNW_STRPAD) 4183850Sab196087 return (MSG_ORIG(MSG_DYN_SUNW_STRPAD)); 4193492Sab196087 DYN_RANGE(DT_CHECKSUM, tags_checksum); 4203492Sab196087 DYN_RANGE(DT_CONFIG, tags_config); 4213492Sab196087 if (tag == DT_VERSYM) 4223492Sab196087 return (MSG_ORIG(MSG_DYN_VERSYM)); 4233492Sab196087 DYN_RANGE(DT_RELACOUNT, tags_relacount); 4243492Sab196087 DYN_RANGE(DT_AUXILIARY, tags_auxiliary); 4250Sstevel@tonic-gate 4263492Sab196087 /* 4273492Sab196087 * SUNW: machine specific range. 4283492Sab196087 */ 4293492Sab196087 if (((mach == EM_SPARC) || (mach == EM_SPARCV9) || 4303492Sab196087 (mach == EM_SPARC32PLUS)) && (tag == DT_SPARC_REGISTER)) 4313492Sab196087 /* this is so x86 can display a sparc binary */ 4323492Sab196087 return (MSG_ORIG(MSG_DYN_REGISTER)); 4333492Sab196087 4343492Sab196087 if (tag == DT_DEPRECATED_SPARC_REGISTER) 4353492Sab196087 return (MSG_ORIG(MSG_DYN_REGISTER)); 4363492Sab196087 4373492Sab196087 /* Unknown item */ 4384734Sab196087 return (conv_invalid_val(inv_buf, tag, fmt_flags)); 4393492Sab196087 4403492Sab196087 #undef DYN_RANGE 4410Sstevel@tonic-gate } 442280Srie 4432352Sab196087 #define BINDTSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 4442352Sab196087 MSG_BND_NEEDED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 4452352Sab196087 MSG_BND_REFER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 4462352Sab196087 MSG_BND_FILTER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 4474734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 4484734Sab196087 4494734Sab196087 /* 4504734Sab196087 * Ensure that Conv_bnd_type_buf_t is large enough: 4514734Sab196087 * 4524734Sab196087 * BINDTSZ is the real minimum size of the buffer required by conv_bnd_type(). 4534734Sab196087 * However, Conv_bnd_type_buf_t uses CONV_BND_TYPE_BUFSIZE to set the 4544734Sab196087 * buffer size. We do things this way because the definition of BINDTSZ uses 4554734Sab196087 * information that is not available in the environment of other programs 4564734Sab196087 * that include the conv.h header file. 4574734Sab196087 */ 4584734Sab196087 #if CONV_BND_TYPE_BUFSIZE < BINDTSZ 4594734Sab196087 #error "CONV_BND_TYPE_BUFSIZE is not large enough" 4604734Sab196087 #endif 461280Srie 462280Srie const char * 4634734Sab196087 conv_bnd_type(uint_t flags, Conv_bnd_type_buf_t *bnd_type_buf) 464280Srie { 4651618Srie static Val_desc vda[] = { 4661618Srie { BND_NEEDED, MSG_ORIG(MSG_BND_NEEDED) }, 4671618Srie { BND_REFER, MSG_ORIG(MSG_BND_REFER) }, 4681618Srie { BND_FILTER, MSG_ORIG(MSG_BND_FILTER) }, 4691618Srie { 0, 0 } 4701618Srie }; 4714734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 4724734Sab196087 NULL, sizeof (bnd_type_buf->buf), vda }; 473280Srie 4741618Srie if (flags == 0) 4751618Srie return (MSG_ORIG(MSG_STR_EMPTY)); 476280Srie 4774734Sab196087 conv_arg.buf = bnd_type_buf->buf; 4782352Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 479*5088Sab196087 (void) conv_expn_field(&conv_arg, 0); 4801618Srie 4814734Sab196087 return ((const char *)bnd_type_buf->buf); 482280Srie } 483280Srie 4841824Srie /* 4851824Srie * Note, conv_bnd_obj() is called with either: 4861824Srie * LML_FLG_OBJADDED (possibly with LML_FLG_OBJREEVAL added), or 4871824Srie * LML_FLG_OBJDELETED, or 4881824Srie * LML_FLG_ATEXIT. 4891824Srie */ 4902352Sab196087 #define BINDOSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 4912352Sab196087 MSG_BND_ADDED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 4922352Sab196087 MSG_BND_REEVAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 4934734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 4944734Sab196087 4954734Sab196087 /* 4964734Sab196087 * Ensure that Conv_bnd_obj_buf_t is large enough: 4974734Sab196087 * 4984734Sab196087 * BINDOSZ is the real minimum size of the buffer required by conv_bnd_obj(). 4994734Sab196087 * However, Conv_bnd_obj_buf_t uses CONV_BND_OBJ_BUFSIZE to set the 5004734Sab196087 * buffer size. We do things this way because the definition of BINDOSZ uses 5014734Sab196087 * information that is not available in the environment of other programs 5024734Sab196087 * that include the conv.h header file. 5034734Sab196087 */ 5044734Sab196087 #if CONV_BND_OBJ_BUFSIZE < BINDOSZ 5054734Sab196087 #error "CONV_BND_OBJ_BUFSIZE is not large enough" 5064734Sab196087 #endif 507280Srie 508280Srie const char * 5094734Sab196087 conv_bnd_obj(uint_t flags, Conv_bnd_obj_buf_t *bnd_obj_buf) 510280Srie { 5111618Srie static Val_desc vda[] = { 5121618Srie { LML_FLG_OBJADDED, MSG_ORIG(MSG_BND_ADDED) }, 5131618Srie { LML_FLG_OBJREEVAL, MSG_ORIG(MSG_BND_REEVAL) }, 5141618Srie { LML_FLG_OBJDELETED, MSG_ORIG(MSG_BND_DELETED) }, 5151618Srie { LML_FLG_ATEXIT, MSG_ORIG(MSG_BND_ATEXIT) }, 5161618Srie { 0, 0 } 5171618Srie }; 5184734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 5194734Sab196087 NULL, sizeof (bnd_obj_buf->buf), vda }; 5201618Srie 5211824Srie if ((flags & (LML_FLG_OBJADDED | LML_FLG_OBJREEVAL | 5221824Srie LML_FLG_OBJDELETED | LML_FLG_ATEXIT)) == 0) 5231824Srie return (MSG_ORIG(MSG_BND_REVISIT)); 524280Srie 525280Srie /* 5261618Srie * Note, we're not worried about unknown flags for this family, only 5272352Sab196087 * the selected flags are of interest, so we leave conv_arg.rflags 5282352Sab196087 * set to 0. 529280Srie */ 5304734Sab196087 conv_arg.buf = bnd_obj_buf->buf; 5312352Sab196087 conv_arg.oflags = flags; 532*5088Sab196087 (void) conv_expn_field(&conv_arg, 0); 533280Srie 5344734Sab196087 return ((const char *)bnd_obj_buf->buf); 535280Srie } 536