From 4750840e89293d286db914f853154f2dcbb10b96 Mon Sep 17 00:00:00 2001 From: Pierre Muller Date: Wed, 12 Apr 2023 21:51:53 +0000 Subject: [PATCH] Specify endianess and abi when calling xtensa linker --- compiler/systems/t_embed.pas | 16 +++++++++++++++- compiler/systems/t_freertos.pas | 16 +++++++++++++++- compiler/systems/t_linux.pas | 10 ++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/compiler/systems/t_embed.pas b/compiler/systems/t_embed.pas index 1bd2aa0d33..8027e3788c 100644 --- a/compiler/systems/t_embed.pas +++ b/compiler/systems/t_embed.pas @@ -98,10 +98,24 @@ const {$else} platform_select=''; {$endif} +var + platformopt : string; begin + {$ifdef xtensa} + if target_info.endian=endian_little then + platformopt:=' -b elf32-xtensa-le -m elf32xtensa' + else + platformopt:=' -b elf32-xtensa-be -m elf32xtensa'; + if target_info.abi=abi_xtensa_call0 then + platformopt:=platformopt+' --abi-call0' + else if target_info.abi=abi_xtensa_windowed then + platformopt:=platformopt+' --abi-windowed'; + {$else} + platformopt:=''; + {$endif} with Info do begin - ExeCmd[1]:='ld -g '+platform_select+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE -T $RES'; + ExeCmd[1]:='ld -g '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE -T $RES'; end; end; diff --git a/compiler/systems/t_freertos.pas b/compiler/systems/t_freertos.pas index a8659498ac..73669ac058 100644 --- a/compiler/systems/t_freertos.pas +++ b/compiler/systems/t_freertos.pas @@ -73,8 +73,22 @@ const {$else} platform_select=''; {$endif} +var + platformopt : string; begin - Info.ExeCmd[1]:='ld -g '+platform_select+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE -T $RES'; + {$ifdef xtensa} + if target_info.endian=endian_little then + platformopt:=' -b elf32-xtensa-le -m elf32xtensa' + else + platformopt:=' -b elf32-xtensa-be -m elf32xtensa'; + if target_info.abi=abi_xtensa_call0 then + platformopt:=platformopt+' --abi-call0' + else if target_info.abi=abi_xtensa_windowed then + platformopt:=platformopt+' --abi-windowed'; + {$else} + platformopt:=''; + {$endif} + Info.ExeCmd[1]:='ld -g '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE -T $RES'; end; diff --git a/compiler/systems/t_linux.pas b/compiler/systems/t_linux.pas index 06d5d7a77a..433079a1ec 100644 --- a/compiler/systems/t_linux.pas +++ b/compiler/systems/t_linux.pas @@ -402,6 +402,16 @@ begin else platformopt:=' -b elf64-powerpc -m elf64ppc'; {$endif powerpc64} +{$ifdef xtensa} + if target_info.endian=endian_little then + platformopt:=' -b elf32-xtensa-le -m elf32xtensa' + else + platformopt:=' -b elf32-xtensa-be -m elf32xtensa'; + if target_info.abi=abi_xtensa_call0 then + platformopt:=platformopt+' --abi-call0' + else if target_info.abi=abi_xtensa_windowed then + platformopt:=platformopt+' --abi-windowed'; + {$endif} {$ifdef arm} platformopt:=' -z noexecstack'; {$endif arm}