summaryrefslogtreecommitdiff
path: root/closures/compiler/systems/t_sunos.pas
blob: 77632e43eaa85db58e1eec1193d851cfbe10b6a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
{
    Copyright (c) 1998-2008 by Peter Vreman

    This unit implements support import,export,link routines
    for the (i386) solaris target

    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_sunos;

{$i fpcdefs.inc}

interface

{ copy from t_linux
// Up to now we use gld since the solaris ld seems not support .res-files}
{-$DEFINE LinkTest} { DON't del link.res and write Info }
{$DEFINE GnuLd}{The other is not implemented }

implementation

  uses
    sysutils,
    cutils,cfileutl,cclasses,
    verbose,systems,globtype,globals,
    symconst,script,
    fmodule,aasmbase,aasmtai,aasmdata,aasmcpu,cpubase,symsym,symdef,
    cgobj,
    import,export,expunix,link,comprsrc,rescmn,i_sunos,ogbase;

  type
    timportlibsolaris=class(timportlib)
      procedure generatelib;override;
    end;

    texportlibsolaris=class(texportlibunix)
(*
      procedure setinitname(list: TAsmList; const s: string); override;
      procedure setfininame(list: TAsmList; const s: string); override;
*)
    end;

    tlinkersolaris=class(texternallinker)
    private
      Glibc2,
      Glibc21 : boolean;
      use_gnu_ld : boolean;
      linkres : TLinkRes;
      Function  WriteResponseFile(isdll:boolean) : Boolean;
    public
      constructor Create;override;
      procedure SetDefaultInfo;override;
      function  MakeExecutable:boolean;override;
      function  MakeSharedLibrary:boolean;override;
    end;


{*****************************************************************************
                               TIMPORTLIBsolaris
*****************************************************************************}

    procedure timportlibsolaris.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;


{*****************************************************************************
                               TEXPORTLIBsolaris
*****************************************************************************}
(*
    procedure texportlibsolaris.setinitname(list: TAsmList; const s: string);
      begin
        inherited setinitname(list,s);
{$ifdef sparc}
        new_section(list,sec_init,'',4);
        list.concat(tai_symbol.createname_global('_init',AT_FUNCTION,0));
        list.concat(taicpu.op_reg_const_reg(A_SAVE,NR_STACK_POINTER_REG,-96,NR_STACK_POINTER_REG));
{$endif sparc}
      end;


    procedure texportlibsolaris.setfininame(list: TAsmList; const s: string);
      begin
        inherited setfininame(list,s);
{$ifdef sparc}
        new_section(list,sec_fini,'',4);
        list.concat(tai_symbol.createname_global('_fini',AT_FUNCTION,0));
        list.concat(taicpu.op_reg_const_reg(A_SAVE,NR_STACK_POINTER_REG,-96,NR_STACK_POINTER_REG));
{$endif sparc}
      end;
*)
{*****************************************************************************
                                  TLINKERsolaris
*****************************************************************************}

Constructor TLinkersolaris.Create;
begin
  Inherited Create;

  if cs_link_native in init_settings.globalswitches then
    use_gnu_ld:=false
  else
    use_gnu_ld:=true;
  if NOT Dontlinkstdlibpath Then
{$ifdef x86_64}
   LibrarySearchPath.AddPath(sysrootpath,'/lib/64;/usr/lib/64;/usr/X11R6/lib/64;/opt/sfw/lib/64',true);
{$else not x86_64}
   LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib;/opt/sfw/lib',true);
{$endif not x86_64}
{$ifdef  LinkTest}
     if (cs_link_staticflag in current_settings.globalswitches) then  WriteLN('ForceLinkStaticFlag');
     if (cs_link_static in current_settings.globalswitches) then  WriteLN('LinkStatic-Flag');
     if (cs_link_shared in current_settings.globalswitches) then  WriteLN('LinkSynamicFlag');
{$EndIf}
end;


procedure TLinkersolaris.SetDefaultInfo;
{
  This will also detect which libc version will be used
}
{$ifdef x86_64}
const
  gld = 'gld -m elf_x86_64 ';
  solaris_ld = '/usr/bin/ld -64 ';
{$endif}
{$ifdef i386}
const
  gld = 'gld ';
  solaris_ld = '/usr/bin/ld ';
{$endif }
{$ifdef sparc}
const
  gld = 'gld ';
  solaris_ld = 'ld ';
{$endif}
begin
  Glibc2:=false;
  Glibc21:=false;
  with Info do
   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';
     DllCmd[2]:='gstrip --strip-unneeded $EXE';
     DllCmd[3]:=solaris_ld + '$OPT $INITFINI -M $VERSIONFILE -G -Bdynamic -L. -o $EXE $RESDATA';
     DynamicLinker:=''; { Gnu uses the default }
     Glibc21:=false;
{$ELSE}
    Not Implememted
{$ENDIF}
   end;

end;


Function TLinkersolaris.WriteResponseFile(isdll:boolean) : Boolean;
Var
  i            : longint;
{  cprtobj,
  gprtobj,
  prtobj       : string[80];}
  HPath        : TCmdStrListItem;
  s,s2         : TCmdStr;
  linkdynamic,
  linklibc     : boolean;
  LinkRes2 : TLinkRes;
begin
  WriteResponseFile:=False;
{ set special options for some targets }
  linkdynamic:=not(SharedLibFiles.empty);
{  linkdynamic:=false; // da nicht getestet }
  linklibc:=(SharedLibFiles.Find('c')<>nil);
{  prtobj:='prt0';
  cprtobj:='cprt0';
  gprtobj:='gprt0';}
  if cs_profile in current_settings.moduleswitches then
   begin
{     prtobj:=gprtobj;}
     if not glibc2 then
      AddSharedLibrary('gmon');
     AddSharedLibrary('c');
     linklibc:=true;
   end
  else
   begin
     if linklibc then
      begin
{       prtobj:=cprtobj;}
      end
      else
       AddSharedLibrary('c'); { quick hack: this solaris implementation needs alwys libc }
   end;

  if use_gnu_ld then
    begin
  { Open link.res file }
  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);

  { Write path to search libraries }
  HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  while assigned(HPath) do
   begin
     LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
     HPath:=TCmdStrListItem(HPath.Next);
   end;
  HPath:=TCmdStrListItem(LibrarySearchPath.First);
  while assigned(HPath) do
   begin
     LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
     HPath:=TCmdStrListItem(HPath.Next);
   end;

  { force local symbol resolution (i.e., inside the shared }
  { library itself) for all non-exorted symbols, otherwise }
  { several RTL symbols of FPC-compiled shared libraries   }
  { will be bound to those of a single shared library or   }
  { to the main program                                    }
  if (isdll) then
    begin
      LinkRes.add('VERSION');
      LinkRes.add('{');
      LinkRes.add('  {');
      if not texportlibunix(exportlib).exportedsymnames.empty then
        begin
          LinkRes.add('    global:');
          repeat
            LinkRes.add('      '+texportlibunix(exportlib).exportedsymnames.getfirst+';');
          until texportlibunix(exportlib).exportedsymnames.empty;
        end;
      LinkRes.add('    local:');
      LinkRes.add('      *;');
      LinkRes.add('  };');
      LinkRes.add('}');
    end;

  LinkRes.Add('INPUT(');
  { add objectfiles, start with prt0 always }
  { solaris port contains _start inside the system unit, it
    needs only one entry because it is linked always against libc
  if prtobj<>'' then
   LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  }
  { try to add crti and crtbegin if linking to C }
  if linklibc then { Needed in solaris? }
   begin
{     if librarysearchpath.FindFile('crtbegin.o',s) then
      LinkRes.AddFileName(s);}
     if librarysearchpath.FindFile('crti.o',false,s) then
      LinkRes.AddFileName(s);
   end;
  { main objectfiles }
  while not ObjectFiles.Empty do
   begin
     s:=ObjectFiles.GetFirst;
     if s<>'' then
      LinkRes.AddFileName(maybequoted(s));
   end;
  LinkRes.Add(')');

  { Write staticlibraries }
  if not StaticLibFiles.Empty then
   begin
     LinkRes.Add('GROUP(');
     While not StaticLibFiles.Empty do
      begin
        S:=StaticLibFiles.GetFirst;
        LinkRes.AddFileName(maybequoted(s))
      end;
     LinkRes.Add(')');
   end;

  { 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) }
  if not SharedLibFiles.Empty then
   begin
     LinkRes.Add('INPUT(');
     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
           linklibc:=true;
           linkdynamic:=false; { libc will include the ld-solaris (war ld-linux) for us }
         end;
      end;
     { be sure that libc is the last lib }
     if linklibc then
      LinkRes.Add('-lc');
     { when we have -static for the linker the we also need libgcc }
     if (cs_link_staticflag in current_settings.globalswitches) then begin
      LinkRes.Add('-lgcc');
     end;
     if linkdynamic and (Info.DynamicLinker<>'') then { gld has a default, DynamicLinker is not set in solaris }
       LinkRes.AddFileName(Info.DynamicLinker);
     LinkRes.Add(')');
   end;
  { objects which must be at the end }
  if linklibc then {needed in solaris ? }
   begin
     if {librarysearchpath.FindFile('crtend.o',s1) or}
        librarysearchpath.FindFile('crtn.o',false,s2) then
      begin
        LinkRes.Add('INPUT(');
{        LinkRes.AddFileName(s1);}
        LinkRes.AddFileName(s2);
        LinkRes.Add(')');
      end;
   end;
{ Write and Close response }
  linkres.writetodisk;
  LinkRes.Free;
    end
  else { not use_gnu_ld }
    begin
   { Open TlinkRes, will not be written to disk }
  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName+'2');

 { Write path to search libraries }
  HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  while assigned(HPath) do
   begin
     LinkRes.Add('-L '+maybequoted(HPath.Str));
     HPath:=TCmdStrListItem(HPath.Next);
   end;
  HPath:=TCmdStrListItem(LibrarySearchPath.First);
  while assigned(HPath) do
   begin
     LinkRes.Add('-L '+maybequoted(HPath.Str));
     HPath:=TCmdStrListItem(HPath.Next);
   end;
  { force local symbol resolution (i.e., inside the shared }
  { library itself) for all non-exorted symbols, otherwise }
  { several RTL symbols of FPC-compiled shared libraries   }
  { will be bound to those of a single shared library or   }
  { to the main program                                    }
  if (isdll) then
    begin
      LinkRes2:=TLinkRes.Create(outputexedir+Info.ResName);
      // LinkRes2.add('VERSION'); not needed for now
      LinkRes2.add('  {');
      if not texportlibunix(exportlib).exportedsymnames.empty then
        begin
          LinkRes2.add('    global:');
          repeat
            LinkRes2.add('      '+texportlibunix(exportlib).exportedsymnames.getfirst+';');
          until texportlibunix(exportlib).exportedsymnames.empty;
        end;
      LinkRes2.add('    local:');
      LinkRes2.add('      *;');
      LinkRes2.add('  };');
      LinkRes2.writetodisk;
      LinkRes2.Free;
    end;


  { add objectfiles, start with prt0 always }
  { solaris port contains _start inside the system unit, it
    needs only one entry because it is linked always against libc
  if prtobj<>'' then
   LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  }
  { try to add crti and crtbegin if linking to C }
  if linklibc then { Needed in solaris? }
   begin
{     if librarysearchpath.FindFile('crtbegin.o',s) then
      LinkRes.AddFileName(s);}
     if librarysearchpath.FindFile('crti.o',false,s) then
      LinkRes.AddFileName(s);
   end;
  { main objectfiles }
  while not ObjectFiles.Empty do
   begin
     s:=ObjectFiles.GetFirst;
     if s<>'' then
      LinkRes.AddFileName(maybequoted(s));
   end;

  { Write staticlibraries }
  if not StaticLibFiles.Empty then
   begin
     linkres.add('-('); 
     While not StaticLibFiles.Empty do
      begin
        S:=StaticLibFiles.GetFirst;
        LinkRes.AddFileName(maybequoted(s))
      end;
     linkres.add('-)'); 
   end;

  { 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) }
  if not SharedLibFiles.Empty then
   begin
     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
           linklibc:=true;
           linkdynamic:=false; { libc will include the ld-solaris (war ld-linux) for us }
         end;
      end;
     { be sure that libc is the last lib }
     if linklibc then
      LinkRes.Add('-lc');
     { when we have -static for the linker the we also need libgcc }
     if (cs_link_staticflag in current_settings.globalswitches) then begin
      LinkRes.Add('-lgcc');
     end;
     if linkdynamic and (Info.DynamicLinker<>'') then { gld has a default, DynamicLinker is not set in solaris }
       LinkRes.AddFileName(Info.DynamicLinker);
   end;
  { objects which must be at the end }
  if linklibc then {needed in solaris ? }
   begin
     if {librarysearchpath.FindFile('crtend.o',s1) or}
        librarysearchpath.FindFile('crtn.o',false,s2) then
      begin
{        LinkRes.AddFileName(s1);}
        LinkRes.AddFileName(s2);
      end;
   end;
{ Write and Close response }
  //linkres.writetodisk;
  //LinkRes.Free;

    end;
  WriteResponseFile:=True;
end;


function TLinkersolaris.MakeExecutable:boolean;
var
  binstr,
  s, linkstr,
  cmdstr  : TCmdStr;
  success : boolean;
  DynLinkStr : string[60];
  StaticStr,
  StripStr   : string[40];
begin
  if not(cs_link_nolink in current_settings.globalswitches) then
   Message1(exec_i_linking,current_module.exefilename^);

{ Create some replacements }
  StaticStr:='';
  StripStr:='';
  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_profile in current_settings.moduleswitches) or
     ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then
   DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  if rlinkpath<>'' then
    if use_gnu_ld then
      DynLinkStr:=DynLinkStr+' --rpath-link '+rlinkpath
    else
      DynLinkStr:=DynLinkStr+' -R '+rlinkpath;

  { solaris sets DynamicLinker, but gld will (hopefully) defaults to -Bdynamic and add the default-linker }
{ Write used files and libraries }
  WriteResponseFile(false);

{ Call linker }
  if use_gnu_ld then
    SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr)
  else
    SplitBinCmd(Info.ExeCmd[2],binstr,cmdstr);
  Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename^));
  Replace(cmdstr,'$OPT',Info.ExtraOptions);
  if use_gnu_ld then
    Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName))
  else
    begin
      linkstr:='';
      while not linkres.data.Empty do
        begin
          s:=linkres.data.GetFirst;
	  if s<>'' then
            linkstr:=linkstr+' '+s;
        end;
      linkres.free;
      Replace(cmdstr,'$RESDATA',linkstr);
    end;
  Replace(cmdstr,'$STATIC',StaticStr);
  Replace(cmdstr,'$STRIP',StripStr);
  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);

{ Remove ReponseFile }
{$IFNDEF LinkTest}
  if (success) and use_gnu_ld and
     not(cs_link_nolink in current_settings.globalswitches) then
   DeleteFile(outputexedir+Info.ResName);
{$ENDIF}
  MakeExecutable:=success;   { otherwise a recursive call to link method }
end;


Function TLinkersolaris.MakeSharedLibrary:boolean;
var
  InitFiniStr : string;
  binstr,
  s, linkstr,
  cmdstr  : TCmdStr;
  success : boolean;
begin
  MakeSharedLibrary:=false;
  if not(cs_link_nolink in current_settings.globalswitches) then
   Message1(exec_i_linking,current_module.sharedlibfilename^);

{ Write used files and libraries }
  WriteResponseFile(true);

{ Create some replacements }
{ initname and fininame may contain $, which can be wrongly interpreted
  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
        InitFiniStr:=InitFiniStr+''''+exportlib.initname+''''
      else
        InitFiniStr:=InitFiniStr+exportlib.initname;
      if (exportlib.fininame<>'') then
        begin
          if cs_link_nolink in current_settings.globalswitches then
            InitFiniStr:=InitFiniStr+' -fini '''+exportlib.initname+''''
          else
            InitFiniStr:=InitFiniStr+' -fini '+exportlib.fininame;
        end;
    end
  else
    begin
      InitFiniStr:='-z initarray=';
      if cs_link_nolink in current_settings.globalswitches then
        InitFiniStr:=InitFiniStr+''''+exportlib.initname+''''
      else
        InitFiniStr:=InitFiniStr+exportlib.initname;
      if (exportlib.fininame<>'') then
        begin
          if cs_link_nolink in current_settings.globalswitches then
            InitFiniStr:=InitFiniStr+' -z finiarray='''+exportlib.initname+''''
          else
            InitFiniStr:=InitFiniStr+' -z finiarray='+exportlib.fininame;
        end;
    end;

{ Call linker }
  if use_gnu_ld then
    SplitBinCmd(Info.DllCmd[1],binstr,cmdstr)
  else
    SplitBinCmd(Info.DllCmd[3],binstr,cmdstr);
  Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
  Replace(cmdstr,'$OPT',Info.ExtraOptions);
  Replace(cmdstr,'$INITFINI',InitFiniStr);
  if use_gnu_ld then
    Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName))
  else
    begin
      Replace(cmdstr,'$VERSIONFILE',maybequoted(outputexedir+Info.ResName));
      linkstr:='';
      while not linkres.data.Empty do
        begin
          s:=linkres.data.GetFirst;
	  if s<>'' then
            linkstr:=linkstr+' '+s;
        end;
      linkres.free;
      Replace(cmdstr,'$RESDATA',linkstr);
    end;
  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);


{ Strip the library ? }
  if success and (cs_link_strip in current_settings.globalswitches) then
   begin
     SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
     Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
     success:=DoExec(utilsprefix+FindUtil(binstr),cmdstr,true,false);
   end;

{ Remove ReponseFile }
{$IFNDEF LinkTest}
  if (success) and not(cs_link_nolink in current_settings.globalswitches) then
   DeleteFile(outputexedir+Info.ResName);
{$ENDIF}
  MakeSharedLibrary:=success;   { otherwise a recursive call to link method }
end;


{*****************************************************************************
                                     Initialize
*****************************************************************************}

initialization
{$ifdef i386}
  RegisterExternalLinker(system_i386_solaris_info,TLinkersolaris);
  RegisterImport(system_i386_solaris,TImportLibsolaris);
  RegisterExport(system_i386_solaris,TExportLibsolaris);
  RegisterTarget(system_i386_solaris_info);
{$endif i386}

{$ifdef x86_64}
  RegisterExternalLinker(system_x86_64_solaris_info,TLinkersolaris);
  RegisterImport(system_x86_64_solaris,TImportLibsolaris);
  RegisterExport(system_x86_64_solaris,TExportLibsolaris);
  RegisterTarget(system_x86_64_solaris_info);
{$endif x86_64}

{$ifdef sparc}
  RegisterExternalLinker(system_sparc_solaris_info,TLinkersolaris);
  RegisterImport(system_sparc_solaris,TImportLibsolaris);
  RegisterExport(system_sparc_solaris,TExportLibsolaris);
  RegisterTarget(system_sparc_solaris_info);
{$endif sparc}

  RegisterRes(res_elf_info,TWinLikeResourceFile);
end.