|
@@ -115,10 +115,23 @@ implementation
|
|
|
TLINKERsolaris
|
|
|
*****************************************************************************}
|
|
|
|
|
|
+{$ifdef x86_64}
|
|
|
+const
|
|
|
+ gnu_emul = '-m elf_x86_64_sol2';
|
|
|
+{$endif}
|
|
|
+{$ifdef i386}
|
|
|
+const
|
|
|
+ gnu_emul = '-m elf_i386_sol2';
|
|
|
+{$endif }
|
|
|
+{$ifdef sparc}
|
|
|
+const
|
|
|
+ { no emulation specification needed, as long as only 32-bit is supported }
|
|
|
+ gnu_emul = '';
|
|
|
+{$endif}
|
|
|
+
|
|
|
Constructor TLinkersolaris.Create;
|
|
|
begin
|
|
|
Inherited Create;
|
|
|
-
|
|
|
if cs_link_native in init_settings.globalswitches then
|
|
|
use_gnu_ld:=false
|
|
|
else
|
|
@@ -143,12 +156,12 @@ procedure TLinkersolaris.SetDefaultInfo;
|
|
|
}
|
|
|
{$ifdef x86_64}
|
|
|
const
|
|
|
- gld = 'gld -m elf_x86_64_sol2 ';
|
|
|
+ gld = 'gld $EMUL ';
|
|
|
solaris_ld = '/usr/bin/ld -64 ';
|
|
|
{$endif}
|
|
|
{$ifdef i386}
|
|
|
const
|
|
|
- gld = 'gld ';
|
|
|
+ gld = 'gld $EMUL';
|
|
|
solaris_ld = '/usr/bin/ld ';
|
|
|
{$endif }
|
|
|
{$ifdef sparc}
|
|
@@ -163,10 +176,10 @@ begin
|
|
|
begin
|
|
|
{$IFDEF GnuLd}
|
|
|
ExeCmd[1]:=gld + '$OPT $DYNLINK $STATIC $STRIP -L. -o $EXE $RES';
|
|
|
- ExeCmd[2]:=solaris_ld + '$OPT $DYNLINK $STATIC $STRIP -L . -o $EXE $RESDATA';
|
|
|
- DllCmd[1]:=gld + '$OPT $INITFINI -shared -L. -o $EXE $RES';
|
|
|
+ ExeCmd[2]:=solaris_ld + '$OPT $DYNLINK $STATIC $STRIP -L . -o $EXE $RESDATA $REDIRECT';
|
|
|
+ DllCmd[1]:=gld + '$OPT $INITFINI -shared -L. $MAP -o $EXE $RES';
|
|
|
DllCmd[2]:='gstrip --strip-unneeded $EXE';
|
|
|
- DllCmd[3]:=solaris_ld + '$OPT $INITFINI -M $VERSIONFILE -G -Bdynamic -L. -o $EXE $RESDATA';
|
|
|
+ DllCmd[3]:=solaris_ld + '$OPT $INITFINI -M $VERSIONFILE $MAP -G -Bdynamic -L. -o $EXE $RESDATA $REDIRECT';
|
|
|
DynamicLinker:=''; { Gnu uses the default }
|
|
|
Glibc21:=false;
|
|
|
{$ELSE}
|
|
@@ -242,7 +255,7 @@ begin
|
|
|
if (isdll) then
|
|
|
begin
|
|
|
LinkRes.add('VERSION');
|
|
|
- LinkRes.add('{');
|
|
|
+ LinkRes.add('{ DEFAULT'); { gld 2.25 does not support anonymous version }
|
|
|
LinkRes.add(' {');
|
|
|
if not texportlibunix(exportlib).exportedsymnames.empty then
|
|
|
begin
|
|
@@ -310,6 +323,7 @@ begin
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
+ LinkRes.Add('-lc');
|
|
|
linklibc:=true;
|
|
|
linkdynamic:=false; { libc will include the ld-solaris (war ld-linux) for us }
|
|
|
end;
|
|
@@ -409,13 +423,13 @@ begin
|
|
|
{ Write staticlibraries }
|
|
|
if not StaticLibFiles.Empty then
|
|
|
begin
|
|
|
- linkres.add('-(');
|
|
|
+ linkres.add('-(');
|
|
|
While not StaticLibFiles.Empty do
|
|
|
begin
|
|
|
S:=StaticLibFiles.GetFirst;
|
|
|
LinkRes.AddFileName(maybequoted(s))
|
|
|
end;
|
|
|
- linkres.add('-)');
|
|
|
+ linkres.add('-)');
|
|
|
end;
|
|
|
|
|
|
{ Write sharedlibraries like -l<lib>, also add the needed dynamic linker
|
|
@@ -474,20 +488,32 @@ var
|
|
|
cmdstr : TCmdStr;
|
|
|
success : boolean;
|
|
|
DynLinkStr : string[60];
|
|
|
- StaticStr,
|
|
|
+ StaticStr, RedirectStr,
|
|
|
StripStr : string[40];
|
|
|
begin
|
|
|
+ success:=false;
|
|
|
if not(cs_link_nolink in current_settings.globalswitches) then
|
|
|
Message1(exec_i_linking,current_module.exefilename);
|
|
|
|
|
|
{ Create some replacements }
|
|
|
StaticStr:='';
|
|
|
StripStr:='';
|
|
|
+ RedirectStr:='';
|
|
|
DynLinkStr:='';
|
|
|
if (cs_link_staticflag in current_settings.globalswitches) then
|
|
|
StaticStr:='-Bstatic';
|
|
|
if (cs_link_strip in current_settings.globalswitches) then
|
|
|
StripStr:='-s';
|
|
|
+ if (cs_link_map in current_settings.globalswitches) then
|
|
|
+ begin
|
|
|
+ if use_gnu_ld then
|
|
|
+ StripStr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'))
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ StripStr:='-m';
|
|
|
+ RedirectStr:=' > '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
|
|
|
+ end;
|
|
|
+ end;
|
|
|
If (cs_profile in current_settings.moduleswitches) or
|
|
|
((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then
|
|
|
DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
|
|
@@ -509,7 +535,10 @@ begin
|
|
|
Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
|
|
|
Replace(cmdstr,'$OPT',Info.ExtraOptions);
|
|
|
if use_gnu_ld then
|
|
|
- Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName))
|
|
|
+ begin
|
|
|
+ Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
|
|
|
+ Replace(cmdstr,'$EMUL',gnu_emul);
|
|
|
+ end
|
|
|
else
|
|
|
begin
|
|
|
linkstr:='';
|
|
@@ -524,12 +553,13 @@ begin
|
|
|
end;
|
|
|
Replace(cmdstr,'$STATIC',StaticStr);
|
|
|
Replace(cmdstr,'$STRIP',StripStr);
|
|
|
+ Replace(cmdstr,'$REDIRECT',RedirectStr);
|
|
|
Replace(cmdstr,'$DYNLINK',DynLinkStr);
|
|
|
if BinStr[1]<>'/' then
|
|
|
- success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false)
|
|
|
- else { Using utilsprefix has no sense on /usr/bin/ld }
|
|
|
- success:=DoExec(BinStr,Trim(CmdStr),true,false);
|
|
|
+ BinStr:=FindUtil(utilsprefix+BinStr);
|
|
|
|
|
|
+ { We need shell if output is redirected }
|
|
|
+ success:=DoExec(BinStr,Trim(CmdStr),true,RedirectStr<>'');
|
|
|
{ Remove ReponseFile }
|
|
|
{$IFNDEF LinkTest}
|
|
|
if (success) and use_gnu_ld and
|
|
@@ -543,11 +573,12 @@ end;
|
|
|
Function TLinkersolaris.MakeSharedLibrary:boolean;
|
|
|
var
|
|
|
InitFiniStr : string;
|
|
|
- binstr,
|
|
|
- s, linkstr,
|
|
|
+ binstr, RedirectStr,
|
|
|
+ s, linkstr, MapStr,
|
|
|
cmdstr : TCmdStr;
|
|
|
- success : boolean;
|
|
|
+ need_quotes, success : boolean;
|
|
|
begin
|
|
|
+ success:=false;
|
|
|
MakeSharedLibrary:=false;
|
|
|
if not(cs_link_nolink in current_settings.globalswitches) then
|
|
|
Message1(exec_i_linking,current_module.sharedlibfilename);
|
|
@@ -555,20 +586,34 @@ begin
|
|
|
{ Write used files and libraries }
|
|
|
WriteResponseFile(true);
|
|
|
|
|
|
+ RedirectStr:='';
|
|
|
+ MapStr:='';
|
|
|
{ Create some replacements }
|
|
|
+ if (cs_link_map in current_settings.globalswitches) then
|
|
|
+ begin
|
|
|
+ if use_gnu_ld then
|
|
|
+ MapStr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'))
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ MapStr:='-m';
|
|
|
+ RedirectStr:=' > '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ need_quotes:= (cs_link_nolink in current_settings.globalswitches) or
|
|
|
+ (RedirectStr<>'');
|
|
|
{ initname and fininame may contain $, which can be wrongly interpreted
|
|
|
- in a link script, thus we surround them with single quotes
|
|
|
+ in a link script, thus we surround them with single quotes
|
|
|
in cs_link_nolink is in globalswitches }
|
|
|
if use_gnu_ld then
|
|
|
begin
|
|
|
InitFiniStr:='-init ';
|
|
|
- if cs_link_nolink in current_settings.globalswitches then
|
|
|
+ if need_quotes then
|
|
|
InitFiniStr:=InitFiniStr+''''+exportlib.initname+''''
|
|
|
else
|
|
|
InitFiniStr:=InitFiniStr+exportlib.initname;
|
|
|
if (exportlib.fininame<>'') then
|
|
|
begin
|
|
|
- if cs_link_nolink in current_settings.globalswitches then
|
|
|
+ if need_quotes then
|
|
|
InitFiniStr:=InitFiniStr+' -fini '''+exportlib.initname+''''
|
|
|
else
|
|
|
InitFiniStr:=InitFiniStr+' -fini '+exportlib.fininame;
|
|
@@ -577,13 +622,13 @@ begin
|
|
|
else
|
|
|
begin
|
|
|
InitFiniStr:='-z initarray=';
|
|
|
- if cs_link_nolink in current_settings.globalswitches then
|
|
|
+ if need_quotes then
|
|
|
InitFiniStr:=InitFiniStr+''''+exportlib.initname+''''
|
|
|
else
|
|
|
InitFiniStr:=InitFiniStr+exportlib.initname;
|
|
|
if (exportlib.fininame<>'') then
|
|
|
begin
|
|
|
- if cs_link_nolink in current_settings.globalswitches then
|
|
|
+ if need_quotes then
|
|
|
InitFiniStr:=InitFiniStr+' -z finiarray='''+exportlib.initname+''''
|
|
|
else
|
|
|
InitFiniStr:=InitFiniStr+' -z finiarray='+exportlib.fininame;
|
|
@@ -599,7 +644,10 @@ begin
|
|
|
Replace(cmdstr,'$OPT',Info.ExtraOptions);
|
|
|
Replace(cmdstr,'$INITFINI',InitFiniStr);
|
|
|
if use_gnu_ld then
|
|
|
- Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName))
|
|
|
+ begin
|
|
|
+ Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
|
|
|
+ Replace(cmdstr,'$EMUL',gnu_emul);
|
|
|
+ end
|
|
|
else
|
|
|
begin
|
|
|
Replace(cmdstr,'$VERSIONFILE',maybequoted(outputexedir+Info.ResName));
|
|
@@ -613,12 +661,12 @@ begin
|
|
|
linkres.free;
|
|
|
Replace(cmdstr,'$RESDATA',linkstr);
|
|
|
end;
|
|
|
+ Replace(cmdstr,'$REDIRECT',RedirectStr);
|
|
|
+ Replace(cmdstr,'$MAP',MapStr);
|
|
|
if BinStr[1]<>'/' then
|
|
|
- success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false)
|
|
|
- else { Using utilsprefix has no sense on /usr/bin/ld }
|
|
|
- success:=DoExec(BinStr,Trim(CmdStr),true,false);
|
|
|
-
|
|
|
-
|
|
|
+ BinStr:=FindUtil(utilsprefix+BinStr);
|
|
|
+ { We need shell if output is redirected }
|
|
|
+ success:=DoExec(BinStr,Trim(CmdStr),true,RedirectStr<>'');
|
|
|
{ Strip the library ? }
|
|
|
if success and (cs_link_strip in current_settings.globalswitches) then
|
|
|
begin
|