|
@@ -31,7 +31,7 @@ interface
|
|
cclasses,
|
|
cclasses,
|
|
globtype,
|
|
globtype,
|
|
cgbase,cpubase,
|
|
cgbase,cpubase,
|
|
- aasmbase,aasmtai,aasmdata;
|
|
|
|
|
|
+ aasmbase,aasmcfi,aasmtai,aasmdata;
|
|
|
|
|
|
const
|
|
const
|
|
maxdwarfops = 2;
|
|
maxdwarfops = 2;
|
|
@@ -63,6 +63,11 @@ interface
|
|
end;
|
|
end;
|
|
|
|
|
|
TDwarfAsmCFI=class(TAsmCFI)
|
|
TDwarfAsmCFI=class(TAsmCFI)
|
|
|
|
+ use_eh_frame : boolean;
|
|
|
|
+ constructor create;override;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ TDwarfAsmCFILowLevel=class(TDwarfAsmCFI)
|
|
private
|
|
private
|
|
FDwarfList : TLinkedList;
|
|
FDwarfList : TLinkedList;
|
|
FFrameStartLabel,
|
|
FFrameStartLabel,
|
|
@@ -75,7 +80,6 @@ interface
|
|
data_alignment_factor : shortint;
|
|
data_alignment_factor : shortint;
|
|
property DwarfList:TlinkedList read FDwarfList;
|
|
property DwarfList:TlinkedList read FDwarfList;
|
|
public
|
|
public
|
|
- use_eh_frame : boolean;
|
|
|
|
constructor create;override;
|
|
constructor create;override;
|
|
destructor destroy;override;
|
|
destructor destroy;override;
|
|
procedure generate_code(list:TAsmList);override;
|
|
procedure generate_code(list:TAsmList);override;
|
|
@@ -94,6 +98,20 @@ interface
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+ TDwarfAsmCFIHighLevel=class(TDwarfAsmCFILowLevel)
|
|
|
|
+ public
|
|
|
|
+ procedure generate_code(list:TAsmList);override;
|
|
|
|
+
|
|
|
|
+ { operations }
|
|
|
|
+ procedure start_frame(list:TAsmList);override;
|
|
|
|
+ procedure end_frame(list:TAsmList);override;
|
|
|
|
+ procedure outmost_frame(list: TAsmList);override;
|
|
|
|
+ procedure cfa_offset(list:TAsmList;reg:tregister;ofs:longint);override;
|
|
|
|
+ procedure cfa_restore(list:TAsmList;reg:tregister);override;
|
|
|
|
+ procedure cfa_def_cfa_register(list:TAsmList;reg:tregister);override;
|
|
|
|
+ procedure cfa_def_cfa_offset(list:TAsmList;ofs:longint);override;
|
|
|
|
+ end;
|
|
|
|
+
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
@@ -211,6 +229,19 @@ implementation
|
|
****************************************************************************}
|
|
****************************************************************************}
|
|
|
|
|
|
constructor TDwarfAsmCFI.create;
|
|
constructor TDwarfAsmCFI.create;
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ if tf_use_psabieh in target_info.flags then
|
|
|
|
+ use_eh_frame:=true;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+{****************************************************************************
|
|
|
|
+ TDwarfAsmCFILowLevel
|
|
|
|
+****************************************************************************}
|
|
|
|
+
|
|
|
|
+ constructor TDwarfAsmCFILowLevel.create;
|
|
begin
|
|
begin
|
|
inherited create;
|
|
inherited create;
|
|
FFrameStartLabel:=nil;
|
|
FFrameStartLabel:=nil;
|
|
@@ -219,12 +250,10 @@ implementation
|
|
code_alignment_factor:=1;
|
|
code_alignment_factor:=1;
|
|
data_alignment_factor:=-4;
|
|
data_alignment_factor:=-4;
|
|
FDwarfList:=TLinkedList.Create;
|
|
FDwarfList:=TLinkedList.Create;
|
|
- if tf_use_psabieh in target_info.flags then
|
|
|
|
- use_eh_frame:=true;
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- destructor TDwarfAsmCFI.destroy;
|
|
|
|
|
|
+ destructor TDwarfAsmCFILowLevel.destroy;
|
|
begin
|
|
begin
|
|
FDwarfList.Free;
|
|
FDwarfList.Free;
|
|
end;
|
|
end;
|
|
@@ -232,7 +261,7 @@ implementation
|
|
|
|
|
|
{$ifdef i386}
|
|
{$ifdef i386}
|
|
{ if more cpu dependend stuff is implemented, this needs more refactoring }
|
|
{ if more cpu dependend stuff is implemented, this needs more refactoring }
|
|
- procedure TDwarfAsmCFI.generate_initial_instructions(list:TAsmList);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.generate_initial_instructions(list:TAsmList);
|
|
begin
|
|
begin
|
|
list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
|
|
list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
|
|
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
|
|
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
|
|
@@ -243,7 +272,7 @@ implementation
|
|
end;
|
|
end;
|
|
{$else i386}
|
|
{$else i386}
|
|
{ if more cpu dependend stuff is implemented, this needs more refactoring }
|
|
{ if more cpu dependend stuff is implemented, this needs more refactoring }
|
|
- procedure TDwarfAsmCFI.generate_initial_instructions(list:TAsmList);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.generate_initial_instructions(list:TAsmList);
|
|
begin
|
|
begin
|
|
list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
|
|
list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
|
|
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
|
|
list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
|
|
@@ -254,7 +283,7 @@ implementation
|
|
end;
|
|
end;
|
|
{$endif i386}
|
|
{$endif i386}
|
|
|
|
|
|
- procedure TDwarfAsmCFI.generate_code(list:TAsmList);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.generate_code(list:TAsmList);
|
|
var
|
|
var
|
|
hp : tdwarfitem;
|
|
hp : tdwarfitem;
|
|
CurrentLSDALabel,
|
|
CurrentLSDALabel,
|
|
@@ -431,7 +460,7 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- procedure TDwarfAsmCFI.start_frame(list:TAsmList);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.start_frame(list:TAsmList);
|
|
begin
|
|
begin
|
|
current_asmdata.getlabel(FFrameEndLabel,alt_dbgframe);
|
|
current_asmdata.getlabel(FFrameEndLabel,alt_dbgframe);
|
|
FLastloclabel:=get_frame_start;
|
|
FLastloclabel:=get_frame_start;
|
|
@@ -440,7 +469,7 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- function TDwarfAsmCFI.get_frame_start : TAsmLabel;
|
|
|
|
|
|
+ function TDwarfAsmCFILowLevel.get_frame_start : TAsmLabel;
|
|
begin
|
|
begin
|
|
if not(assigned(FFrameStartLabel)) then
|
|
if not(assigned(FFrameStartLabel)) then
|
|
current_asmdata.getlabel(FFrameStartLabel,alt_dbgframe);
|
|
current_asmdata.getlabel(FFrameStartLabel,alt_dbgframe);
|
|
@@ -448,20 +477,20 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- function TDwarfAsmCFI.get_cfa_list: TAsmList;
|
|
|
|
|
|
+ function TDwarfAsmCFILowLevel.get_cfa_list: TAsmList;
|
|
begin
|
|
begin
|
|
Result:=TAsmList(DwarfList);
|
|
Result:=TAsmList(DwarfList);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- procedure TDwarfAsmCFI.outmost_frame(list: TAsmList);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.outmost_frame(list: TAsmList);
|
|
begin
|
|
begin
|
|
cfa_advance_loc(list);
|
|
cfa_advance_loc(list);
|
|
DwarfList.concat(tdwarfitem.create_reg(DW_CFA_undefined,doe_uleb,NR_RETURN_ADDRESS_REG));
|
|
DwarfList.concat(tdwarfitem.create_reg(DW_CFA_undefined,doe_uleb,NR_RETURN_ADDRESS_REG));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- procedure TDwarfAsmCFI.end_frame(list:TAsmList);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.end_frame(list:TAsmList);
|
|
begin
|
|
begin
|
|
if not assigned(FFrameStartLabel) then
|
|
if not assigned(FFrameStartLabel) then
|
|
internalerror(2004041213);
|
|
internalerror(2004041213);
|
|
@@ -473,7 +502,7 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- procedure TDwarfAsmCFI.cfa_advance_loc(list:TAsmList);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.cfa_advance_loc(list:TAsmList);
|
|
var
|
|
var
|
|
currloclabel : tasmlabel;
|
|
currloclabel : tasmlabel;
|
|
begin
|
|
begin
|
|
@@ -486,7 +515,7 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- procedure TDwarfAsmCFI.cfa_offset(list:TAsmList;reg:tregister;ofs:longint);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.cfa_offset(list:TAsmList;reg:tregister;ofs:longint);
|
|
begin
|
|
begin
|
|
cfa_advance_loc(list);
|
|
cfa_advance_loc(list);
|
|
{ TODO: check if ref is a temp}
|
|
{ TODO: check if ref is a temp}
|
|
@@ -495,27 +524,119 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- procedure TDwarfAsmCFI.cfa_restore(list:TAsmList;reg:tregister);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.cfa_restore(list:TAsmList;reg:tregister);
|
|
begin
|
|
begin
|
|
cfa_advance_loc(list);
|
|
cfa_advance_loc(list);
|
|
DwarfList.concat(tdwarfitem.create_reg(DW_CFA_restore_extended,doe_uleb,reg));
|
|
DwarfList.concat(tdwarfitem.create_reg(DW_CFA_restore_extended,doe_uleb,reg));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- procedure TDwarfAsmCFI.cfa_def_cfa_register(list:TAsmList;reg:tregister);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.cfa_def_cfa_register(list:TAsmList;reg:tregister);
|
|
begin
|
|
begin
|
|
cfa_advance_loc(list);
|
|
cfa_advance_loc(list);
|
|
DwarfList.concat(tdwarfitem.create_reg(DW_CFA_def_cfa_register,doe_uleb,reg));
|
|
DwarfList.concat(tdwarfitem.create_reg(DW_CFA_def_cfa_register,doe_uleb,reg));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- procedure TDwarfAsmCFI.cfa_def_cfa_offset(list:TAsmList;ofs:longint);
|
|
|
|
|
|
+ procedure TDwarfAsmCFILowLevel.cfa_def_cfa_offset(list:TAsmList;ofs:longint);
|
|
begin
|
|
begin
|
|
cfa_advance_loc(list);
|
|
cfa_advance_loc(list);
|
|
DwarfList.concat(tdwarfitem.create_const(DW_CFA_def_cfa_offset,doe_uleb,ofs));
|
|
DwarfList.concat(tdwarfitem.create_const(DW_CFA_def_cfa_offset,doe_uleb,ofs));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+{****************************************************************************
|
|
|
|
+ TDwarfAsmCFILowLevel
|
|
|
|
+****************************************************************************}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure TDwarfAsmCFIHighLevel.generate_code(list: TAsmList);
|
|
|
|
+ begin
|
|
|
|
+ if not(tf_use_hlcfi in target_info.flags) then
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure TDwarfAsmCFIHighLevel.start_frame(list: TAsmList);
|
|
|
|
+ begin
|
|
|
|
+ if not(tf_use_hlcfi in target_info.flags) then
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ list.concat(tai_cfi_op_none.create(cfi_startproc));
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure TDwarfAsmCFIHighLevel.end_frame(list: TAsmList);
|
|
|
|
+ begin
|
|
|
|
+ if not(tf_use_hlcfi in target_info.flags) then
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ list.concat(tai_cfi_op_none.create(cfi_endproc));
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure TDwarfAsmCFIHighLevel.outmost_frame(list: TAsmList);
|
|
|
|
+ begin
|
|
|
|
+ if not(tf_use_hlcfi in target_info.flags) then
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ list.concat(tai_cfi_op_reg.create(cfi_undefined,NR_RETURN_ADDRESS_REG));
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure TDwarfAsmCFIHighLevel.cfa_offset(list: TAsmList; reg: tregister; ofs: longint);
|
|
|
|
+ begin
|
|
|
|
+ if not(tf_use_hlcfi in target_info.flags) then
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ list.concat(tai_cfi_op_reg_val.create(cfi_offset,reg,ofs));
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure TDwarfAsmCFIHighLevel.cfa_restore(list: TAsmList; reg: tregister);
|
|
|
|
+ begin
|
|
|
|
+ if not(tf_use_hlcfi in target_info.flags) then
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ list.concat(tai_cfi_op_reg.create(cfi_restore,reg));
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure TDwarfAsmCFIHighLevel.cfa_def_cfa_register(list: TAsmList; reg: tregister);
|
|
|
|
+ begin
|
|
|
|
+ if not(tf_use_hlcfi in target_info.flags) then
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ list.concat(tai_cfi_op_reg.create(cfi_def_cfa_register,reg));
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure TDwarfAsmCFIHighLevel.cfa_def_cfa_offset(list: TAsmList; ofs: longint);
|
|
|
|
+ begin
|
|
|
|
+ if not(tf_use_hlcfi in target_info.flags) then
|
|
|
|
+ begin
|
|
|
|
+ inherited;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ list.concat(tai_cfi_op_val.create(cfi_def_cfa_offset,ofs));
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
begin
|
|
begin
|
|
- CAsmCFI:=TDwarfAsmCFI;
|
|
|
|
|
|
+ CAsmCFI:=TDwarfAsmCFIHighLevel;
|
|
end.
|
|
end.
|