xref: /titanic_41/usr/src/cmd/sgs/libconv/common/dynamic_machelf.c (revision 4f680cc668fa6cf678c531083400ade9a9c7934c)
1*4f680cc6SAli Bahrami /*
2*4f680cc6SAli Bahrami  * CDDL HEADER START
3*4f680cc6SAli Bahrami  *
4*4f680cc6SAli Bahrami  * The contents of this file are subject to the terms of the
5*4f680cc6SAli Bahrami  * Common Development and Distribution License (the "License").
6*4f680cc6SAli Bahrami  * You may not use this file except in compliance with the License.
7*4f680cc6SAli Bahrami  *
8*4f680cc6SAli Bahrami  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*4f680cc6SAli Bahrami  * or http://www.opensolaris.org/os/licensing.
10*4f680cc6SAli Bahrami  * See the License for the specific language governing permissions
11*4f680cc6SAli Bahrami  * and limitations under the License.
12*4f680cc6SAli Bahrami  *
13*4f680cc6SAli Bahrami  * When distributing Covered Code, include this CDDL HEADER in each
14*4f680cc6SAli Bahrami  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*4f680cc6SAli Bahrami  * If applicable, add the following below this CDDL HEADER, with the
16*4f680cc6SAli Bahrami  * fields enclosed by brackets "[]" replaced with your own identifying
17*4f680cc6SAli Bahrami  * information: Portions Copyright [yyyy] [name of copyright owner]
18*4f680cc6SAli Bahrami  *
19*4f680cc6SAli Bahrami  * CDDL HEADER END
20*4f680cc6SAli Bahrami  */
21*4f680cc6SAli Bahrami 
22*4f680cc6SAli Bahrami /*
23*4f680cc6SAli Bahrami  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*4f680cc6SAli Bahrami  * Use is subject to license terms.
25*4f680cc6SAli Bahrami  */
26*4f680cc6SAli Bahrami 
27*4f680cc6SAli Bahrami /*
28*4f680cc6SAli Bahrami  * String conversion routine for .dynamic tag entries.
29*4f680cc6SAli Bahrami  */
30*4f680cc6SAli Bahrami #include	<stdio.h>
31*4f680cc6SAli Bahrami #include	<string.h>
32*4f680cc6SAli Bahrami #include	<sys/elf_SPARC.h>
33*4f680cc6SAli Bahrami #include	"rtld.h"
34*4f680cc6SAli Bahrami #include	"_conv.h"
35*4f680cc6SAli Bahrami #include	"dynamic_msg.h"
36*4f680cc6SAli Bahrami 
37*4f680cc6SAli Bahrami 
38*4f680cc6SAli Bahrami 
39*4f680cc6SAli Bahrami const char *
conv_dyn_posflag1(Xword flags,Conv_fmt_flags_t fmt_flags,Conv_dyn_posflag1_buf_t * dyn_posflag1_buf)40*4f680cc6SAli Bahrami conv_dyn_posflag1(Xword flags, Conv_fmt_flags_t fmt_flags,
41*4f680cc6SAli Bahrami     Conv_dyn_posflag1_buf_t *dyn_posflag1_buf)
42*4f680cc6SAli Bahrami {
43*4f680cc6SAli Bahrami 	static CONV_EXPN_FIELD_ARG conv_arg = {
44*4f680cc6SAli Bahrami 	    NULL, sizeof (dyn_posflag1_buf->buf) };
45*4f680cc6SAli Bahrami 	static CONV_EXPN_FIELD_ARG conv_arg_alt = {
46*4f680cc6SAli Bahrami 	    NULL, sizeof (dyn_posflag1_buf->buf), NULL, 0, 0,
47*4f680cc6SAli Bahrami 	    MSG_ORIG(MSG_STR_EMPTY), NULL, MSG_ORIG(MSG_STR_EMPTY) };
48*4f680cc6SAli Bahrami 
49*4f680cc6SAli Bahrami 	CONV_EXPN_FIELD_ARG	*arg;
50*4f680cc6SAli Bahrami 
51*4f680cc6SAli Bahrami 	if (flags == 0)
52*4f680cc6SAli Bahrami 		return (MSG_ORIG(MSG_GBL_ZERO));
53*4f680cc6SAli Bahrami 	CONV_XWORD_64TEST(flags, fmt_flags, &dyn_posflag1_buf->inv_buf);
54*4f680cc6SAli Bahrami 
55*4f680cc6SAli Bahrami 	arg = (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) ?
56*4f680cc6SAli Bahrami 	    &conv_arg_alt : &conv_arg;
57*4f680cc6SAli Bahrami 	arg->buf = dyn_posflag1_buf->buf;
58*4f680cc6SAli Bahrami 	arg->oflags = arg->rflags = flags;
59*4f680cc6SAli Bahrami 	(void) conv_expn_field(arg, conv_dyn_posflag1_strings(fmt_flags),
60*4f680cc6SAli Bahrami 	    fmt_flags);
61*4f680cc6SAli Bahrami 
62*4f680cc6SAli Bahrami 	return ((const char *)dyn_posflag1_buf);
63*4f680cc6SAli Bahrami }
64*4f680cc6SAli Bahrami 
65*4f680cc6SAli Bahrami const char *
conv_dyn_flag(Xword flags,Conv_fmt_flags_t fmt_flags,Conv_dyn_flag_buf_t * dyn_flag_buf)66*4f680cc6SAli Bahrami conv_dyn_flag(Xword flags, Conv_fmt_flags_t fmt_flags,
67*4f680cc6SAli Bahrami     Conv_dyn_flag_buf_t *dyn_flag_buf)
68*4f680cc6SAli Bahrami {
69*4f680cc6SAli Bahrami 	static CONV_EXPN_FIELD_ARG conv_arg = {
70*4f680cc6SAli Bahrami 	    NULL, sizeof (dyn_flag_buf->buf) };
71*4f680cc6SAli Bahrami 
72*4f680cc6SAli Bahrami 	if (flags == 0)
73*4f680cc6SAli Bahrami 		return (MSG_ORIG(MSG_GBL_ZERO));
74*4f680cc6SAli Bahrami 	CONV_XWORD_64TEST(flags, fmt_flags, &dyn_flag_buf->inv_buf);
75*4f680cc6SAli Bahrami 
76*4f680cc6SAli Bahrami 	conv_arg.buf = dyn_flag_buf->buf;
77*4f680cc6SAli Bahrami 	conv_arg.oflags = conv_arg.rflags = flags;
78*4f680cc6SAli Bahrami 	if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) {
79*4f680cc6SAli Bahrami 		conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY);
80*4f680cc6SAli Bahrami 	} else {
81*4f680cc6SAli Bahrami 		conv_arg.prefix = conv_arg.suffix = NULL;
82*4f680cc6SAli Bahrami 	}
83*4f680cc6SAli Bahrami 	(void) conv_expn_field(&conv_arg, conv_dyn_flag_strings(fmt_flags),
84*4f680cc6SAli Bahrami 	    fmt_flags);
85*4f680cc6SAli Bahrami 
86*4f680cc6SAli Bahrami 	return ((const char *)dyn_flag_buf->buf);
87*4f680cc6SAli Bahrami }
88*4f680cc6SAli Bahrami 
89*4f680cc6SAli Bahrami const char *
conv_dyn_flag1(Xword flags,Conv_fmt_flags_t fmt_flags,Conv_dyn_flag1_buf_t * dyn_flag1_buf)90*4f680cc6SAli Bahrami conv_dyn_flag1(Xword flags, Conv_fmt_flags_t fmt_flags,
91*4f680cc6SAli Bahrami     Conv_dyn_flag1_buf_t *dyn_flag1_buf)
92*4f680cc6SAli Bahrami {
93*4f680cc6SAli Bahrami 	static CONV_EXPN_FIELD_ARG conv_arg = {
94*4f680cc6SAli Bahrami 	    NULL, sizeof (dyn_flag1_buf->buf) };
95*4f680cc6SAli Bahrami 
96*4f680cc6SAli Bahrami 	if (flags == 0)
97*4f680cc6SAli Bahrami 		return (MSG_ORIG(MSG_GBL_ZERO));
98*4f680cc6SAli Bahrami 	CONV_XWORD_64TEST(flags, fmt_flags, &dyn_flag1_buf->inv_buf);
99*4f680cc6SAli Bahrami 
100*4f680cc6SAli Bahrami 	conv_arg.oflags = conv_arg.rflags = flags;
101*4f680cc6SAli Bahrami 	conv_arg.buf = dyn_flag1_buf->buf;
102*4f680cc6SAli Bahrami 	(void) conv_expn_field(&conv_arg, conv_dyn_flag1_strings(fmt_flags),
103*4f680cc6SAli Bahrami 	    fmt_flags);
104*4f680cc6SAli Bahrami 
105*4f680cc6SAli Bahrami 	return ((const char *)dyn_flag1_buf->buf);
106*4f680cc6SAli Bahrami }
107*4f680cc6SAli Bahrami 
108*4f680cc6SAli Bahrami const char *
conv_dyn_feature1(Xword flags,Conv_fmt_flags_t fmt_flags,Conv_dyn_feature1_buf_t * dyn_feature1_buf)109*4f680cc6SAli Bahrami conv_dyn_feature1(Xword flags, Conv_fmt_flags_t fmt_flags,
110*4f680cc6SAli Bahrami     Conv_dyn_feature1_buf_t *dyn_feature1_buf)
111*4f680cc6SAli Bahrami {
112*4f680cc6SAli Bahrami 	static CONV_EXPN_FIELD_ARG conv_arg = {
113*4f680cc6SAli Bahrami 	    NULL, sizeof (dyn_feature1_buf->buf) };
114*4f680cc6SAli Bahrami 
115*4f680cc6SAli Bahrami 	if (flags == 0)
116*4f680cc6SAli Bahrami 		return (MSG_ORIG(MSG_GBL_ZERO));
117*4f680cc6SAli Bahrami 	CONV_XWORD_64TEST(flags, fmt_flags, &dyn_feature1_buf->inv_buf);
118*4f680cc6SAli Bahrami 
119*4f680cc6SAli Bahrami 	conv_arg.buf = dyn_feature1_buf->buf;
120*4f680cc6SAli Bahrami 	conv_arg.oflags = conv_arg.rflags = flags;
121*4f680cc6SAli Bahrami 	if (CONV_TYPE_FMT_ALT(fmt_flags) == CONV_FMT_ALT_DUMP) {
122*4f680cc6SAli Bahrami 		conv_arg.prefix = conv_arg.suffix = MSG_ORIG(MSG_STR_EMPTY);
123*4f680cc6SAli Bahrami 	} else {
124*4f680cc6SAli Bahrami 		conv_arg.prefix = conv_arg.suffix = NULL;
125*4f680cc6SAli Bahrami 	}
126*4f680cc6SAli Bahrami 	(void) conv_expn_field(&conv_arg,
127*4f680cc6SAli Bahrami 	    conv_dyn_feature1_strings(fmt_flags), fmt_flags);
128*4f680cc6SAli Bahrami 
129*4f680cc6SAli Bahrami 	return ((const char *)dyn_feature1_buf->buf);
130*4f680cc6SAli Bahrami }
131*4f680cc6SAli Bahrami 
132*4f680cc6SAli Bahrami 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*4f680cc6SAli Bahrami conv_dyn_tag(Xword tag, uchar_t osabi, Half mach, Conv_fmt_flags_t fmt_flags,
134*4f680cc6SAli Bahrami     Conv_inv_buf_t *inv_buf)
135*4f680cc6SAli Bahrami {
136*4f680cc6SAli Bahrami 	CONV_XWORD_64TEST(tag, fmt_flags, inv_buf);
137*4f680cc6SAli Bahrami 	return (conv_map_ds(osabi, mach, tag,
138*4f680cc6SAli Bahrami 	    conv_dyn_tag_strings(osabi, mach, fmt_flags), fmt_flags, inv_buf));
139*4f680cc6SAli Bahrami }
140