summaryrefslogtreecommitdiff
path: root/compiler/systems
diff options
context:
space:
mode:
authorjonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2>2015-01-21 23:28:34 +0000
committerjonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2>2015-01-21 23:28:34 +0000
commit1903b037de2fb3e75826406b46f055acb70963fa (patch)
tree604cd8b790fe14e5fbe441d4cd647c80d2a36a9a /compiler/systems
parentad1141d52f8353457053b925cd674fe1d5c4eafc (diff)
parent953d907e4d6c3a5c2f8aaee6e5e4f73c55ce5985 (diff)
downloadfpc-blocks.tar.gz
* synchronised with trunk till r29513blocks
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/blocks@29516 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/systems')
-rw-r--r--compiler/systems/i_aros.pas169
-rw-r--r--compiler/systems/i_bsd.pas73
-rw-r--r--compiler/systems/i_linux.pas5
-rw-r--r--compiler/systems/i_nativent.pas2
-rw-r--r--compiler/systems/t_aix.pas23
-rw-r--r--compiler/systems/t_amiga.pas1
-rw-r--r--compiler/systems/t_aros.pas304
-rw-r--r--compiler/systems/t_bsd.pas9
-rw-r--r--compiler/systems/t_gba.pas1
-rw-r--r--compiler/systems/t_linux.pas1
-rw-r--r--compiler/systems/t_morph.pas2
-rw-r--r--compiler/systems/t_nds.pas142
-rw-r--r--compiler/systems/t_os2.pas8
-rw-r--r--compiler/systems/t_sunos.pas4
14 files changed, 652 insertions, 92 deletions
diff --git a/compiler/systems/i_aros.pas b/compiler/systems/i_aros.pas
new file mode 100644
index 0000000000..1e6262481d
--- /dev/null
+++ b/compiler/systems/i_aros.pas
@@ -0,0 +1,169 @@
+{
+ Copyright (c) 1998-2002 by Peter Vreman
+
+ This unit implements support information structures for arosOS
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ****************************************************************************
+}
+{ This unit implements support information structures for the arosOS. }
+unit i_aros;
+
+{$i fpcdefs.inc}
+
+ interface
+
+ uses
+ systems;
+
+ const
+ system_i386_aros_info : tsysteminfo =
+ (
+ system : system_i386_aros;
+ name : 'AROS for i386';
+ shortname : 'aros';
+ flags : [tf_files_case_aware, tf_smartlink_library, tf_has_winlike_resources];
+ cpu : cpu_i386;
+ unit_env : '';
+ extradefines : 'HASAMIGA';
+ exeext : '';
+ defext : '.def';
+ scriptext : '.sh';
+ smartext : '.sl';
+ unitext : '.ppu';
+ unitlibext : '.ppl';
+ asmext : '.s';
+ objext : '.o';
+ resext : '.res';
+ resobjext : '.or';
+ sharedlibext : '.library';
+ staticlibext : '.a';
+ staticlibprefix : 'libp';
+ sharedlibprefix : '';
+ sharedClibext : '.library';
+ staticClibext : '.a';
+ staticClibprefix : 'lib';
+ sharedClibprefix : '';
+ importlibprefix : 'libimp';
+ importlibext : '.a';
+ Cprefix : '';
+ newline : #10;
+ dirsep : '/';
+ assem : as_i386_elf32;
+ assemextern : as_gas;
+ link : ld_none;
+ linkextern : ld_aros;
+ ar : ar_gnu_ar;
+ res : res_elf;
+ dbg : dbg_stabs;
+ script : script_amiga;
+ endian : endian_little;
+ alignment :
+ (
+ procalign : 16;
+ loopalign : 4;
+ jumpalign : 0;
+ constalignmin : 0;
+ constalignmax : 8;
+ varalignmin : 0;
+ varalignmax : 16;
+ localalignmin : 0;
+ localalignmax : 4;
+ recordalignmin : 0;
+ recordalignmax : 16;
+ maxCrecordalign : 4
+ );
+ first_parm_offset : 8;
+ stacksize : 262144;
+ stackalign : 4;
+ abi : abi_default;
+ );
+
+ system_x86_64_aros_info : tsysteminfo =
+ (
+ system : system_x86_64_aros;
+ name : 'AROS for x86_64';
+ shortname : 'aros';
+ flags : [tf_files_case_aware];
+ cpu : cpu_x86_64;
+ unit_env : '';
+ extradefines : 'HASAMIGA';
+ exeext : '';
+ defext : '.def';
+ scriptext : '.sh';
+ smartext : '.sl';
+ unitext : '.ppu';
+ unitlibext : '.ppl';
+ asmext : '.s';
+ objext : '.o';
+ resext : '.res';
+ resobjext : '.or';
+ sharedlibext : '.library';
+ staticlibext : '.a';
+ staticlibprefix : 'libp';
+ sharedlibprefix : '';
+ sharedClibext : '.library';
+ staticClibext : '.a';
+ staticClibprefix : 'lib';
+ sharedClibprefix : '';
+ importlibprefix : 'libimp';
+ importlibext : '.a';
+ Cprefix : '';
+ newline : #10;
+ dirsep : '/';
+ assem : as_x86_64_elf64;
+ assemextern : as_gas;
+ link : ld_none;
+ linkextern : ld_aros;
+ ar : ar_gnu_ar;
+ res : res_none;
+ dbg : dbg_stabs;
+ script : script_amiga;
+ endian : endian_little;
+ alignment :
+ (
+ procalign : 8;
+ loopalign : 4;
+ jumpalign : 0;
+ constalignmin : 0;
+ constalignmax : 8;
+ varalignmin : 0;
+ varalignmax : 16;
+ localalignmin : 4;
+ localalignmax : 16;
+ recordalignmin : 0;
+ recordalignmax : 16;
+ maxCrecordalign : 16
+ );
+ first_parm_offset : 16;
+ stacksize : 8*1024*1024;
+ stackalign : 16; { fix me: this is a wild guess for now (KB) }
+ abi : abi_default;
+ );
+
+ implementation
+
+initialization
+{$ifdef CPU86}
+ {$ifdef aros}
+ set_source_info(system_i386_aros_info);
+ {$endif aros}
+{$endif CPU86}
+{$ifdef CPUX86_64}
+ {$ifdef AROS}
+ set_source_info(system_x86_64_aros_info);
+ {$endif AROS}
+{$endif CPUX86_64}
+end.
diff --git a/compiler/systems/i_bsd.pas b/compiler/systems/i_bsd.pas
index 90264afcf0..c9072cc4d8 100644
--- a/compiler/systems/i_bsd.pas
+++ b/compiler/systems/i_bsd.pas
@@ -188,6 +188,72 @@ unit i_bsd;
);
+ system_x86_64_dragonfly_info : tsysteminfo =
+ (
+ system : system_x86_64_dragonfly;
+ name : 'DragonFly for x86-64';
+ shortname : 'DragonFly';
+ flags : [tf_needs_symbol_size,tf_needs_dwarf_cfi,tf_library_needs_pic,tf_needs_symbol_type,
+ tf_files_case_sensitive,tf_smartlink_library,
+ tf_dwarf_only_local_labels,
+ {tf_pic_uses_got,}tf_smartlink_sections,tf_has_winlike_resources];
+ cpu : cpu_x86_64;
+ unit_env : 'BSDUNITS';
+ extradefines : 'UNIX;HASUNIX;BSD';
+ exeext : '';
+ defext : '.def';
+ scriptext : '.sh';
+ smartext : '.sl';
+ unitext : '.ppu';
+ unitlibext : '.ppl';
+ asmext : '.s';
+ objext : '.o';
+ resext : '.res';
+ resobjext : '.or';
+ sharedlibext : '.so';
+ staticlibext : '.a';
+ staticlibprefix : 'libp';
+ sharedlibprefix : 'lib';
+ sharedClibext : '.so';
+ staticClibext : '.a';
+ staticClibprefix : 'lib';
+ sharedClibprefix : 'lib';
+ importlibprefix : 'libimp';
+ importlibext : '.a';
+ Cprefix : '';
+ newline : #10;
+ dirsep : '/';
+ assem : as_x86_64_elf64;
+ assemextern : as_gas;
+ link : ld_none;
+ linkextern : ld_bsd;
+ ar : ar_gnu_ar;
+ res : res_elf;
+ dbg : dbg_dwarf2; //dbg_stabs;
+ script : script_unix;
+ endian : endian_little;
+ alignment :
+ (
+ procalign : 8;
+ loopalign : 4;
+ jumpalign : 0;
+ constalignmin : 0;
+ constalignmax : 8;
+ varalignmin : 0;
+ varalignmax : 16;
+ localalignmin : 4;
+ localalignmax : 16;
+ recordalignmin : 0;
+ recordalignmax : 16;
+ maxCrecordalign : 16
+ );
+ first_parm_offset : 16;
+ stacksize : 256*1024;
+ stackalign : 16;
+ abi : abi_default;
+ );
+
+
system_i386_netbsd_info : tsysteminfo =
(
system : system_i386_NetBSD;
@@ -255,7 +321,7 @@ unit i_bsd;
system : system_i386_OpenBSD;
name : 'OpenBSD for i386';
shortname : 'OpenBSD';
- flags : [tf_pic_uses_got,tf_under_development,tf_files_case_sensitive,tf_smartlink_library,tf_has_winlike_resources];
+ flags : [tf_pic_uses_got,tf_under_development,tf_files_case_sensitive,tf_smartlink_library,tf_smartlink_sections,tf_has_winlike_resources];
cpu : cpu_i386;
unit_env : 'BSDUNITS';
extradefines : 'UNIX;BSD;HASUNIX';
@@ -319,7 +385,7 @@ unit i_bsd;
shortname : 'OpenBSD';
flags : [tf_needs_symbol_size,tf_needs_dwarf_cfi,tf_library_needs_pic,tf_needs_symbol_type,
tf_files_case_sensitive,tf_smartlink_library, tf_under_development,
- tf_dwarf_only_local_labels,
+ tf_dwarf_only_local_labels, tf_pic_default,
{ tf_pic_uses_got,}tf_smartlink_sections,tf_has_winlike_resources];
cpu : cpu_x86_64;
unit_env : 'BSDUNITS';
@@ -969,6 +1035,9 @@ initialization
{$ifdef FreeBSD}
set_source_info(system_x86_64_FreeBSD_info);
{$endif}
+ {$ifdef DragonFly}
+ set_source_info(system_x86_64_DragonFly_info);
+ {$endif}
{$ifdef OpenBSD}
set_source_info(system_x86_64_OpenBSD_info);
{$endif}
diff --git a/compiler/systems/i_linux.pas b/compiler/systems/i_linux.pas
index 5316dd9236..258bf2815e 100644
--- a/compiler/systems/i_linux.pas
+++ b/compiler/systems/i_linux.pas
@@ -167,6 +167,7 @@ unit i_linux;
name : 'Linux for m68k';
shortname : 'Linux';
flags : [tf_needs_symbol_size,tf_needs_symbol_type,tf_files_case_sensitive,
+ tf_smartlink_sections,
tf_requires_proper_alignment, { Coldfire seems to need this at least (KB) }
tf_smartlink_library,tf_has_winlike_resources];
cpu : cpu_m68k;
@@ -816,7 +817,7 @@ unit i_linux;
name : 'Linux for MIPSEB';
shortname : 'Linux';
flags : [tf_needs_symbol_size,tf_needs_symbol_type,tf_files_case_sensitive,
- tf_requires_proper_alignment,
+ tf_requires_proper_alignment,tf_pic_uses_got,tf_safecall_exceptions,
tf_smartlink_sections,tf_smartlink_library,tf_has_winlike_resources];
cpu : cpu_mipseb;
unit_env : 'LINUXUNITS';
@@ -881,7 +882,7 @@ unit i_linux;
name : 'Linux for MIPSEL';
shortname : 'Linux';
flags : [tf_needs_symbol_size,tf_needs_symbol_type,tf_files_case_sensitive,
- tf_requires_proper_alignment,
+ tf_requires_proper_alignment,tf_pic_uses_got,tf_safecall_exceptions,
tf_smartlink_sections,tf_smartlink_library,tf_has_winlike_resources];
cpu : cpu_mipsel;
unit_env : 'LINUXUNITS';
diff --git a/compiler/systems/i_nativent.pas b/compiler/systems/i_nativent.pas
index 325257efb9..02a05775c0 100644
--- a/compiler/systems/i_nativent.pas
+++ b/compiler/systems/i_nativent.pas
@@ -42,7 +42,7 @@ unit i_nativent;
tf_dwarf_only_local_labels];
cpu : cpu_i386;
unit_env : 'NTUNITS';
- extradefines : 'NATIVENT,FPC_OS_UNICODE';
+ extradefines : 'NATIVENT;FPC_OS_UNICODE';
exeext : '.exe';
defext : '.def';
scriptext : '.bat';
diff --git a/compiler/systems/t_aix.pas b/compiler/systems/t_aix.pas
index beb6eec417..0d26dbca1d 100644
--- a/compiler/systems/t_aix.pas
+++ b/compiler/systems/t_aix.pas
@@ -43,6 +43,7 @@ interface
TLinkerAIX=class(texternallinker)
private
prtobj : string[80];
+ assumebinutils,use_gld : boolean;
Function WriteResponseFile(isdll:boolean) : Boolean;
public
constructor Create;override;
@@ -51,7 +52,6 @@ interface
function MakeSharedLibrary:boolean;override;
end;
-
implementation
uses
@@ -117,8 +117,8 @@ begin
sure that the binary does not contain any relocations in the text
section (otherwise you get an error at load time instead of at link time
in case something is wrong) }
- ExeCmd[1]:='ld -bpT:0x10000000 -bpD:0x20000000 -btextro $OPT $STRIP -L. -o $EXE $CATRES' {$ifdef powerpc64}+' -b64'{$endif};
- DllCmd[1]:='ld -bpT:0x10000000 -bpD:0x20000000 -btextro $OPT $INITFINI $STRIP -G -L. -o $EXE $CATRES' {$ifdef powerpc64}+' -b64'{$endif};
+ ExeCmd[1]:='$LDBIN -bpT:0x10000000 -bpD:0x20000000 -btextro $OPT $STRIP -L. -o $EXE $CATRES' {$ifdef powerpc64}+' -b64'{$endif};
+ DllCmd[1]:='$LDBIN -bpT:0x10000000 -bpD:0x20000000 -btextro $OPT $INITFINI $STRIP -G -L. -o $EXE $CATRES' {$ifdef powerpc64}+' -b64'{$endif};
if cs_debuginfo in current_settings.moduleswitches then
begin
{ debugging helpers }
@@ -139,6 +139,11 @@ begin
{$else}
{$error unsupported AIX architecture}
{$endif}
+ assumebinutils:=
+ not(cs_link_native in current_settings.globalswitches) or
+ (not(cs_link_on_target in current_settings.globalswitches) and
+ not(source_info.system in systems_aix)) ;
+ use_gld:=assumebinutils and (source_info.system in systems_aix)
end;
@@ -148,12 +153,8 @@ Var
i : longint;
HPath : TCmdStrListItem;
s,s1 : TCmdStr;
- assumebinutils : boolean;
begin
result:=False;
- assumebinutils:=
- not(cs_link_on_target in current_settings.globalswitches) and
- not(source_info.system in systems_aix) ;
{ Open link.res file }
LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,assumebinutils);
with linkres do
@@ -261,6 +262,10 @@ begin
{ Call linker }
SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
+ if assumebinutils and (source_info.system in systems_aix) then
+ Replace(binstr,'$LDBIN','gld')
+ else
+ Replace(binstr,'$LDBIN','ld');
binstr:=FindUtil(utilsprefix+BinStr);
Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
Replace(cmdstr,'$OPT',Info.ExtraOptions);
@@ -351,6 +356,10 @@ begin
{ Call linker }
SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
+ if assumebinutils and (source_info.system in systems_aix) then
+ Replace(binstr,'$LDBIN','gld')
+ else
+ Replace(binstr,'$LDBIN','ld');
binstr:=FindUtil(utilsprefix+BinStr);
{ on AIX, shared libraries are special object files that are stored inside
an archive. In that archive, the 32 bit version of the library is called
diff --git a/compiler/systems/t_amiga.pas b/compiler/systems/t_amiga.pas
index f7f0c53ea4..3976db7cb2 100644
--- a/compiler/systems/t_amiga.pas
+++ b/compiler/systems/t_amiga.pas
@@ -257,6 +257,7 @@ begin
{ Write used files and libraries }
WriteResponseFile(false);
+ success:=false;
case (target_info.system) of
system_m68k_amiga: success:=MakeAmiga68kExe;
system_powerpc_amiga: success:=MakeAmigaPPCExe;
diff --git a/compiler/systems/t_aros.pas b/compiler/systems/t_aros.pas
new file mode 100644
index 0000000000..06ebc47676
--- /dev/null
+++ b/compiler/systems/t_aros.pas
@@ -0,0 +1,304 @@
+{
+ Copyright (c) 2004-2006 by Free Pascal Development Team
+
+ This unit implements support import, export, link routines
+ for the aros targets (arosOS/i386, arosOS/x86_64)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit t_aros;
+
+{$i fpcdefs.inc}
+
+interface
+
+ uses
+ rescmn, comprsrc, import, export, link, ogbase;
+
+
+type
+
+ timportlibaros=class(timportlib)
+ procedure generatelib; override;
+ end;
+
+
+ PLinkeraros = ^TLinkeraros;
+ TLinkeraros = class(texternallinker)
+ private
+ function WriteResponseFile(isdll: boolean): boolean;
+ procedure Setaros386Info;
+ procedure Setarosx86_64Info;
+ function Makearos386Exe: boolean;
+ function Makearosx86_64Exe: boolean;
+ public
+ constructor Create; override;
+ procedure SetDefaultInfo; override;
+ function MakeExecutable: boolean; override;
+ end;
+
+
+implementation
+
+ uses
+ SysUtils,
+ cutils,cfileutl,cclasses,
+ globtype,globals,systems,verbose,script,fmodule,i_aros;
+
+
+procedure timportlibaros.generatelib;
+var
+ i: longint;
+ ImportLibrary: TImportLibrary;
+begin
+ for i:=0 to current_module.ImportLibraryList.count -1 do
+ begin
+ ImportLibrary := TImportlibrary(current_module.ImportLibraryList[i]);
+ current_module.linkothersharedlibs.add(ImportLibrary.Name, link_always);
+ end;
+end;
+
+{****************************************************************************
+ TLinkeraros
+****************************************************************************}
+
+
+
+constructor TLinkeraros.Create;
+begin
+ Inherited Create;
+ { allow duplicated libs (PM) }
+ SharedLibFiles.doubles:=true;
+ StaticLibFiles.doubles:=true;
+end;
+
+procedure TLinkeraros.Setaros386Info;
+begin
+ with Info do begin
+ { Note: collect-aros seems to be buggy, and doesn't forward options }
+ { properly when calling the underlying GNU LD. (FIXME?) }
+ { This means paths with spaces in them are not supported for now on AROS. }
+ { So for example no Ram Disk: usage for anything which must be linked. (KB) }
+ ExeCmd[1]:='collect-aros $OPT $STRIP -d -n -o $EXE $RES';
+ //ExeCmd[1]:='ld $OPT -d -n -o $EXE $RES';
+ end;
+end;
+
+procedure TLinkeraros.Setarosx86_64Info;
+begin
+ with Info do begin
+ ExeCmd[1]:='ld $OPT -defsym=__AROS__=1 -d -q -n -o $EXE $RES';
+ end;
+end;
+
+procedure TLinkeraros.SetDefaultInfo;
+begin
+ case (target_info.system) of
+ system_i386_aros: Setaros386Info;
+ system_x86_64_aros: Setarosx86_64Info;
+ end;
+end;
+
+
+function TLinkeraros.WriteResponseFile(isdll: boolean): boolean;
+var
+ linkres : TLinkRes;
+ i : longint;
+ HPath : TCmdStrListItem;
+ s,s1 : string;
+ linklibc : boolean;
+begin
+ WriteResponseFile:=False;
+
+ { Open link.res file }
+ LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
+
+ { Write path to search libraries }
+ HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
+ while assigned(HPath) do
+ begin
+ s:=HPath.Str;
+ if (cs_link_on_target in current_settings.globalswitches) then
+ s:=ScriptFixFileName(s);
+ LinkRes.Add('-L'+s);
+ HPath:=TCmdStrListItem(HPath.Next);
+ end;
+ HPath:=TCmdStrListItem(LibrarySearchPath.First);
+ while assigned(HPath) do
+ begin
+ s:=HPath.Str;
+ s1 := Unix2AmigaPath(maybequoted(s));
+ if trim(s1)<>'' then
+ LinkRes.Add('SEARCH_DIR('+s1+')');
+ HPath:=TCmdStrListItem(HPath.Next);
+ end;
+
+ LinkRes.Add('INPUT (');
+ { add objectfiles, start with prt0 always }
+ s:=FindObjectFile('prt0','',false);
+ LinkRes.AddFileName(s);
+ while not ObjectFiles.Empty do
+ begin
+ s:=ObjectFiles.GetFirst;
+ if s<>'' then
+ begin
+ LinkRes.AddFileName(Unix2AmigaPath(maybequoted(s)));
+ end;
+ end;
+
+ { Write staticlibraries }
+ if not StaticLibFiles.Empty then
+ begin
+ LinkRes.Add(')');
+ LinkRes.Add('GROUP(');
+ while not StaticLibFiles.Empty do
+ begin
+ S:=StaticLibFiles.GetFirst;
+ LinkRes.AddFileName(Unix2AmigaPath(maybequoted(s)));
+ end;
+ end;
+
+ if (cs_link_on_target in current_settings.globalswitches) then
+ begin
+ LinkRes.Add(')');
+
+ { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
+ here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
+ linklibc:=false;
+ while not SharedLibFiles.Empty do
+ begin
+ S:=SharedLibFiles.GetFirst;
+ if s<>'c' then
+ begin
+ i:=Pos(target_info.sharedlibext,S);
+ if i>0 then
+ Delete(S,i,255);
+ LinkRes.Add('-l'+s);
+ end
+ else
+ begin
+ LinkRes.Add('-l'+s);
+ linklibc:=true;
+ end;
+ end;
+ { be sure that libc&libgcc is the last lib }
+ if linklibc then
+ begin
+ LinkRes.Add('-lc');
+ LinkRes.Add('-lgcc');
+ end;
+ end
+ else
+ begin
+ while not SharedLibFiles.Empty do
+ begin
+ S:=SharedLibFiles.GetFirst;
+ LinkRes.Add('lib'+s+target_info.staticlibext);
+ end;
+ LinkRes.Add(')');
+ end;
+
+{ Write and Close response }
+ linkres.writetodisk;
+ linkres.free;
+
+ WriteResponseFile:=True;
+end;
+
+
+function TLinkeraros.Makearos386Exe: boolean;
+var
+ BinStr,
+ CmdStr : TCmdStr;
+ StripStr: string[40];
+begin
+ StripStr:='';
+ if (cs_link_strip in current_settings.globalswitches) then StripStr:='-s';
+
+ { Call linker }
+ SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
+ Replace(cmdstr,'$OPT',Info.ExtraOptions);
+ Replace(cmdstr,'$EXE',maybequoted(ScriptFixFileName(current_module.exefilename)));
+ Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));
+ Replace(cmdstr,'$STRIP',StripStr);
+
+ { Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename^))));
+ Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));}
+
+ Makearos386Exe:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
+end;
+
+
+function TLinkeraros.Makearosx86_64Exe: boolean;
+var
+ BinStr,
+ CmdStr : TCmdStr;
+ StripStr: string[40];
+begin
+ StripStr:='';
+ if (cs_link_strip in current_settings.globalswitches) then StripStr:='-s';
+
+ { Call linker }
+ SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
+ binstr:=FindUtil(utilsprefix+BinStr);
+ Replace(cmdstr,'$OPT',Info.ExtraOptions);
+ Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename))));
+ Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
+ Replace(cmdstr,'$STRIP',StripStr);
+ Makearosx86_64Exe:=DoExec(FindUtil(BinStr),CmdStr,true,false);
+end;
+
+
+function TLinkeraros.MakeExecutable:boolean;
+var
+ success : boolean;
+begin
+ success:=false;
+ if not(cs_link_nolink in current_settings.globalswitches) then
+ Message1(exec_i_linking,current_module.exefilename);
+
+ { Write used files and libraries }
+ WriteResponseFile(false);
+
+ case (target_info.system) of
+ system_i386_aros: success:=Makearos386Exe;
+ system_x86_64_aros: success:=Makearosx86_64Exe;
+ end;
+
+ { Remove ReponseFile }
+ if (success) and not(cs_link_nolink in current_settings.globalswitches) then
+ DeleteFile(outputexedir+Info.ResName);
+
+ MakeExecutable:=success; { otherwise a recursive call to link method }
+end;
+
+
+{*****************************************************************************
+ Initialize
+*****************************************************************************}
+
+initialization
+{$ifdef i386}
+ RegisterLinker(ld_aros,TLinkeraros);
+ RegisterTarget(system_i386_aros_info);
+{$endif i386}
+{$ifdef x86_64}
+ RegisterLinker(ld_aros,TLinkeraros);
+ RegisterTarget(system_x86_64_aros_info);
+{$endif x86_64}
+ RegisterRes(res_elf_info, TWinLikeResourceFile);
+end.
diff --git a/compiler/systems/t_bsd.pas b/compiler/systems/t_bsd.pas
index 911fcd0e08..b35a78aecb 100644
--- a/compiler/systems/t_bsd.pas
+++ b/compiler/systems/t_bsd.pas
@@ -695,6 +695,12 @@ begin
else
DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
end;
+
+{ Use -nopie on OpenBSD }
+ if (target_info.system in systems_openbsd) and
+ (target_info.system <> system_x86_64_openbsd) then
+ Info.ExtraOptions:=Info.ExtraOptions+' -nopie';
+
{ Write used files and libraries }
WriteResponseFile(false);
@@ -912,6 +918,9 @@ end;
initialization
RegisterLinker(ld_bsd,TLinkerBSD);
{$ifdef x86_64}
+ RegisterImport(system_x86_64_dragonfly,timportlibbsd);
+ RegisterExport(system_x86_64_dragonfly,texportlibbsd);
+ RegisterTarget(system_x86_64_dragonfly_info);
RegisterImport(system_x86_64_freebsd,timportlibbsd);
RegisterExport(system_x86_64_freebsd,texportlibbsd);
RegisterTarget(system_x86_64_freebsd_info);
diff --git a/compiler/systems/t_gba.pas b/compiler/systems/t_gba.pas
index 2dee4d83ea..06d23d2a9b 100644
--- a/compiler/systems/t_gba.pas
+++ b/compiler/systems/t_gba.pas
@@ -571,6 +571,7 @@ begin
StripStr:='';
DynLinkStr:='';
MapStr:='';
+ GCSectionsStr:='';
if (cs_link_strip in current_settings.globalswitches) and
not(cs_link_separate_dbg_file in current_settings.globalswitches) then
diff --git a/compiler/systems/t_linux.pas b/compiler/systems/t_linux.pas
index dd43499fd3..bebd8f7e04 100644
--- a/compiler/systems/t_linux.pas
+++ b/compiler/systems/t_linux.pas
@@ -146,6 +146,7 @@ begin
{$endif}
{$endif arm}
{$ifdef x86_64}
+ if not Dontlinkstdlibpath Then
LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/x86_64-linux-gnu',true);
{$endif x86_64}
end;
diff --git a/compiler/systems/t_morph.pas b/compiler/systems/t_morph.pas
index fedd5c329c..c79d6583f8 100644
--- a/compiler/systems/t_morph.pas
+++ b/compiler/systems/t_morph.pas
@@ -205,13 +205,13 @@ var
success : boolean;
StripStr: string[40];
begin
+ StripStr:='';
if not(cs_link_nolink in current_settings.globalswitches) then
Message1(exec_i_linking,current_module.exefilename);
if UseVLink then
begin
- StripStr:='';
if (cs_link_strip in current_settings.globalswitches) then
StripStr:='-s -P __abox__';
end;
diff --git a/compiler/systems/t_nds.pas b/compiler/systems/t_nds.pas
index 16eab29b5e..93828c28aa 100644
--- a/compiler/systems/t_nds.pas
+++ b/compiler/systems/t_nds.pas
@@ -82,12 +82,14 @@ Var
linklibc,
linklibgcc : boolean;
found1,
- found2 : boolean;
+ found2 : boolean;
begin
WriteResponseFile:=False;
linklibc:=(SharedLibFiles.Find('c')<>nil);
linklibgcc:=(SharedLibFiles.Find('gcc')<>nil);
-
+
+ prtobj:='';
+ cprtobj:='';
case apptype of
app_arm9:
begin
@@ -243,20 +245,19 @@ begin
begin
if apptype=app_arm9 then //ARM9
begin
- add('OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")');
- add('OUTPUT_ARCH(arm)');
- add('ENTRY(_start)');
- add('');
add('MEMORY {');
- add('');
add(' rom : ORIGIN = 0x08000000, LENGTH = 32M');
add(' ewram : ORIGIN = 0x02000000, LENGTH = 4M - 4k');
add(' dtcm : ORIGIN = 0x0b000000, LENGTH = 16K');
- add(' vectors : ORIGIN = 0x01000000, LENGTH = 256');
- add(' itcm : ORIGIN = 0x01000100, LENGTH = 32K - 256');
+ add(' vectors : ORIGIN = 0x01000000, LENGTH = 256');
+ add(' itcm : ORIGIN = 0x01000100, LENGTH = 32K - 256');
add('}');
add('');
- add('__vectors_start = ORIGIN(vectors);');
+ add('OUTPUT_ARCH(arm)');
+ add('OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")');
+ add('ENTRY(_start)');
+ add('');
+ add('__vectors_start = ORIGIN(vectors);');
add('__itcm_start = ORIGIN(itcm);');
add('__ewram_end = ORIGIN(ewram) + LENGTH(ewram);');
add('__eheap_end = ORIGIN(ewram) + LENGTH(ewram);');
@@ -276,7 +277,7 @@ begin
add(' __text_start = . ;');
add(' KEEP (*(.init))');
add(' . = ALIGN(4); /* REQUIRED. LD is flaky without it. */');
- add(' } >ewram = 0xff');
+ add(' } >ewram = 0xff');
add('');
add(' .plt : { *(.plt) } >ewram = 0xff');
add('');
@@ -312,36 +313,40 @@ begin
add(' . = ALIGN(4); /* REQUIRED. LD is flaky without it. */');
add(' } >ewram = 0xff');
add('');
- add(' .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ewram');
- add(' __exidx_start = .;');
- add(' .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ewram');
- add(' __exidx_end = .;');
- add(' /* Ensure the __preinit_array_start label is properly aligned. We');
- add(' could instead move the label definition inside the section, but');
- add(' the linker would then create the section even if it turns out to');
- add(' be empty, which isn''t pretty. */');
- add(' . = ALIGN(32 / 8);');
- add(' PROVIDE (__preinit_array_start = .);');
- add(' .preinit_array : { KEEP (*(.preinit_array)) } >ewram = 0xff');
- add(' PROVIDE (__preinit_array_end = .);');
- add(' PROVIDE (__init_array_start = .);');
- add(' .init_array :');
- add(' {');
- add(' KEEP (*(SORT(.init_array.*)))');
- add(' KEEP (*(.init_array))');
- add(' } >ewram = 0xff');
- add(' PROVIDE (__init_array_end = .);');
- add(' PROVIDE (__fini_array_start = .);');
- add(' .fini_array :');
- add(' {');
- add(' KEEP (*(.fini_array))');
- add(' KEEP (*(SORT(.fini_array.*)))');
- add(' } >ewram = 0xff');
- add(' PROVIDE (__fini_array_end = .);');
+ add(' .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ewram');
+ add(' __exidx_start = .;');
+ add(' ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ewram');
+ add(' __exidx_end = .;');
+ add('');
+ add(' /* Ensure the __preinit_array_start label is properly aligned. We');
+ add(' could instead move the label definition inside the section, but');
+ add(' the linker would then create the section even if it turns out to');
+ add(' be empty, which isn''t pretty. */');
+ add('');
+ add(' . = ALIGN(32 / 8);');
+ add('');
+ add(' PROVIDE (__preinit_array_start = .);');
+ add(' .preinit_array : { KEEP (*(.preinit_array)) } >ewram = 0xff');
+ add(' PROVIDE (__preinit_array_end = .);');
+ add(' PROVIDE (__init_array_start = .);');
+ add(' .init_array :');
+ add(' {');
+ add(' KEEP (*(SORT(.init_array.*)))');
+ add(' KEEP (*(.init_array))');
+ add(' } >ewram = 0xff');
+ add(' PROVIDE (__init_array_end = .);');
+ add(' PROVIDE (__fini_array_start = .);');
+ add(' .fini_array :');
+ add(' {');
+ add(' KEEP (*(.fini_array))');
+ add(' KEEP (*(SORT(.fini_array.*)))');
+ add(' } >ewram = 0xff');
+ add('');
+ add(' PROVIDE (__fini_array_end = .);');
add('');
add(' .ctors :');
add(' {');
- add(' /* gcc uses crtbegin.o to find the start of the constructors, so');
+ add(' /* gcc uses crtbegin.o to find the start of the constructors, so');
add(' we make sure it is first. Because this is a wildcard, it');
add(' doesn''t matter if the user does not actually link against');
add(' crtbegin.o; the linker won''t look for a file to match a');
@@ -392,7 +397,6 @@ begin
add(' *(.data)');
add(' *(.data.*)');
add(' *(.gnu.linkonce.d*)');
- add(' *(.fpc*)');
add(' CONSTRUCTORS');
add(' . = ALIGN(4);');
add(' __data_end = ABSOLUTE(.) ;');
@@ -408,7 +412,7 @@ begin
add(' *(.dtcm.*)');
add(' . = ALIGN(4);');
add(' __dtcm_end = ABSOLUTE(.);');
- add(' } >dtcm = 0xff');
+ add(' } >dtcm = 0xff');
add('');
add('');
add(' __itcm_lma = __dtcm_lma + SIZEOF(.dtcm);');
@@ -420,29 +424,27 @@ begin
add(' . = ALIGN(4);');
add(' __itcm_end = ABSOLUTE(.);');
add(' } >itcm = 0xff');
+ add(' ');
+ add(' __vectors_lma = __itcm_lma + SIZEOF(.itcm);');
add('');
-
- add(' __vectors_lma = __itcm_lma + SIZEOF(.itcm);');
- add(' .vectors __vectors_start : AT (__vectors_lma)');
- add(' {');
- add(' *(.vectors)');
- add(' *vectors.*(.text)');
- add(' . = ALIGN(4);');
- add(' __vectors_end = ABSOLUTE(.);');
- add(' } >vectors = 0xff');
- add('');
- add(' .sbss __dtcm_end (NOLOAD):');
+ add(' .vectors __vectors_start : AT (__vectors_lma)');
+ add(' {');
+ add(' *(.vectors)');
+ add(' *vectors.*(.text)');
+ add(' . = ALIGN(4);');
+ add(' __vectors_end = ABSOLUTE(.);');
+ add(' } >vectors = 0xff');
+ add(' ');
+ add(' .sbss __dtcm_end (NOLOAD): ');
add(' {');
add(' __sbss_start = ABSOLUTE(.);');
add(' __sbss_start__ = ABSOLUTE(.);');
add(' *(.sbss)');
add(' . = ALIGN(4); /* REQUIRED. LD is flaky without it. */');
add(' __sbss_end = ABSOLUTE(.);');
- add(' } >dtcm');
- add('');
+ add(' } >dtcm ');
add('');
- add('');
- add(' .bss __bss_vma (NOLOAD):');
+ add(' .bss __bss_vma (NOLOAD): ');
add(' {');
add(' __bss_start = ABSOLUTE(.);');
add(' __bss_start__ = ABSOLUTE(.);');
@@ -453,7 +455,8 @@ begin
add(' . = ALIGN(4); /* REQUIRED. LD is flaky without it. */');
add(' __bss_end__ = ABSOLUTE(.) ;');
add(' __end__ = ABSOLUTE(.) ;');
- add(' } AT>ewram');
+ add(' } AT>ewram ');
+ add('');
add('');
add('');
add(' /* Stabs debugging sections. */');
@@ -492,6 +495,7 @@ begin
add(' .stack 0x80000 : { _stack = .; *(.stack) }');
add(' /* These must appear regardless of . */');
add('}');
+ add('');
end;
if apptype=app_arm7 then
begin
@@ -501,12 +505,13 @@ begin
add('');
add('MEMORY {');
add('');
- add(' rom : ORIGIN = 0x08000000, LENGTH = 32M');
- add(' iwram : ORIGIN = 0x037f8000, LENGTH = 96K');
+ add(' rom : ORIGIN = 0x08000000, LENGTH = 32M');
+ add(' iwram : ORIGIN = 0x037f8000, LENGTH = 96K ');
add('}');
add('');
add('__iwram_start = ORIGIN(iwram);');
add('__iwram_top = ORIGIN(iwram)+ LENGTH(iwram);');
+ add('');
add('__sp_irq = __iwram_top - 0x100;');
add('__sp_svc = __sp_irq - 0x100;');
add('__sp_usr = __sp_svc - 0x100;');
@@ -527,9 +532,8 @@ begin
add('');
add(' .text : /* ALIGN (4): */');
add(' {');
- add('');
- add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
- add(' KEEP (*(.text.*personality*))');
+ add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
+ add(' KEEP (*(.text.*personality*))');
add(' /* .gnu.warning sections are handled specially by elf32.em. */');
add(' *(.gnu.warning)');
add(' *(.glue_7t) *(.glue_7) *(.vfp11_veneer)');
@@ -612,30 +616,16 @@ begin
add(' .jcr : { KEEP (*(.jcr)) } >iwram = 0');
add(' .got : { *(.got.plt) *(.got) } >iwram = 0');
add('');
- add('');
- add(' .iwram ALIGN(4) :');
- add(' {');
- add(' __iwram_start = ABSOLUTE(.) ;');
- add(' *(.iwram)');
- add(' *iwram.*(.text)');
- add(' . = ALIGN(4); /* REQUIRED. LD is flaky without it. */');
- add(' __iwram_end = ABSOLUTE(.) ;');
- add(' } >iwram = 0xff');
- add('');
- add('');
add(' .data ALIGN(4) : {');
add(' __data_start = ABSOLUTE(.);');
add(' *(.data)');
add(' *(.data.*)');
add(' *(.gnu.linkonce.d*)');
- add(' *(.fpc*)');
add(' CONSTRUCTORS');
add(' . = ALIGN(4);');
add(' __data_end = ABSOLUTE(.) ;');
add(' } >iwram = 0xff');
add('');
- add('');
- add('');
add(' .bss ALIGN(4) :');
add(' {');
add(' __bss_start = ABSOLUTE(.);');
@@ -714,6 +704,8 @@ begin
StripStr:='';
MapStr:='';
DynLinkStr:='';
+ GCSectionsStr:='';
+ preName:='';
case apptype of
app_arm9: preName:='.nef';
app_arm7: preName:='.nlf';
diff --git a/compiler/systems/t_os2.pas b/compiler/systems/t_os2.pas
index 064169836c..f6d9f4d65b 100644
--- a/compiler/systems/t_os2.pas
+++ b/compiler/systems/t_os2.pas
@@ -396,7 +396,7 @@ begin
with Info do
begin
ExeCmd[1]:='ld $OPT -o $OUT @$RES';
- ExeCmd[2]:='emxbind -b $STRIP $MAP $APPTYPE $RSRC -k$STACKKB -h1 -o $EXE $OUT -ai -s8';
+ ExeCmd[2]:='emxbind -b $STRIP $MAP $APPTYPE $RSRC -k$STACKKB -h1 -q -o $EXE $OUT -ai -s8';
if Source_Info.Script = script_dos then
ExeCmd[3]:='del $OUT';
end;
@@ -533,7 +533,11 @@ begin
Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
*)
Replace(cmdstr,'$RES',outputexedir+Info.ResName);
- Replace(cmdstr,'$OPT ',Info.ExtraOptions);
+ if (Info.ExtraOptions <> '') and
+ (Info.ExtraOptions [Length (Info.ExtraOptions)] <> ' ') then
+ Replace(cmdstr,'$OPT',Info.ExtraOptions)
+ else
+ Replace(cmdstr,'$OPT ',Info.ExtraOptions);
Replace(cmdstr,'$RSRC ',RsrcStr);
Replace(cmdstr,'$OUT',maybequoted(OutName));
Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
diff --git a/compiler/systems/t_sunos.pas b/compiler/systems/t_sunos.pas
index 63788fd288..f369acaa77 100644
--- a/compiler/systems/t_sunos.pas
+++ b/compiler/systems/t_sunos.pas
@@ -143,12 +143,12 @@ procedure TLinkersolaris.SetDefaultInfo;
}
{$ifdef x86_64}
const
- gld = 'gld -m elf_x86_64 ';
+ gld = 'gld -m elf_x86_64_sol2 ';
solaris_ld = '/usr/bin/ld -64 ';
{$endif}
{$ifdef i386}
const
- gld = 'gld ';
+ gld = 'gld -m elf_i386_sol2 ';
solaris_ld = '/usr/bin/ld ';
{$endif }
{$ifdef sparc}