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 /* 234734Sab196087 * 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 segment flags. 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate #include <string.h> 321618Srie #include <libld.h> 331618Srie #include "_conv.h" 340Sstevel@tonic-gate #include "segments_msg.h" 350Sstevel@tonic-gate 362352Sab196087 #define SEGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 372352Sab196087 MSG_FLG_SG_VADDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 382352Sab196087 MSG_FLG_SG_PADDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 392352Sab196087 MSG_FLG_SG_LENGTH_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 402352Sab196087 MSG_FLG_SG_ALIGN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 412352Sab196087 MSG_FLG_SG_ROUND_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 422352Sab196087 MSG_FLG_SG_FLAGS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 432352Sab196087 MSG_FLG_SG_TYPE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 442352Sab196087 MSG_FLG_SG_ORDER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 452352Sab196087 MSG_FLG_SG_NOHDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 462352Sab196087 MSG_FLG_SG_EMPTY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 472352Sab196087 MSG_FLG_SG_KEY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 482352Sab196087 MSG_FLG_SG_DISABLED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 492352Sab196087 MSG_FLG_SG_PHREQ_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 504734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 514734Sab196087 524734Sab196087 /* 534734Sab196087 * Ensure that Conv_seg_flags_buf_t is large enough: 544734Sab196087 * 554734Sab196087 * SEGSZ is the real minimum size of the buffer required by conv_seg_flags(). 564734Sab196087 * However, Conv_seg_flags_buf_t uses CONV_SEG_FLAGS_BUFSIZE to set the 574734Sab196087 * buffer size. We do things this way because the definition of SEGSZ uses 584734Sab196087 * information that is not available in the environment of other programs 594734Sab196087 * that include the conv.h header file. 604734Sab196087 */ 61*5152Sab196087 #if (CONV_SEG_FLAGS_BUFSIZE != SEGSZ) && !defined(__lint) 62*5152Sab196087 #define REPORT_BUFSIZE SEGSZ 63*5152Sab196087 #include "report_bufsize.h" 64*5152Sab196087 #error "CONV_SEG_FLAGS_BUFSIZE does not match SEGSZ" 654734Sab196087 #endif 660Sstevel@tonic-gate 670Sstevel@tonic-gate const char * 684734Sab196087 conv_seg_flags(Half flags, Conv_seg_flags_buf_t *seg_flags_buf) 690Sstevel@tonic-gate { 701618Srie static Val_desc vda[] = { 711618Srie { FLG_SG_VADDR, MSG_ORIG(MSG_FLG_SG_VADDR) }, 721618Srie { FLG_SG_PADDR, MSG_ORIG(MSG_FLG_SG_PADDR) }, 731618Srie { FLG_SG_LENGTH, MSG_ORIG(MSG_FLG_SG_LENGTH) }, 741618Srie { FLG_SG_ALIGN, MSG_ORIG(MSG_FLG_SG_ALIGN) }, 751618Srie { FLG_SG_ROUND, MSG_ORIG(MSG_FLG_SG_ROUND) }, 761618Srie { FLG_SG_FLAGS, MSG_ORIG(MSG_FLG_SG_FLAGS) }, 771618Srie { FLG_SG_TYPE, MSG_ORIG(MSG_FLG_SG_TYPE) }, 781618Srie { FLG_SG_ORDER, MSG_ORIG(MSG_FLG_SG_ORDER) }, 791618Srie { FLG_SG_NOHDR, MSG_ORIG(MSG_FLG_SG_NOHDR) }, 801618Srie { FLG_SG_EMPTY, MSG_ORIG(MSG_FLG_SG_EMPTY) }, 811618Srie { FLG_SG_KEY, MSG_ORIG(MSG_FLG_SG_KEY) }, 821618Srie { FLG_SG_DISABLED, MSG_ORIG(MSG_FLG_SG_DISABLED) }, 831618Srie { FLG_SG_PHREQ, MSG_ORIG(MSG_FLG_SG_PHREQ) }, 841618Srie { 0, 0 } 851618Srie }; 864734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 874734Sab196087 NULL, sizeof (seg_flags_buf->buf), vda }; 880Sstevel@tonic-gate 890Sstevel@tonic-gate if (flags == 0) 900Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 910Sstevel@tonic-gate 924734Sab196087 conv_arg.buf = seg_flags_buf->buf; 932352Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 945088Sab196087 (void) conv_expn_field(&conv_arg, 0); 951618Srie 964734Sab196087 return ((const char *)seg_flags_buf->buf); 970Sstevel@tonic-gate } 98