|
@@ -151,7 +151,7 @@ implementation
|
|
else
|
|
else
|
|
linker.sysinitunit:='sysinitpas';
|
|
linker.sysinitunit:='sysinitpas';
|
|
end
|
|
end
|
|
- else if target_info.system=system_x86_64_win64 then
|
|
|
|
|
|
+ else if target_info.system in [system_x86_64_win64,system_aarch64_win64] then
|
|
linker.sysinitunit:='sysinit';
|
|
linker.sysinitunit:='sysinit';
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -270,22 +270,26 @@ implementation
|
|
|
|
|
|
procedure AddImport(const afuncname,mangledname:string;ordnr:longint;isvar:boolean);
|
|
procedure AddImport(const afuncname,mangledname:string;ordnr:longint;isvar:boolean);
|
|
const
|
|
const
|
|
-{$ifdef x86_64}
|
|
|
|
|
|
+{$if defined(x86_64)}
|
|
jmpopcode : array[0..1] of byte = (
|
|
jmpopcode : array[0..1] of byte = (
|
|
$ff,$25 // jmp qword [rip + offset32]
|
|
$ff,$25 // jmp qword [rip + offset32]
|
|
);
|
|
);
|
|
-{$else x86_64}
|
|
|
|
- {$ifdef arm}
|
|
|
|
|
|
+{$elseif defined(arm)}
|
|
jmpopcode : array[0..7] of byte = (
|
|
jmpopcode : array[0..7] of byte = (
|
|
$00,$c0,$9f,$e5, // ldr ip, [pc, #0]
|
|
$00,$c0,$9f,$e5, // ldr ip, [pc, #0]
|
|
$00,$f0,$9c,$e5 // ldr pc, [ip]
|
|
$00,$f0,$9c,$e5 // ldr pc, [ip]
|
|
);
|
|
);
|
|
- {$else arm}
|
|
|
|
|
|
+{$elseif defined(aarch64)}
|
|
|
|
+ jmpopcode : array[0..11] of byte = (
|
|
|
|
+ $70,$00,$00,$58, // ldr ip0, .+12
|
|
|
|
+ $10,$02,$40,$F9, // ldr ip0, [ip0]
|
|
|
|
+ $00,$02,$1F,$D6 // br ip0
|
|
|
|
+ );
|
|
|
|
+{$elseif defined(i386)}
|
|
jmpopcode : array[0..1] of byte = (
|
|
jmpopcode : array[0..1] of byte = (
|
|
$ff,$25
|
|
$ff,$25
|
|
);
|
|
);
|
|
- {$endif arm}
|
|
|
|
-{$endif x86_64}
|
|
|
|
|
|
+{$endif}
|
|
nopopcodes : array[0..1] of byte = (
|
|
nopopcodes : array[0..1] of byte = (
|
|
$90,$90
|
|
$90,$90
|
|
);
|
|
);
|
|
@@ -378,11 +382,13 @@ implementation
|
|
else
|
|
else
|
|
implabel:=objdata.SymbolDefine(basedllname+'_index_'+tostr(ordnr),AB_GLOBAL,AT_FUNCTION);
|
|
implabel:=objdata.SymbolDefine(basedllname+'_index_'+tostr(ordnr),AB_GLOBAL,AT_FUNCTION);
|
|
objdata.writebytes(jmpopcode,sizeof(jmpopcode));
|
|
objdata.writebytes(jmpopcode,sizeof(jmpopcode));
|
|
-{$ifdef x86_64}
|
|
|
|
|
|
+{$if defined(x86_64)}
|
|
objdata.writereloc(0,sizeof(longint),idata5label,RELOC_RELATIVE);
|
|
objdata.writereloc(0,sizeof(longint),idata5label,RELOC_RELATIVE);
|
|
|
|
+{$elseif defined(aarch64)}
|
|
|
|
+ objdata.writereloc(0,sizeof(aint),idata5label,RELOC_ABSOLUTE);
|
|
{$else}
|
|
{$else}
|
|
objdata.writereloc(0,sizeof(longint),idata5label,RELOC_ABSOLUTE32);
|
|
objdata.writereloc(0,sizeof(longint),idata5label,RELOC_ABSOLUTE32);
|
|
-{$endif x86_64}
|
|
|
|
|
|
+{$endif x86_64 or aarch64}
|
|
objdata.writebytes(nopopcodes,align(objdata.CurrObjSec.size,qword(sizeof(nopopcodes)))-objdata.CurrObjSec.size);
|
|
objdata.writebytes(nopopcodes,align(objdata.CurrObjSec.size,qword(sizeof(nopopcodes)))-objdata.CurrObjSec.size);
|
|
end;
|
|
end;
|
|
ObjOutput.exportsymbol(implabel);
|
|
ObjOutput.exportsymbol(implabel);
|
|
@@ -524,7 +530,7 @@ implementation
|
|
else
|
|
else
|
|
current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ExtractFileName(ImportLibrary.Name)+'_index_'+tostr(ImportSymbol.ordnr),AT_FUNCTION,0,voidcodepointertype));
|
|
current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ExtractFileName(ImportLibrary.Name)+'_index_'+tostr(ImportSymbol.ordnr),AT_FUNCTION,0,voidcodepointertype));
|
|
current_asmdata.asmlists[al_imports].concat(tai_function_name.create(''));
|
|
current_asmdata.asmlists[al_imports].concat(tai_function_name.create(''));
|
|
- {$ifdef ARM}
|
|
|
|
|
|
+ {$if defined(ARM)}
|
|
reference_reset_symbol(href,l5,0,sizeof(pint),[]);
|
|
reference_reset_symbol(href,l5,0,sizeof(pint),[]);
|
|
current_asmdata.asmlists[al_imports].concat(Taicpu.op_reg_ref(A_LDR,NR_R12,href));
|
|
current_asmdata.asmlists[al_imports].concat(Taicpu.op_reg_ref(A_LDR,NR_R12,href));
|
|
reference_reset_base(href,NR_R12,0,ctempposinvalid,sizeof(pint),[]);
|
|
reference_reset_base(href,NR_R12,0,ctempposinvalid,sizeof(pint),[]);
|
|
@@ -532,7 +538,10 @@ implementation
|
|
current_asmdata.asmlists[al_imports].concat(Tai_label.Create(l5));
|
|
current_asmdata.asmlists[al_imports].concat(Tai_label.Create(l5));
|
|
reference_reset_symbol(href,l4,0,sizeof(pint),[]);
|
|
reference_reset_symbol(href,l4,0,sizeof(pint),[]);
|
|
current_asmdata.asmlists[al_imports].concat(tai_const.create_sym_offset(href.symbol,href.offset));
|
|
current_asmdata.asmlists[al_imports].concat(tai_const.create_sym_offset(href.symbol,href.offset));
|
|
- {$else ARM}
|
|
|
|
|
|
+ {$elseif defined(AARCH64)}
|
|
|
|
+ { ToDo }
|
|
|
|
+ internalerror(2020033001);
|
|
|
|
+ {$else X86}
|
|
reference_reset_symbol(href,l4,0,sizeof(pint),[]);
|
|
reference_reset_symbol(href,l4,0,sizeof(pint),[]);
|
|
{$ifdef X86_64}
|
|
{$ifdef X86_64}
|
|
href.base:=NR_RIP;
|
|
href.base:=NR_RIP;
|
|
@@ -540,7 +549,7 @@ implementation
|
|
|
|
|
|
current_asmdata.asmlists[al_imports].concat(Taicpu.Op_ref(A_JMP,S_NO,href));
|
|
current_asmdata.asmlists[al_imports].concat(Taicpu.Op_ref(A_JMP,S_NO,href));
|
|
current_asmdata.asmlists[al_imports].concat(Tai_align.Create_op(4,$90));
|
|
current_asmdata.asmlists[al_imports].concat(Tai_align.Create_op(4,$90));
|
|
- {$endif ARM}
|
|
|
|
|
|
+ {$endif X86}
|
|
{ add jump field to al_imports }
|
|
{ add jump field to al_imports }
|
|
new_section(current_asmdata.asmlists[al_imports],sec_idata5,'',0);
|
|
new_section(current_asmdata.asmlists[al_imports],sec_idata5,'',0);
|
|
if (cs_debuginfo in current_settings.moduleswitches) then
|
|
if (cs_debuginfo in current_settings.moduleswitches) then
|
|
@@ -1859,4 +1868,11 @@ initialization
|
|
RegisterRes(res_gnu_windres_info,TWinLikeResourceFile);
|
|
RegisterRes(res_gnu_windres_info,TWinLikeResourceFile);
|
|
RegisterTarget(system_arm_wince_info);
|
|
RegisterTarget(system_arm_wince_info);
|
|
{$endif arm}
|
|
{$endif arm}
|
|
|
|
+{$ifdef aarch64}
|
|
|
|
+ RegisterImport(system_aarch64_win64,TImportLibWin);
|
|
|
|
+ RegisterExport(system_aarch64_win64,TExportLibWin);
|
|
|
|
+ // ToDo?
|
|
|
|
+ RegisterRes(res_gnu_windres_info,TWinLikeResourceFile);
|
|
|
|
+ RegisterTarget(system_aarch64_win64_info);
|
|
|
|
+{$endif aarch64}
|
|
end.
|
|
end.
|