xref: /titanic_41/usr/src/cmd/sgs/libconv/common/dwarf_ehe.c (revision 749f21d359d8fbd020c974a1a5227316221bfc9c)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include	<strings.h>
29 #include	<stdio.h>
30 #include	<limits.h>
31 #include	<dwarf.h>
32 #include	<dwarf_ehe_msg.h>
33 
34 #define	STRBUFSIZE	128
35 const char *
36 conv_dwarf_ehe_str(uint_t flags)
37 {
38 	static char	string[STRBUFSIZE];
39 
40 	(void) strncpy(string, MSG_ORIG(MSG_GBL_OSQBRKT), STRBUFSIZE);
41 
42 	if (flags == DW_EH_PE_omit) {
43 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_OMIT), STRBUFSIZE);
44 		(void) strlcat(string, MSG_ORIG(MSG_GBL_CSQBRKT), STRBUFSIZE);
45 		return (string);
46 	}
47 	if (flags == DW_EH_PE_absptr) {
48 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_ABSPTR), STRBUFSIZE);
49 		(void) strlcat(string, MSG_ORIG(MSG_GBL_CSQBRKT), STRBUFSIZE);
50 		return (string);
51 	}
52 
53 	switch (flags & 0x0f) {
54 	case DW_EH_PE_absptr:
55 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_ABSPTR), STRBUFSIZE);
56 		break;
57 	case DW_EH_PE_uleb128:
58 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_ULEB128), STRBUFSIZE);
59 		break;
60 	case DW_EH_PE_udata2:
61 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_UDATA2), STRBUFSIZE);
62 		break;
63 	case DW_EH_PE_udata4:
64 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_UDATA4), STRBUFSIZE);
65 		break;
66 	case DW_EH_PE_udata8:
67 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_UDATA8), STRBUFSIZE);
68 		break;
69 	case DW_EH_PE_sleb128:
70 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_SLEB128), STRBUFSIZE);
71 		break;
72 	case DW_EH_PE_sdata2:
73 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_SDATA2), STRBUFSIZE);
74 		break;
75 	case DW_EH_PE_sdata4:
76 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_SDATA4), STRBUFSIZE);
77 		break;
78 	case DW_EH_PE_sdata8:
79 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_SDATA8), STRBUFSIZE);
80 		break;
81 	}
82 
83 	switch (flags & 0xf0) {
84 	case DW_EH_PE_pcrel:
85 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_PCREL), STRBUFSIZE);
86 		break;
87 	case DW_EH_PE_textrel:
88 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_TEXTREL), STRBUFSIZE);
89 		break;
90 	case DW_EH_PE_datarel:
91 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_DATAREL), STRBUFSIZE);
92 		break;
93 	case DW_EH_PE_funcrel:
94 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_FUNCREL), STRBUFSIZE);
95 		break;
96 	case DW_EH_PE_aligned:
97 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_ALIGNED), STRBUFSIZE);
98 		break;
99 	case DW_EH_PE_indirect:
100 		(void) strlcat(string, MSG_ORIG(MSG_DWEHE_INDIRECT),
101 			STRBUFSIZE);
102 		break;
103 	}
104 
105 	(void) strlcat(string, MSG_ORIG(MSG_GBL_CSQBRKT), STRBUFSIZE);
106 	return (string);
107 }
108