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