1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate #include <string.h> 29*0Sstevel@tonic-gate #include "_conv.h" 30*0Sstevel@tonic-gate #include "dl_msg.h" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #define MODESZ MSG_GBL_OSQBRKT_SIZE + \ 33*0Sstevel@tonic-gate MSG_RTLD_LAZY_SIZE + \ 34*0Sstevel@tonic-gate MSG_RTLD_NOLOAD_SIZE + \ 35*0Sstevel@tonic-gate MSG_RTLD_GLOBAL_SIZE + \ 36*0Sstevel@tonic-gate MSG_RTLD_PARENT_SIZE + \ 37*0Sstevel@tonic-gate MSG_RTLD_GROUP_SIZE + \ 38*0Sstevel@tonic-gate MSG_RTLD_WORLD_SIZE + \ 39*0Sstevel@tonic-gate MSG_RTLD_NODELETE_SIZE + \ 40*0Sstevel@tonic-gate MSG_RTLD_FIRST_SIZE + \ 41*0Sstevel@tonic-gate MSG_RTLD_CONFGEN_SIZE + \ 42*0Sstevel@tonic-gate MSG_GBL_CSQBRKT_SIZE 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate /* 45*0Sstevel@tonic-gate * String conversion routine for dlopen() attributes. 46*0Sstevel@tonic-gate */ 47*0Sstevel@tonic-gate const char * 48*0Sstevel@tonic-gate conv_dlmode_str(int mode, int fabricate) 49*0Sstevel@tonic-gate { 50*0Sstevel@tonic-gate static char string[MODESZ] = { '\0' }; 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate (void) strcpy(string, MSG_ORIG(MSG_GBL_OSQBRKT)); 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate if (mode & RTLD_NOW) 55*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_NOW)); 56*0Sstevel@tonic-gate else if (fabricate) 57*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_LAZY)); 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate if (mode & RTLD_NOLOAD) 60*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_NOLOAD)); 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate if (mode & RTLD_GLOBAL) 63*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_GLOBAL)); 64*0Sstevel@tonic-gate else if (fabricate) 65*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_LOCAL)); 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate if (mode & RTLD_PARENT) 68*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_PARENT)); 69*0Sstevel@tonic-gate if (mode & RTLD_GROUP) 70*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_GROUP)); 71*0Sstevel@tonic-gate if (mode & RTLD_WORLD) 72*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_WORLD)); 73*0Sstevel@tonic-gate if (mode & RTLD_NODELETE) 74*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_NODELETE)); 75*0Sstevel@tonic-gate if (mode & RTLD_FIRST) 76*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_FIRST)); 77*0Sstevel@tonic-gate if (mode & RTLD_CONFGEN) 78*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_CONFGEN)); 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_CSQBRKT)); 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate return ((const char *)string); 83*0Sstevel@tonic-gate } 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate #define FLAGSZ MSG_GBL_OSQBRKT_SIZE + \ 86*0Sstevel@tonic-gate MSG_RTLD_REL_RELATIVE_SIZE + \ 87*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 88*0Sstevel@tonic-gate MSG_RTLD_REL_EXEC_SIZE + \ 89*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 90*0Sstevel@tonic-gate MSG_RTLD_REL_DEPENDS_SIZE + \ 91*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 92*0Sstevel@tonic-gate MSG_RTLD_REL_PRELOAD_SIZE + \ 93*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 94*0Sstevel@tonic-gate MSG_RTLD_REL_SELF_SIZE + \ 95*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 96*0Sstevel@tonic-gate MSG_RTLD_REL_WEAK_SIZE + \ 97*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 98*0Sstevel@tonic-gate MSG_RTLD_MEMORY_SIZE + \ 99*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 100*0Sstevel@tonic-gate MSG_RTLD_STRIP_SIZE + \ 101*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 102*0Sstevel@tonic-gate MSG_RTLD_NOHEAP_SIZE + \ 103*0Sstevel@tonic-gate MSG_GBL_SEP_SIZE + \ 104*0Sstevel@tonic-gate MSG_RTLD_CONFSET_SIZE + \ 105*0Sstevel@tonic-gate MSG_GBL_CSQBRKT_SIZE 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate /* 108*0Sstevel@tonic-gate * String conversion routine for dldump() flags. 109*0Sstevel@tonic-gate * crle(1) uses this routine to generate update information, and in this case 110*0Sstevel@tonic-gate * we build a "|" separated string. 111*0Sstevel@tonic-gate */ 112*0Sstevel@tonic-gate const char * 113*0Sstevel@tonic-gate conv_dlflag_str(int flags, int separator) 114*0Sstevel@tonic-gate { 115*0Sstevel@tonic-gate static char string[FLAGSZ] = { '\0' }; 116*0Sstevel@tonic-gate int element = 0; 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate if (flags == 0) 119*0Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate if (separator) 122*0Sstevel@tonic-gate (void) strcpy(string, MSG_ORIG(MSG_GBL_QUOTE)); 123*0Sstevel@tonic-gate else 124*0Sstevel@tonic-gate (void) strcpy(string, MSG_ORIG(MSG_GBL_OSQBRKT)); 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate if ((flags & RTLD_REL_ALL) == RTLD_REL_ALL) { 127*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_REL_ALL)); 128*0Sstevel@tonic-gate element++; 129*0Sstevel@tonic-gate } else { 130*0Sstevel@tonic-gate if (flags & RTLD_REL_RELATIVE) { 131*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_REL_RELATIVE)); 132*0Sstevel@tonic-gate element++; 133*0Sstevel@tonic-gate } 134*0Sstevel@tonic-gate if (flags & RTLD_REL_EXEC) { 135*0Sstevel@tonic-gate if (separator && element++) 136*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 137*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_REL_EXEC)); 138*0Sstevel@tonic-gate } 139*0Sstevel@tonic-gate if (flags & RTLD_REL_DEPENDS) { 140*0Sstevel@tonic-gate if (separator && element++) 141*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 142*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_REL_DEPENDS)); 143*0Sstevel@tonic-gate } 144*0Sstevel@tonic-gate if (flags & RTLD_REL_PRELOAD) { 145*0Sstevel@tonic-gate if (separator && element++) 146*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 147*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_REL_PRELOAD)); 148*0Sstevel@tonic-gate } 149*0Sstevel@tonic-gate if (flags & RTLD_REL_SELF) { 150*0Sstevel@tonic-gate if (separator && element++) 151*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 152*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_REL_SELF)); 153*0Sstevel@tonic-gate } 154*0Sstevel@tonic-gate if (flags & RTLD_REL_WEAK) { 155*0Sstevel@tonic-gate if (separator && element++) 156*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 157*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_REL_WEAK)); 158*0Sstevel@tonic-gate } 159*0Sstevel@tonic-gate } 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate if (flags & RTLD_MEMORY) { 162*0Sstevel@tonic-gate if (separator && element++) 163*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 164*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_MEMORY)); 165*0Sstevel@tonic-gate } 166*0Sstevel@tonic-gate if (flags & RTLD_STRIP) { 167*0Sstevel@tonic-gate if (separator && element++) 168*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 169*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_STRIP)); 170*0Sstevel@tonic-gate } 171*0Sstevel@tonic-gate if (flags & RTLD_NOHEAP) { 172*0Sstevel@tonic-gate if (separator && element++) 173*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 174*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_NOHEAP)); 175*0Sstevel@tonic-gate } 176*0Sstevel@tonic-gate if (flags & RTLD_CONFSET) { 177*0Sstevel@tonic-gate if (separator && element++) 178*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_SEP)); 179*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_RTLD_CONFSET)); 180*0Sstevel@tonic-gate } 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate if (separator) 183*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_QUOTE)); 184*0Sstevel@tonic-gate else 185*0Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_GBL_CSQBRKT)); 186*0Sstevel@tonic-gate 187*0Sstevel@tonic-gate return ((const char *)string); 188*0Sstevel@tonic-gate } 189