* leb128 gets always a 64bit int

* fixed sleb128 encode

git-svn-id: trunk@3060 -
This commit is contained in:
peter 2006-03-27 13:42:06 +00:00
parent f9ccac3f30
commit dfd84c6fd3
3 changed files with 19 additions and 18 deletions

View File

@ -107,10 +107,10 @@ interface
function use_smartlink_section:boolean; function use_smartlink_section:boolean;
function maybe_smartlink_symbol:boolean; function maybe_smartlink_symbol:boolean;
function LengthUleb128(a: aword) : byte; function LengthUleb128(a: qword) : byte;
function LengthSleb128(a: aint) : byte; function LengthSleb128(a: int64) : byte;
function EncodeUleb128(a: aword;out buf) : byte; function EncodeUleb128(a: qword;out buf) : byte;
function EncodeSleb128(a: aint;out buf) : byte; function EncodeSleb128(a: int64;out buf) : byte;
implementation implementation
@ -134,7 +134,7 @@ implementation
end; end;
function LengthUleb128(a: aword) : byte; function LengthUleb128(a: qword) : byte;
begin begin
result:=0; result:=0;
repeat repeat
@ -146,10 +146,10 @@ implementation
end; end;
function LengthSleb128(a: aint) : byte; function LengthSleb128(a: int64) : byte;
var var
b, size: byte; b, size: byte;
asign : aint; asign : int64;
neg, more: boolean; neg, more: boolean;
begin begin
more := true; more := true;
@ -178,7 +178,7 @@ implementation
end; end;
function EncodeUleb128(a: aword;out buf) : byte; function EncodeUleb128(a: qword;out buf) : byte;
var var
b: byte; b: byte;
pbuf : pbyte; pbuf : pbyte;
@ -199,10 +199,10 @@ implementation
end; end;
function EncodeSleb128(a: aint;out buf) : byte; function EncodeSleb128(a: int64;out buf) : byte;
var var
b, size: byte; b, size: byte;
asign : aint; asign : int64;
neg, more: boolean; neg, more: boolean;
pbuf : pbyte; pbuf : pbyte;
begin begin
@ -229,6 +229,7 @@ implementation
else else
b := b or $80; b := b or $80;
pbuf^:=b; pbuf^:=b;
inc(pbuf);
inc(result); inc(result);
if not(more) then if not(more) then
break; break;

View File

@ -57,8 +57,8 @@ interface
destructor destroy; override; destructor destroy; override;
private private
setcount: longint; setcount: longint;
procedure WriteDecodedSleb128(a: aint); procedure WriteDecodedSleb128(a: int64);
procedure WriteDecodedUleb128(a: aword); procedure WriteDecodedUleb128(a: qword);
function NextSetLabel: string; function NextSetLabel: string;
protected protected
InstrWriter: TCPUInstrWriter; InstrWriter: TCPUInstrWriter;
@ -326,7 +326,7 @@ implementation
end; end;
procedure TGNUAssembler.WriteDecodedUleb128(a: aword); procedure TGNUAssembler.WriteDecodedUleb128(a: qword);
var var
i,len : longint; i,len : longint;
buf : array[0..63] of byte; buf : array[0..63] of byte;
@ -341,7 +341,7 @@ implementation
end; end;
procedure TGNUAssembler.WriteDecodedSleb128(a: aint); procedure TGNUAssembler.WriteDecodedSleb128(a: int64);
var var
i,len : longint; i,len : longint;
buf : array[0..255] of byte; buf : array[0..255] of byte;
@ -631,9 +631,9 @@ implementation
AsmWrite(ait_const2str[aitconst_8bit]); AsmWrite(ait_const2str[aitconst_8bit]);
case tai_const(hp).consttype of case tai_const(hp).consttype of
aitconst_uleb128bit: aitconst_uleb128bit:
WriteDecodedUleb128(aword(tai_const(hp).value)); WriteDecodedUleb128(qword(tai_const(hp).value));
aitconst_sleb128bit: aitconst_sleb128bit:
WriteDecodedSleb128(aint(tai_const(hp).value)); WriteDecodedSleb128(int64(tai_const(hp).value));
end end
end end
else else

View File

@ -930,8 +930,8 @@ implementation
finish_entry; finish_entry;
{ to simplify things, we don't write a multidimensional array here } { to simplify things, we don't write a multidimensional array here }
append_entry(DW_TAG_subrange_type,false,[ append_entry(DW_TAG_subrange_type,false,[
DW_AT_lower_bound,DW_FORM_udata,def.lowrange, DW_AT_lower_bound,DW_FORM_sdata,def.lowrange,
DW_AT_upper_bound,DW_FORM_udata,def.highrange DW_AT_upper_bound,DW_FORM_sdata,def.highrange
]); ]);
append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.rangetype.def)); append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.rangetype.def));
finish_entry; finish_entry;