|
@@ -409,45 +409,80 @@ procedure TLinkerLinux.SetDefaultInfo;
|
|
|
{
|
|
|
This will also detect which libc version will be used
|
|
|
}
|
|
|
-
|
|
|
-const
|
|
|
-{$ifdef i386} platform_select='-b elf32-i386 -m elf_i386';{$endif}
|
|
|
-{$ifdef x86_64} platform_select='-b elf64-x86-64 -m elf_x86_64';{$endif}
|
|
|
-{$ifdef powerpc} platform_select='-b elf32-powerpc -m elf32ppclinux';{$endif}
|
|
|
-{$ifdef POWERPC64} platform_select='';{$endif}
|
|
|
-{$ifdef sparc} platform_select='-b elf32-sparc -m elf32_sparc';{$endif}
|
|
|
-{$ifdef sparc64} platform_select='-b elf64-sparc -m elf64_sparc';{$endif}
|
|
|
-{$ifdef arm} platform_select='';{$endif} {unknown :( }
|
|
|
-{$ifdef aarch64} platform_select='';{$endif} {unknown :( }
|
|
|
-{$ifdef m68k} platform_select='';{$endif} {unknown :( }
|
|
|
+var
|
|
|
+ target_opt: string;
|
|
|
+ emulation_opt: string;
|
|
|
+ platformopt: string;
|
|
|
+ LdProgram: string;
|
|
|
+begin
|
|
|
+ target_opt:='';
|
|
|
+ emulation_opt:='';
|
|
|
+ platformopt:='';
|
|
|
+ LdProgram:='';
|
|
|
+{$ifdef i386}
|
|
|
+ target_opt:=' -b elf32-i386';
|
|
|
+ emulation_opt:=' -m elf_i386';
|
|
|
+{$endif}
|
|
|
+{$ifdef x86_64}
|
|
|
+ target_opt:=' -b elf64-x86-64';
|
|
|
+ emulation_opt:=' -m elf_x86_64';
|
|
|
+{$endif}
|
|
|
+{$ifdef powerpc}
|
|
|
+ target_opt:=' -b elf32-powerpc';
|
|
|
+ emulation_opt:=' -m elf32ppclinux';
|
|
|
+{$endif}
|
|
|
+{$ifdef sparc}
|
|
|
+ target_opt:=' -b elf32-sparc';
|
|
|
+ emulation_opt:=' -m elf32_sparc';
|
|
|
+{$endif}
|
|
|
+{$ifdef sparc64}
|
|
|
+ target_opt:=' -b elf64-sparc';
|
|
|
+ emulation_opt:=' -m elf64_sparc';
|
|
|
+{$endif}
|
|
|
+{$ifdef arm} target_opt='';{$endif} {unknown :( }
|
|
|
+{$ifdef aarch64} target_opt='';{$endif} {unknown :( }
|
|
|
+{$ifdef m68k} target_opt='';{$endif} {unknown :( }
|
|
|
{$ifdef mips}
|
|
|
{$ifdef mipsel}
|
|
|
- platform_select='-EL';
|
|
|
+ platformopt:=' -EL';
|
|
|
{$else}
|
|
|
- platform_select='-EB';
|
|
|
+ platformopt:=' -EB';
|
|
|
{$endif}
|
|
|
{$endif}
|
|
|
-{$ifdef riscv32} platform_select='-m elf32lriscv';{$endif}
|
|
|
-{$ifdef riscv64} platform_select='-m elf64lriscv';{$endif}
|
|
|
-{$ifdef xtensa} platform_select='';{$endif}
|
|
|
-{$ifdef loongarch64} platform_select='';{$endif}
|
|
|
+{$ifdef riscv32}
|
|
|
+ target_opt=' -m elf32lriscv';
|
|
|
+{$endif}
|
|
|
+{$ifdef riscv64}
|
|
|
+ target_opt=' -m elf64lriscv';
|
|
|
+{$endif}
|
|
|
+{$ifdef loongarch64}
|
|
|
+ target_opt='';
|
|
|
+{$endif}
|
|
|
|
|
|
-var
|
|
|
- platformopt: string;
|
|
|
-begin
|
|
|
- platformopt:='';
|
|
|
{$ifdef powerpc64}
|
|
|
if (target_info.abi=abi_powerpc_elfv2) and
|
|
|
(target_info.endian=endian_little) then
|
|
|
- platformopt:=' -b elf64-powerpcle -m elf64lppc'
|
|
|
+ begin
|
|
|
+ target_opt:=' -b elf64-powerpcle';
|
|
|
+ emulation_opt:=' -m elf64lppc';
|
|
|
+ end;
|
|
|
else
|
|
|
- platformopt:=' -b elf64-powerpc -m elf64ppc';
|
|
|
+ begin
|
|
|
+ target_opt:=' -b elf64-powerpc';
|
|
|
+ emulation_opt:=' -m elf64ppc';
|
|
|
+ end;
|
|
|
{$endif powerpc64}
|
|
|
{$ifdef xtensa}
|
|
|
if target_info.endian=endian_little then
|
|
|
- platformopt:=' -b elf32-xtensa-le -m elf32xtensa'
|
|
|
+ begin
|
|
|
+ target_opt:=' -b elf32-xtensa-le';
|
|
|
+ emulation_opt:=' -m elf32xtensa';
|
|
|
+ end
|
|
|
else
|
|
|
- platformopt:=' -b elf32-xtensa-be -m elf32xtensa';
|
|
|
+ begin
|
|
|
+ target_opt:=' -b elf32-xtensa-be';
|
|
|
+ emluation_opt:=' -m elf32xtensa';
|
|
|
+ end;
|
|
|
if target_info.abi=abi_xtensa_call0 then
|
|
|
platformopt:=platformopt+' --abi-call0'
|
|
|
else if target_info.abi=abi_xtensa_windowed then
|
|
@@ -456,11 +491,18 @@ begin
|
|
|
{$ifdef arm}
|
|
|
platformopt:=' -z noexecstack';
|
|
|
{$endif arm}
|
|
|
+ if cs_link_lld in current_settings.globalswitches then
|
|
|
+ begin
|
|
|
+ LdProgram:='ld.lld';
|
|
|
+ target_opt:=' -b elf';
|
|
|
+ end
|
|
|
+ else
|
|
|
+ LdProgram:='ld';
|
|
|
|
|
|
with Info do
|
|
|
begin
|
|
|
- ExeCmd[1]:='ld '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $LTO $RPATH -L. -o $EXE';
|
|
|
- DllCmd[1]:='ld '+platform_select+platformopt+' $OPT $INIT $FINI $SONAME $MAP $LTO $RPATH -shared $GCSECTIONS -L. -o $EXE';
|
|
|
+ ExeCmd[1]:=LdProgram+target_opt+emulation_opt+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $LTO $RPATH -L. -o $EXE';
|
|
|
+ DllCmd[1]:=LdProgram+target_opt+emulation_opt+platformopt+' $OPT $INIT $FINI $SONAME $MAP $LTO $RPATH -shared $GCSECTIONS -L. -o $EXE';
|
|
|
{ when we want to cross-link we need to override default library paths;
|
|
|
when targeting binutils 2.19 or later, we use the "INSERT" command to
|
|
|
augment the default linkerscript, which also requires -T (normally that
|