From c1e2f557f124dd6d00ac869446da0e9ad2ff74c9 Mon Sep 17 00:00:00 2001
From: Pierre Muller <pierre@freepascal.org>
Date: Thu, 25 May 2023 09:58:42 +0000
Subject: [PATCH] Add '-b pei_aarch64' option for aarch64-win64 system

---
 compiler/systems/t_win.pas | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/compiler/systems/t_win.pas b/compiler/systems/t_win.pas
index 5ccfd13089..4c943f3b3a 100644
--- a/compiler/systems/t_win.pas
+++ b/compiler/systems/t_win.pas
@@ -1145,14 +1145,18 @@ implementation
       begin
         with Info do
          begin
+{$ifdef aarch64}
+           targetopts:='-b pei-aarch64-little';
+{$endif aarch64}
 {$ifdef x86_64}
            targetopts:='-b pei-x86-64';
-{$else x86_64}
-           if target_info.system=system_arm_wince then
-             targetopts:='-m arm_wince_pe'
-           else
-             targetopts:='-b pei-i386 -m i386pe';
-{$endif not x86_64}
+{$endif x86_64}
+{$ifdef i386}
+           targetopts:='-b pei-i386 -m i386pe';
+{$endif i386}
+{$ifdef arm}
+           targetopts:='-m arm_wince_pe';
+{$endif arm}
            ExeCmd[1]:='ld '+targetopts+' $OPT $GCSECTIONS $MAP $STRIP $APPTYPE $ENTRY  $IMAGEBASE $RELOC -o $EXE $RES';
            DllCmd[1]:='ld '+targetopts+' $OPT $GCSECTIONS $MAP $STRIP --dll $APPTYPE $ENTRY  $IMAGEBASE $RELOC -o $EXE $RES';
            { ExeCmd[2]:='dlltool --as $ASBIN --dllname $EXE --output-exp exp.$$$ $RELOC $DEF';