3 Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of version 2.1 of the GNU Lesser General Public License
7 as published by the Free Software Foundation.
9 This program is distributed in the hope that it would be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 Further, this software is distributed without any warranty that it is
14 free of the rightful claim of any third person regarding infringement
15 or the like. Any license provided herein, whether implied or
16 otherwise, applies only to this software file. Patent licenses, if
17 any, provided herein do not apply to combinations of this program with
18 other software, or any other product whatsoever.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this program; if not, write the Free Software
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
25 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
26 Mountain View, CA 94043, or:
30 For further information regarding this notice, see:
32 http://oss.sgi.com/projects/GenInfo/NoticeExplan
39 #include "libdwarfdefs.h"
43 #define MORE_BYTES 0x80
44 #define DATA_MASK 0x7f
49 /*-------------------------------------------------------------
50 Encode val as a leb128. This encodes it as an unsigned
52 ---------------------------------------------------------------*/
53 /* return DW_DLV_ERROR or DW_DLV_OK.
54 ** space to write leb number is provided by caller, with caller
56 ** number of bytes used returned thru nbytes arg
59 _dwarf_pro_encode_leb128_nm(Dwarf_Unsigned val
, int *nbytes
,
60 char *space
, int splen
)
63 char *end
= space
+ splen
;
84 /* return DW_DLV_ERROR or DW_DLV_OK.
85 ** space to write leb number is provided by caller, with caller
87 ** number of bytes used returned thru nbytes arg
88 ** encodes a signed number.
91 _dwarf_pro_encode_signed_leb128_nm(Dwarf_Signed value
, int *nbytes
,
92 char *space
, int splen
)
95 Dwarf_Signed sign
= -(value
< 0);
97 char *end
= space
+ splen
;
102 unsigned char byte
= value
& DATA_MASK
;
104 value
>>= DIGIT_WIDTH
;
110 * Remaining chunks would just contain the sign bit, and this chunk
111 * has already captured at least one sign bit.
113 if (value
== sign
&& ((byte
& SIGN_BIT
) == (sign
& SIGN_BIT
))) {
121 *nbytes
= str
- space
;