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.
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.
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]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <dwarf_ehe_msg.h>
33 #define FLAGSZ MSG_GBL_OSQBRKT_SIZE + \
34 MSG_DWEHE_SLEB128_SIZE + \
35 MSG_DWEHE_INDIRECT_SIZE + \
36 CONV_INV_BUFSIZE + MSG_GBL_CSQBRKT_SIZE
39 * Ensure that Conv_dwarf_ehe_buf_t is large enough:
41 * FLAGSZ is the real minimum size of the buffer required by conv_dwarf_ehe().
42 * However, Conv_dwarf_ehe_buf_t uses CONV_EHDR_FLAG_BUFSIZE to set the
43 * buffer size. We do things this way because the definition of FLAGSZ uses
44 * information that is not available in the environment of other programs
45 * that include the conv.h header file.
47 #if (CONV_DWARF_EHE_BUFSIZE != FLAGSZ) && !defined(__lint)
48 #define REPORT_BUFSIZE FLAGSZ
49 #include "report_bufsize.h"
50 #error "CONV_DWARF_EHE_BUFSIZE does not match FLAGSZ"
54 conv_dwarf_ehe(uint_t flags
, Conv_dwarf_ehe_buf_t
*dwarf_ehe_buf
)
56 char *buf
= dwarf_ehe_buf
->buf
;
59 (void) strncpy(buf
, MSG_ORIG(MSG_GBL_OSQBRKT
), FLAGSZ
);
61 if (flags
== DW_EH_PE_omit
)
62 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_OMIT
), FLAGSZ
);
63 else if (flags
== DW_EH_PE_absptr
)
64 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_ABSPTR
), FLAGSZ
);
67 return (conv_invalid_val(&dwarf_ehe_buf
->inv_buf
, flags
, 0));
69 if ((flags
== DW_EH_PE_omit
) || (flags
== DW_EH_PE_absptr
)) {
70 (void) strlcat(buf
, MSG_ORIG(MSG_GBL_CSQBRKT
), FLAGSZ
);
74 switch (flags
& 0x0f) {
75 case DW_EH_PE_uleb128
:
76 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_ULEB128
), FLAGSZ
);
79 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_UDATA2
), FLAGSZ
);
82 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_UDATA4
), FLAGSZ
);
85 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_UDATA8
), FLAGSZ
);
87 case DW_EH_PE_sleb128
:
88 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_SLEB128
), FLAGSZ
);
91 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_SDATA2
), FLAGSZ
);
94 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_SDATA4
), FLAGSZ
);
97 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_SDATA8
), FLAGSZ
);
101 return (conv_invalid_val(&dwarf_ehe_buf
->inv_buf
, flags
, 0));
103 switch (flags
& 0xf0) {
105 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_PCREL
), FLAGSZ
);
107 case DW_EH_PE_textrel
:
108 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_TEXTREL
), FLAGSZ
);
110 case DW_EH_PE_datarel
:
111 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_DATAREL
), FLAGSZ
);
113 case DW_EH_PE_funcrel
:
114 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_FUNCREL
), FLAGSZ
);
116 case DW_EH_PE_aligned
:
117 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_ALIGNED
), FLAGSZ
);
119 case DW_EH_PE_indirect
:
120 ret
= strlcat(buf
, MSG_ORIG(MSG_DWEHE_INDIRECT
), FLAGSZ
);
124 return (conv_invalid_val(&dwarf_ehe_buf
->inv_buf
, flags
, 0));
126 (void) strlcat(buf
, MSG_ORIG(MSG_GBL_CSQBRKT
), FLAGSZ
);