t_bsd.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. {
  2. Copyright (c) 1998-2002 by Peter Vreman (original Linux)
  3. (c) 2000 by Marco van de Voort (FreeBSD mods)
  4. This unit implements support import,export,link routines
  5. for the (i386)FreeBSD target
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit t_bsd;
  20. {$i fpcdefs.inc}
  21. interface
  22. implementation
  23. uses
  24. {$ifdef gdb}
  25. gdb,
  26. {$endif gdb}
  27. cutils,cclasses,
  28. {$ifdef USE_SYSUTILS}
  29. sysutils,
  30. {$else USE_SYSUTILS}
  31. dos,
  32. {$endif USE_SYSUTILS}
  33. verbose,systems,globtype,globals,
  34. symconst,script,
  35. fmodule,aasmbase,aasmtai,aasmcpu,cpubase,symsym,symdef,
  36. import,export,link,i_bsd,
  37. cgutils,cgbase,cgobj,cpuinfo;
  38. type
  39. tdarwinimported_item = class(timported_item)
  40. procdef : tprocdef;
  41. end;
  42. timportlibdarwin=class(timportlib)
  43. procedure preparelib(const s:string);override;
  44. procedure importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);override;
  45. procedure importvariable(vs:tglobalvarsym;const name,module:string);override;
  46. procedure generatelib;override;
  47. procedure generatesmartlib;override;
  48. end;
  49. timportlibbsd=class(timportlib)
  50. procedure preparelib(const s:string);override;
  51. procedure importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);override;
  52. procedure importvariable(vs:tglobalvarsym;const name,module:string);override;
  53. procedure generatelib;override;
  54. end;
  55. texportlibbsd=class(texportlib)
  56. procedure preparelib(const s : string);override;
  57. procedure exportprocedure(hp : texported_item);override;
  58. procedure exportvar(hp : texported_item);override;
  59. procedure generatelib;override;
  60. end;
  61. tlinkerbsd=class(texternallinker)
  62. private
  63. LdSupportsNoResponseFile : boolean;
  64. LibrarySuffix : Char;
  65. Function WriteResponseFile(isdll:boolean) : Boolean;
  66. public
  67. constructor Create;override;
  68. procedure SetDefaultInfo;override;
  69. function MakeExecutable:boolean;override;
  70. function MakeSharedLibrary:boolean;override;
  71. end;
  72. {*****************************************************************************
  73. TIMPORTLIBDARWIN
  74. *****************************************************************************}
  75. procedure timportlibdarwin.preparelib(const s : string);
  76. begin
  77. if not(assigned(importssection)) then
  78. importssection:=TAAsmoutput.create;
  79. end;
  80. procedure timportlibdarwin.importprocedure(aprocdef:tprocdef;const module : string;index : longint;const name : string);
  81. begin
  82. { insert sharedlibrary }
  83. { current_module.linkothersharedlibs.add(SplitName(module),link_allways); }
  84. end;
  85. procedure timportlibdarwin.importvariable(vs:tglobalvarsym;const name,module:string);
  86. begin
  87. { insert sharedlibrary }
  88. { current_module.linkothersharedlibs.add(SplitName(module),link_allways); }
  89. { the rest is handled in the nppcld.pas tppcloadnode }
  90. vs.set_mangledname(name);
  91. end;
  92. procedure timportlibdarwin.generatesmartlib;
  93. begin
  94. generatelib;
  95. end;
  96. procedure timportlibdarwin.generatelib;
  97. begin
  98. end;
  99. {*****************************************************************************
  100. TIMPORTLIBBSD
  101. *****************************************************************************}
  102. procedure timportlibbsd.preparelib(const s : string);
  103. begin
  104. end;
  105. procedure timportlibbsd.importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);
  106. begin
  107. { insert sharedlibrary }
  108. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  109. end;
  110. procedure timportlibbsd.importvariable(vs:tglobalvarsym;const name,module:string);
  111. begin
  112. { insert sharedlibrary }
  113. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  114. { reset the mangledname and turn off the dll_var option }
  115. vs.set_mangledname(name);
  116. exclude(vs.varoptions,vo_is_dll_var);
  117. end;
  118. procedure timportlibbsd.generatelib;
  119. begin
  120. end;
  121. {*****************************************************************************
  122. TEXPORTLIBBSD
  123. *****************************************************************************}
  124. procedure texportlibbsd.preparelib(const s:string);
  125. begin
  126. end;
  127. procedure texportlibbsd.exportprocedure(hp : texported_item);
  128. var
  129. hp2 : texported_item;
  130. begin
  131. { first test the index value }
  132. if (hp.options and eo_index)<>0 then
  133. begin
  134. Message1(parser_e_no_export_with_index_for_target,'*bsd/darwin');
  135. exit;
  136. end;
  137. { now place in correct order }
  138. hp2:=texported_item(current_module._exports.first);
  139. while assigned(hp2) and
  140. (hp.name^>hp2.name^) do
  141. hp2:=texported_item(hp2.next);
  142. { insert hp there !! }
  143. if assigned(hp2) and (hp2.name^=hp.name^) then
  144. begin
  145. { this is not allowed !! }
  146. Message1(parser_e_export_name_double,hp.name^);
  147. exit;
  148. end;
  149. if hp2=texported_item(current_module._exports.first) then
  150. current_module._exports.concat(hp)
  151. else if assigned(hp2) then
  152. begin
  153. hp.next:=hp2;
  154. hp.previous:=hp2.previous;
  155. if assigned(hp2.previous) then
  156. hp2.previous.next:=hp;
  157. hp2.previous:=hp;
  158. end
  159. else
  160. current_module._exports.concat(hp);
  161. end;
  162. procedure texportlibbsd.exportvar(hp : texported_item);
  163. begin
  164. hp.is_var:=true;
  165. exportprocedure(hp);
  166. end;
  167. procedure texportlibbsd.generatelib;
  168. var
  169. hp2 : texported_item;
  170. begin
  171. hp2:=texported_item(current_module._exports.first);
  172. while assigned(hp2) do
  173. begin
  174. if (not hp2.is_var) and
  175. (hp2.sym.typ=procsym) then
  176. begin
  177. { the manglednames can already be the same when the procedure
  178. is declared with cdecl }
  179. if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
  180. begin
  181. {$ifdef i386}
  182. { place jump in codesegment }
  183. codesegment.concat(Tai_align.Create_op(4,$90));
  184. codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
  185. codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
  186. codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
  187. {$endif i386}
  188. {$ifdef powerpc}
  189. codesegment.concat(Tai_align.create(16));
  190. codesegment.concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
  191. codeSegment.concat(Taicpu.Op_sym(A_B,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
  192. codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
  193. {$endif powerpc}
  194. end;
  195. end
  196. else
  197. Message1(parser_e_no_export_of_variables_for_target,'*bsd/darwin');
  198. hp2:=texported_item(hp2.next);
  199. end;
  200. end;
  201. {*****************************************************************************
  202. TLINKERLINUX
  203. *****************************************************************************}
  204. Constructor TLinkerBSD.Create;
  205. begin
  206. Inherited Create;
  207. if not Dontlinkstdlibpath Then
  208. if (target_info.system <> system_powerpc_darwin) then
  209. LibrarySearchPath.AddPath('/lib;/usr/lib;/usr/X11R6/lib',true)
  210. else
  211. { Mac OS X doesn't have a /lib }
  212. LibrarySearchPath.AddPath('/usr/lib',true)
  213. end;
  214. procedure TLinkerBSD.SetDefaultInfo;
  215. {
  216. This will also detect which libc version will be used
  217. }
  218. begin
  219. LibrarySuffix:=' ';
  220. LdSupportsNoResponseFile := (target_info.system in [system_m68k_netbsd,system_powerpc_darwin]);
  221. with Info do
  222. begin
  223. if LdSupportsNoResponseFile then
  224. begin
  225. if (target_info.system <> system_powerpc_darwin) then
  226. begin
  227. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE `cat $RES`';
  228. DllCmd[1]:='ld $OPT -shared -L. -o $EXE `cat $RES`'
  229. end
  230. else
  231. begin
  232. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -multiply_defined suppress -L. -o $EXE `cat $RES`';
  233. DllCmd[1]:='libtool $OPT -dynamic -init PASCALMAIN -multiply_defined suppress -L. -o $EXE `cat $RES`'
  234. end
  235. end
  236. else
  237. begin
  238. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE $RES';
  239. DllCmd[1]:='ld $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
  240. end;
  241. if (target_info.system <> system_powerpc_darwin) then
  242. DllCmd[2]:='strip --strip-unneeded $EXE'
  243. else
  244. DllCmd[2]:='strip -x $EXE';
  245. { first try glibc2 }
  246. {$ifdef GLIBC2} {Keep linux code in place. FBSD might go to a different
  247. glibc too once}
  248. DynamicLinker:='/lib/ld-linux.so.2';
  249. if FileExists(DynamicLinker) then
  250. begin
  251. Glibc2:=true;
  252. { Check for 2.0 files, else use the glibc 2.1 stub }
  253. if FileExists('/lib/ld-2.0.*') then
  254. Glibc21:=false
  255. else
  256. Glibc21:=true;
  257. end
  258. else
  259. DynamicLinker:='/lib/ld-linux.so.1';
  260. {$else}
  261. DynamicLinker:='';
  262. {$endif}
  263. end;
  264. end;
  265. Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
  266. Var
  267. linkres : TLinkRes;
  268. i : longint;
  269. cprtobj,
  270. gprtobj,
  271. prtobj : string[80];
  272. HPath : TStringListItem;
  273. s,s1,s2 : string;
  274. linkpthread,
  275. linkdynamic,
  276. linklibc : boolean;
  277. Fl1,Fl2 : Boolean;
  278. begin
  279. WriteResponseFile:=False;
  280. { set special options for some targets }
  281. if target_info.system <> system_powerpc_darwin then
  282. begin
  283. linkdynamic:=not(SharedLibFiles.empty);
  284. linklibc:=(SharedLibFiles.Find('c')<>nil);
  285. linkpthread:=(SharedLibFiles.Find('pthread')<>nil);
  286. if (target_info.system =system_i386_freebsd) and linkpthread Then
  287. Begin
  288. if not (cs_link_pthread in aktglobalswitches) Then
  289. begin
  290. {delete pthreads from list, in this case it is in libc_r}
  291. SharedLibFiles.Remove(SharedLibFiles.Find('pthread').str);
  292. LibrarySuffix:='r';
  293. end;
  294. End;
  295. prtobj:='prt0';
  296. cprtobj:='cprt0';
  297. gprtobj:='gprt0';
  298. if cs_profile in aktmoduleswitches then
  299. begin
  300. prtobj:=gprtobj;
  301. AddSharedLibrary('c');
  302. LibrarySuffix:='p';
  303. linklibc:=true;
  304. end
  305. else
  306. begin
  307. if linklibc then
  308. prtobj:=cprtobj;
  309. end;
  310. end
  311. else
  312. begin
  313. { for darwin: always link dynamically against libc }
  314. linklibc := true;
  315. if not(isdll) then
  316. if not(cs_profile in aktmoduleswitches) then
  317. begin
  318. if librarysearchpath.FindFile('crt1.o',s) then
  319. prtobj:=s
  320. else
  321. prtobj:='/usr/lib/crt1.o';
  322. end
  323. else
  324. prtobj:='/usr/lib/gcrt1.o'
  325. else
  326. prtobj:='';
  327. end;
  328. { Open link.res file }
  329. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
  330. { Write path to search libraries }
  331. HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
  332. while assigned(HPath) do
  333. begin
  334. if LdSupportsNoResponseFile then
  335. LinkRes.Add(maybequoted('-L'+HPath.Str))
  336. else
  337. LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
  338. HPath:=TStringListItem(HPath.Next);
  339. end;
  340. HPath:=TStringListItem(LibrarySearchPath.First);
  341. while assigned(HPath) do
  342. begin
  343. if LdSupportsNoResponseFile then
  344. LinkRes.Add(maybequoted('-L'+HPath.Str))
  345. else
  346. LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
  347. HPath:=TStringListItem(HPath.Next);
  348. end;
  349. if not LdSupportsNoResponseFile then
  350. LinkRes.Add('INPUT(');
  351. { add objectfiles, start with prt0 always }
  352. if prtobj<>'' then
  353. LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  354. { try to add crti and crtbegin if linking to C }
  355. if linklibc and
  356. (target_info.system <> system_powerpc_darwin) then
  357. begin
  358. if librarysearchpath.FindFile('crtbegin.o',s) then
  359. LinkRes.AddFileName(s);
  360. if librarysearchpath.FindFile('crti.o',s) then
  361. LinkRes.AddFileName(s);
  362. end;
  363. { main objectfiles }
  364. while not ObjectFiles.Empty do
  365. begin
  366. s:=ObjectFiles.GetFirst;
  367. if s<>'' then
  368. LinkRes.AddFileName(maybequoted(s));
  369. end;
  370. if not LdSupportsNoResponseFile then
  371. LinkRes.Add(')');
  372. { Write staticlibraries }
  373. if not StaticLibFiles.Empty then
  374. begin
  375. if not LdSupportsNoResponseFile then
  376. LinkRes.Add('GROUP(');
  377. While not StaticLibFiles.Empty do
  378. begin
  379. S:=StaticLibFiles.GetFirst;
  380. LinkRes.AddFileName(maybequoted(s))
  381. end;
  382. if not LdSupportsNoResponseFile then
  383. LinkRes.Add(')');
  384. end;
  385. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  386. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  387. if not SharedLibFiles.Empty then
  388. begin
  389. if not LdSupportsNoResponseFile then
  390. LinkRes.Add('INPUT(');
  391. While not SharedLibFiles.Empty do
  392. begin
  393. S:=SharedLibFiles.GetFirst;
  394. if s<>'c' then
  395. begin
  396. i:=Pos(target_info.sharedlibext,S);
  397. if i>0 then
  398. Delete(S,i,255);
  399. LinkRes.Add('-l'+s);
  400. end
  401. else
  402. begin
  403. linklibc:=true;
  404. linkdynamic:=false; { libc will include the ld-linux for us }
  405. end;
  406. end;
  407. { be sure that libc is the last lib }
  408. if linklibc then
  409. Begin
  410. If LibrarySuffix=' ' Then
  411. LinkRes.Add('-lc')
  412. else
  413. LinkRes.Add('-lc_'+LibrarySuffix);
  414. If LibrarySuffix='r' Then
  415. LinkRes.Add('-lc');
  416. end;
  417. { when we have -static for the linker the we also need libgcc }
  418. if (cs_link_staticflag in aktglobalswitches) then
  419. LinkRes.Add('-lgcc');
  420. if linkdynamic and (Info.DynamicLinker<>'') then
  421. LinkRes.AddFileName(Info.DynamicLinker);
  422. if not LdSupportsNoResponseFile then
  423. LinkRes.Add(')');
  424. end;
  425. { objects which must be at the end }
  426. if linklibc and
  427. (target_info.system <> system_powerpc_darwin) then
  428. begin
  429. Fl1:=librarysearchpath.FindFile('crtend.o',s1);
  430. Fl2:=librarysearchpath.FindFile('crtn.o',s2);
  431. if Fl1 or Fl2 then
  432. begin
  433. LinkRes.Add('INPUT(');
  434. If Fl1 Then
  435. LinkRes.AddFileName(s1);
  436. If Fl2 Then
  437. LinkRes.AddFileName(s2);
  438. LinkRes.Add(')');
  439. end;
  440. end;
  441. { ignore the fact that our relocations are in non-writable sections, }
  442. { will be fixed once we have pic support }
  443. if isdll and
  444. (target_info.system = system_powerpc_darwin) then
  445. LinkRes.Add('-read_only_relocs suppress');
  446. { Write and Close response }
  447. linkres.writetodisk;
  448. linkres.Free;
  449. WriteResponseFile:=True;
  450. end;
  451. function TLinkerBSD.MakeExecutable:boolean;
  452. var
  453. binstr : String;
  454. cmdstr : TCmdStr;
  455. success : boolean;
  456. DynLinkStr : string[60];
  457. GCSectionsStr,
  458. StaticStr,
  459. StripStr : string[40];
  460. begin
  461. if not(cs_link_extern in aktglobalswitches) then
  462. Message1(exec_i_linking,current_module.exefilename^);
  463. { Create some replacements }
  464. StaticStr:='';
  465. StripStr:='';
  466. DynLinkStr:='';
  467. GCSectionsStr:='';
  468. if (cs_link_staticflag in aktglobalswitches) then
  469. begin
  470. if (target_info.system=system_m68k_netbsd) and
  471. ((cs_link_on_target in aktglobalswitches) or
  472. (target_info.system=source_info.system)) then
  473. StaticStr:='-Bstatic'
  474. else
  475. StaticStr:='-static';
  476. end;
  477. if (cs_link_strip in aktglobalswitches) then
  478. if (target_info.system <> system_powerpc_darwin) then
  479. StripStr:='-s'
  480. else
  481. StripStr:='-x';
  482. if (cs_link_smart in aktglobalswitches) and
  483. (tf_smartlink_sections in target_info.flags) then
  484. GCSectionsStr:='--gc-sections';
  485. If (cs_profile in aktmoduleswitches) or
  486. ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then
  487. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  488. if CShared Then
  489. begin
  490. if (target_info.system <> system_powerpc_darwin) then
  491. DynLinKStr:=DynLinkStr+' --shared'
  492. else
  493. DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
  494. end;
  495. { Write used files and libraries }
  496. WriteResponseFile(false);
  497. { Call linker }
  498. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  499. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename^));
  500. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  501. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  502. Replace(cmdstr,'$STATIC',StaticStr);
  503. Replace(cmdstr,'$STRIP',StripStr);
  504. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  505. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  506. success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,LdSupportsNoResponseFile);
  507. { Remove ReponseFile }
  508. if (success) and not(cs_link_extern in aktglobalswitches) then
  509. RemoveFile(outputexedir+Info.ResName);
  510. MakeExecutable:=success; { otherwise a recursive call to link method }
  511. end;
  512. Function TLinkerBSD.MakeSharedLibrary:boolean;
  513. var
  514. InitStr,
  515. FiniStr,
  516. SoNameStr : string[80];
  517. binstr : String;
  518. cmdstr : TCmdStr;
  519. success : boolean;
  520. begin
  521. MakeSharedLibrary:=false;
  522. if not(cs_link_extern in aktglobalswitches) then
  523. Message1(exec_i_linking,current_module.sharedlibfilename^);
  524. { Write used files and libraries }
  525. WriteResponseFile(true);
  526. InitStr:='-init FPC_LIB_START';
  527. FiniStr:='-fini FPC_LIB_EXIT';
  528. SoNameStr:='-soname '+SplitFileName(current_module.sharedlibfilename^);
  529. { Call linker }
  530. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  531. {$ifndef darwin}
  532. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
  533. {$else darwin}
  534. {$ifdef USE_SYSUTILS}
  535. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename^)));
  536. {$else USE_SYSUTILS}
  537. Replace(cmdstr,'$EXE',maybequoted(FExpand(current_module.sharedlibfilename^)));
  538. {$endif USE_SYSUTILS}
  539. {$endif darwin}
  540. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  541. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  542. Replace(cmdstr,'$INIT',InitStr);
  543. Replace(cmdstr,'$FINI',FiniStr);
  544. Replace(cmdstr,'$SONAME',SoNameStr);
  545. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,LdSupportsNoResponseFile);
  546. { Strip the library ? }
  547. if success and (cs_link_strip in aktglobalswitches) then
  548. begin
  549. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  550. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
  551. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
  552. end;
  553. { Remove ReponseFile }
  554. if (success) and not(cs_link_extern in aktglobalswitches) then
  555. RemoveFile(outputexedir+Info.ResName);
  556. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  557. end;
  558. {*****************************************************************************
  559. Initialize
  560. *****************************************************************************}
  561. initialization
  562. {$ifdef x86_64}
  563. RegisterExternalLinker(system_x86_64_FreeBSD_info,TLinkerBSD);
  564. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  565. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  566. RegisterTarget(system_x86_64_freebsd_info);
  567. {$endif}
  568. {$ifdef i386}
  569. RegisterExternalLinker(system_i386_FreeBSD_info,TLinkerBSD);
  570. RegisterExternalLinker(system_i386_NetBSD_info,TLinkerBSD);
  571. RegisterExternalLinker(system_i386_OpenBSD_info,TLinkerBSD);
  572. RegisterImport(system_i386_freebsd,timportlibbsd);
  573. RegisterExport(system_i386_freebsd,texportlibbsd);
  574. RegisterTarget(system_i386_freebsd_info);
  575. RegisterImport(system_i386_netbsd,timportlibbsd);
  576. RegisterExport(system_i386_netbsd,texportlibbsd);
  577. RegisterTarget(system_i386_netbsd_info);
  578. RegisterImport(system_i386_openbsd,timportlibbsd);
  579. RegisterExport(system_i386_openbsd,texportlibbsd);
  580. RegisterTarget(system_i386_openbsd_info);
  581. {$endif i386}
  582. {$ifdef m68k}
  583. // RegisterExternalLinker(system_m68k_FreeBSD_info,TLinkerBSD);
  584. RegisterExternalLinker(system_m68k_NetBSD_info,TLinkerBSD);
  585. RegisterImport(system_m68k_netbsd,timportlibbsd);
  586. RegisterExport(system_m68k_netbsd,texportlibbsd);
  587. RegisterTarget(system_m68k_netbsd_info);
  588. {$endif m68k}
  589. {$ifdef powerpc}
  590. // RegisterExternalLinker(system_m68k_FreeBSD_info,TLinkerBSD);
  591. RegisterExternalLinker(system_powerpc_darwin_info,TLinkerBSD);
  592. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  593. RegisterExport(system_powerpc_darwin,texportlibbsd);
  594. RegisterTarget(system_powerpc_darwin_info);
  595. RegisterExternalLinker(system_powerpc_netbsd_info,TLinkerBSD);
  596. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  597. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  598. RegisterTarget(system_powerpc_netbsd_info);
  599. {$endif powerpc}
  600. end.