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 /* 23*9273SAli.Bahrami@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* 280Sstevel@tonic-gate * String conversion routine for segment flags. 290Sstevel@tonic-gate */ 300Sstevel@tonic-gate #include <string.h> 311618Srie #include <libld.h> 321618Srie #include "_conv.h" 330Sstevel@tonic-gate #include "segments_msg.h" 340Sstevel@tonic-gate 352352Sab196087 #define SEGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \ 362352Sab196087 MSG_FLG_SG_VADDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 372352Sab196087 MSG_FLG_SG_PADDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 382352Sab196087 MSG_FLG_SG_LENGTH_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 392352Sab196087 MSG_FLG_SG_ALIGN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 402352Sab196087 MSG_FLG_SG_ROUND_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 412352Sab196087 MSG_FLG_SG_FLAGS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 422352Sab196087 MSG_FLG_SG_TYPE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 432352Sab196087 MSG_FLG_SG_ORDER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 442352Sab196087 MSG_FLG_SG_NOHDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 452352Sab196087 MSG_FLG_SG_EMPTY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 462352Sab196087 MSG_FLG_SG_KEY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 472352Sab196087 MSG_FLG_SG_DISABLED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 482352Sab196087 MSG_FLG_SG_PHREQ_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \ 494734Sab196087 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 504734Sab196087 514734Sab196087 /* 524734Sab196087 * Ensure that Conv_seg_flags_buf_t is large enough: 534734Sab196087 * 544734Sab196087 * SEGSZ is the real minimum size of the buffer required by conv_seg_flags(). 554734Sab196087 * However, Conv_seg_flags_buf_t uses CONV_SEG_FLAGS_BUFSIZE to set the 564734Sab196087 * buffer size. We do things this way because the definition of SEGSZ uses 574734Sab196087 * information that is not available in the environment of other programs 584734Sab196087 * that include the conv.h header file. 594734Sab196087 */ 605152Sab196087 #if (CONV_SEG_FLAGS_BUFSIZE != SEGSZ) && !defined(__lint) 615152Sab196087 #define REPORT_BUFSIZE SEGSZ 625152Sab196087 #include "report_bufsize.h" 635152Sab196087 #error "CONV_SEG_FLAGS_BUFSIZE does not match SEGSZ" 644734Sab196087 #endif 650Sstevel@tonic-gate 660Sstevel@tonic-gate const char * 674734Sab196087 conv_seg_flags(Half flags, Conv_seg_flags_buf_t *seg_flags_buf) 680Sstevel@tonic-gate { 691618Srie static Val_desc vda[] = { 70*9273SAli.Bahrami@Sun.COM { FLG_SG_VADDR, MSG_FLG_SG_VADDR }, 71*9273SAli.Bahrami@Sun.COM { FLG_SG_PADDR, MSG_FLG_SG_PADDR }, 72*9273SAli.Bahrami@Sun.COM { FLG_SG_LENGTH, MSG_FLG_SG_LENGTH }, 73*9273SAli.Bahrami@Sun.COM { FLG_SG_ALIGN, MSG_FLG_SG_ALIGN }, 74*9273SAli.Bahrami@Sun.COM { FLG_SG_ROUND, MSG_FLG_SG_ROUND }, 75*9273SAli.Bahrami@Sun.COM { FLG_SG_FLAGS, MSG_FLG_SG_FLAGS }, 76*9273SAli.Bahrami@Sun.COM { FLG_SG_TYPE, MSG_FLG_SG_TYPE }, 77*9273SAli.Bahrami@Sun.COM { FLG_SG_ORDER, MSG_FLG_SG_ORDER }, 78*9273SAli.Bahrami@Sun.COM { FLG_SG_NOHDR, MSG_FLG_SG_NOHDR }, 79*9273SAli.Bahrami@Sun.COM { FLG_SG_EMPTY, MSG_FLG_SG_EMPTY }, 80*9273SAli.Bahrami@Sun.COM { FLG_SG_KEY, MSG_FLG_SG_KEY }, 81*9273SAli.Bahrami@Sun.COM { FLG_SG_DISABLED, MSG_FLG_SG_DISABLED }, 82*9273SAli.Bahrami@Sun.COM { FLG_SG_PHREQ, MSG_FLG_SG_PHREQ }, 831618Srie { 0, 0 } 841618Srie }; 854734Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { 86*9273SAli.Bahrami@Sun.COM NULL, sizeof (seg_flags_buf->buf) }; 870Sstevel@tonic-gate 880Sstevel@tonic-gate if (flags == 0) 890Sstevel@tonic-gate return (MSG_ORIG(MSG_GBL_ZERO)); 900Sstevel@tonic-gate 914734Sab196087 conv_arg.buf = seg_flags_buf->buf; 922352Sab196087 conv_arg.oflags = conv_arg.rflags = flags; 93*9273SAli.Bahrami@Sun.COM (void) conv_expn_field(&conv_arg, vda, 0); 941618Srie 954734Sab196087 return ((const char *)seg_flags_buf->buf); 960Sstevel@tonic-gate } 97