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.
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.
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]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * String conversion routine for version flag entries.
32 #include "version_msg.h"
34 #define VERFLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
35 MSG_VER_FLG_WEAK_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
36 MSG_VER_FLG_BASE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
37 MSG_VER_FLG_INFO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
38 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
41 * Ensure that Conv_ver_flags_buf_t is large enough:
43 * VERFLAGSZ is the real minimum size of the buffer required by
44 * conv_ver_flags(). However, Conv_ver_flags_buf_t uses CONV_VER_FLAGS_BUFSIZE
45 * to set the buffer size. We do things this way because the definition of
46 * VERFLAGSZ uses information that is not available in the environment of
47 * other programs that include the conv.h header file.
49 #if (CONV_VER_FLAGS_BUFSIZE != VERFLAGSZ) && !defined(__lint)
50 #define REPORT_BUFSIZE VERFLAGSZ
51 #include "report_bufsize.h"
52 #error "CONV_VER_FLAGS_BUFSIZE does not match VERFLAGSZ"
56 conv_ver_flags(Half flags
, Conv_fmt_flags_t fmt_flags
,
57 Conv_ver_flags_buf_t
*ver_flags_buf
)
59 static const Val_desc vda
[] = {
60 { VER_FLG_WEAK
, MSG_VER_FLG_WEAK
},
61 { VER_FLG_BASE
, MSG_VER_FLG_BASE
},
62 { VER_FLG_INFO
, MSG_VER_FLG_INFO
},
65 static CONV_EXPN_FIELD_ARG conv_arg
= {
66 NULL
, sizeof (ver_flags_buf
->buf
) };
69 return (MSG_ORIG(MSG_GBL_NULL
));
71 conv_arg
.buf
= ver_flags_buf
->buf
;
72 conv_arg
.oflags
= conv_arg
.rflags
= flags
;
73 (void) conv_expn_field(&conv_arg
, vda
, fmt_flags
);
75 return ((const char *)ver_flags_buf
->buf
);
80 * Format a version index as contained in a VERSYM section
83 * verndx - Version index to format
84 * gnuver - If True (non-zero), the version rules used by the
85 * GNU ld are assumed. If False (0), Solaris ld rules apply.
88 conv_ver_index(Versym verndx
, int gnuver
, Conv_inv_buf_t
*inv_buf
)
92 /* Special case versions starting at VER_NDX_LORESERVE */
93 if (verndx
== VER_NDX_ELIMINATE
)
94 return (MSG_ORIG(MSG_VERSYM_ELIMINATE
));
97 * The GNU style of versioning uses the top bit of the
98 * 16-bit version index (0x8000) as a "hidden bit". A
99 * hidden symbol is supposed to be ignored by the linker.
101 if (gnuver
&& (verndx
& 0x8000)) {
103 fmt
= MSG_ORIG(MSG_VERSYM_GNUH_FMT
);
105 fmt
= MSG_ORIG(MSG_VERSYM_FMT
);
108 /* format as numeric */
109 (void) snprintf(inv_buf
->buf
, sizeof (inv_buf
->buf
),
110 fmt
, EC_HALF(verndx
));
111 return (inv_buf
->buf
);