xref: /titanic_50/usr/src/cmd/sgs/libconv/common/sections_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 routines for section attributes.
29*4f680cc6SAli Bahrami  */
30*4f680cc6SAli Bahrami #include	<string.h>
31*4f680cc6SAli Bahrami #include	<sys/param.h>
32*4f680cc6SAli Bahrami #include	<sys/elf_SPARC.h>
33*4f680cc6SAli Bahrami #include	<sys/elf_amd64.h>
34*4f680cc6SAli Bahrami #include	<_conv.h>
35*4f680cc6SAli Bahrami #include	<sections_msg.h>
36*4f680cc6SAli Bahrami 
37*4f680cc6SAli Bahrami 
38*4f680cc6SAli Bahrami 
39*4f680cc6SAli Bahrami const char *
conv_sec_flags(uchar_t osabi,Half mach,Xword flags,Conv_fmt_flags_t fmt_flags,Conv_sec_flags_buf_t * sec_flags_buf)40*4f680cc6SAli Bahrami conv_sec_flags(uchar_t osabi, Half mach, Xword flags,
41*4f680cc6SAli Bahrami     Conv_fmt_flags_t fmt_flags, Conv_sec_flags_buf_t *sec_flags_buf)
42*4f680cc6SAli Bahrami {
43*4f680cc6SAli Bahrami 	static CONV_EXPN_FIELD_ARG conv_arg = {
44*4f680cc6SAli Bahrami 	    NULL, sizeof (sec_flags_buf->buf) };
45*4f680cc6SAli Bahrami 
46*4f680cc6SAli Bahrami 	if (flags == 0)
47*4f680cc6SAli Bahrami 		return (MSG_ORIG(MSG_GBL_ZERO));
48*4f680cc6SAli Bahrami 	CONV_XWORD_64TEST(flags, fmt_flags, &sec_flags_buf->inv_buf);
49*4f680cc6SAli Bahrami 
50*4f680cc6SAli Bahrami 	conv_arg.buf = sec_flags_buf->buf;
51*4f680cc6SAli Bahrami 	conv_arg.oflags = conv_arg.rflags = flags;
52*4f680cc6SAli Bahrami 	(void) conv_expn_field2(&conv_arg, osabi, mach,
53*4f680cc6SAli Bahrami 	    conv_sec_flags_strings(fmt_flags), fmt_flags);
54*4f680cc6SAli Bahrami 
55*4f680cc6SAli Bahrami 	return ((const char *)sec_flags_buf->buf);
56*4f680cc6SAli Bahrami }
57*4f680cc6SAli Bahrami 
58*4f680cc6SAli Bahrami const char *
conv_sec_linkinfo(Word info,Xword flags,Conv_inv_buf_t * inv_buf)59*4f680cc6SAli Bahrami conv_sec_linkinfo(Word info, Xword flags, Conv_inv_buf_t *inv_buf)
60*4f680cc6SAli Bahrami {
61*4f680cc6SAli Bahrami 	if (flags & ALL_SHF_ORDER) {
62*4f680cc6SAli Bahrami 		if (info == SHN_BEFORE)
63*4f680cc6SAli Bahrami 			return (MSG_ORIG(MSG_SHN_BEFORE));
64*4f680cc6SAli Bahrami 		else if (info == SHN_AFTER)
65*4f680cc6SAli Bahrami 			return (MSG_ORIG(MSG_SHN_AFTER));
66*4f680cc6SAli Bahrami 	}
67*4f680cc6SAli Bahrami 
68*4f680cc6SAli Bahrami 	CONV_XWORD_64TEST(flags, 0, inv_buf);
69*4f680cc6SAli Bahrami 	(void) conv_invalid_val(inv_buf, info, CONV_FMT_DECIMAL);
70*4f680cc6SAli Bahrami 	return ((const char *)inv_buf->buf);
71*4f680cc6SAli Bahrami }
72