1 /*
2 * CDDL HEADER START
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * String conversion routine for .dynamic tag entries.
29 */
30 #include <stdio.h>
31 #include <string.h>
32 #include <sys/elf_SPARC.h>
33 #include "rtld.h"
34 #include "_conv.h"
35 #include "dynamic_msg.h"
36
37
38
39 const char *
conv_dyn_posflag1(Xword flags,Conv_fmt_flags_t fmt_flags,Conv_dyn_posflag1_buf_t * dyn_posflag1_buf)40 conv_dyn_posflag1(Xword flags, Conv_fmt_flags_t fmt_flags,
41 Conv_dyn_posflag1_buf_t *dyn_posflag1_buf)
42 {
43 static CONV_EXPN_FIELD_ARG conv_arg = {
44 NULL, sizeof (dyn_posflag1_buf->buf) };
45 static CONV_EXPN_FIELD_ARG conv_arg_alt = {
46 NULL, sizeof (dyn_posflag1_buf->buf), NULL, 0, 0,
47 MSG_ORIG(MSG_STR_EMPTY), NULL, MSG_ORIG(MSG_STR_EMPTY) };
48
49 CONV_EXPN_FIELD_ARG *arg;
50
51 if (flags == 0)
52 return (MSG_ORIG(MSG_GBL_ZERO));
53 CONV_XWORD_64TEST(flags, fmt_flags, &dyn_posflag1_buf->inv_buf);
54
55 arg = (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) ?
56 &conv_arg_alt : &conv_arg;
57 arg->buf = dyn_posflag1_buf->buf;
58 arg->oflags = arg->rflags = flags;
59 (void) conv_expn_field(arg, conv_dyn_posflag1_strings(fmt_flags),
60 fmt_flags);
61
62 return ((const char *)dyn_posflag1_buf);
63 }
64
65 const char *
conv_dyn_flag(Xword flags,Conv_fmt_flags_t fmt_flags,Conv_dyn_flag_buf_t * dyn_flag_buf)66 conv_dyn_flag(Xword flags, Conv_fmt_flags_t fmt_flags,
67 Conv_dyn_flag_buf_t *dyn_flag_buf)
68 {
69 static CONV_EXPN_FIELD_ARG conv_arg = {
70 NULL, sizeof (dyn_flag_buf->buf) };
71
72 if (flags == 0)
73 return (MSG_ORIG(MSG_GBL_ZERO));
74 CONV_XWORD_64TEST(flags, fmt_flags, &dyn_flag_buf->inv_buf);
75
76 conv_arg.buf = dyn_flag_buf->buf;
77 conv_arg.oflags = conv_arg.rflags = flags;
78 if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) {
79 conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY);
80 } else {
81 conv_arg.prefix = conv_arg.suffix = NULL;
82 }
83 (void) conv_expn_field(&conv_arg, conv_dyn_flag_strings(fmt_flags),
84 fmt_flags);
85
86 return ((const char *)dyn_flag_buf->buf);
87 }
88
89 const char *
conv_dyn_flag1(Xword flags,Conv_fmt_flags_t fmt_flags,Conv_dyn_flag1_buf_t * dyn_flag1_buf)90 conv_dyn_flag1(Xword flags, Conv_fmt_flags_t fmt_flags,
91 Conv_dyn_flag1_buf_t *dyn_flag1_buf)
92 {
93 static CONV_EXPN_FIELD_ARG conv_arg = {
94 NULL, sizeof (dyn_flag1_buf->buf) };
95
96 if (flags == 0)
97 return (MSG_ORIG(MSG_GBL_ZERO));
98 CONV_XWORD_64TEST(flags, fmt_flags, &dyn_flag1_buf->inv_buf);
99
100 conv_arg.oflags = conv_arg.rflags = flags;
101 conv_arg.buf = dyn_flag1_buf->buf;
102 (void) conv_expn_field(&conv_arg, conv_dyn_flag1_strings(fmt_flags),
103 fmt_flags);
104
105 return ((const char *)dyn_flag1_buf->buf);
106 }
107
108 const char *
conv_dyn_feature1(Xword flags,Conv_fmt_flags_t fmt_flags,Conv_dyn_feature1_buf_t * dyn_feature1_buf)109 conv_dyn_feature1(Xword flags, Conv_fmt_flags_t fmt_flags,
110 Conv_dyn_feature1_buf_t *dyn_feature1_buf)
111 {
112 static CONV_EXPN_FIELD_ARG conv_arg = {
113 NULL, sizeof (dyn_feature1_buf->buf) };
114
115 if (flags == 0)
116 return (MSG_ORIG(MSG_GBL_ZERO));
117 CONV_XWORD_64TEST(flags, fmt_flags, &dyn_feature1_buf->inv_buf);
118
119 conv_arg.buf = dyn_feature1_buf->buf;
120 conv_arg.oflags = conv_arg.rflags = flags;
121 if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) {
122 conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY);
123 } else {
124 conv_arg.prefix = conv_arg.suffix = NULL;
125 }
126 (void) conv_expn_field(&conv_arg,
127 conv_dyn_feature1_strings(fmt_flags), fmt_flags);
128
129 return ((const char *)dyn_feature1_buf->buf);
130 }
131
132 const char *
conv_dyn_tag(Xword tag,uchar_t osabi,Half mach,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)133 conv_dyn_tag(Xword tag, uchar_t osabi, Half mach, Conv_fmt_flags_t fmt_flags,
134 Conv_inv_buf_t *inv_buf)
135 {
136 CONV_XWORD_64TEST(tag, fmt_flags, inv_buf);
137 return (conv_map_ds(osabi, mach, tag,
138 conv_dyn_tag_strings(osabi, mach, fmt_flags), fmt_flags, inv_buf));
139 }
140