t_bsd.pas 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  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. sysutils,
  25. cutils,cfileutl,cclasses,
  26. verbose,systems,globtype,globals,
  27. symconst,cscript,
  28. fmodule,aasmbase,aasmtai,aasmdata,aasmcpu,cpubase,symsym,symdef,
  29. import,export,link,comprsrc,rescmn,i_bsd,expunix,
  30. cgutils,cgbase,cgobj,cpuinfo,ogbase;
  31. type
  32. timportlibdarwin=class(timportlib)
  33. procedure generatelib;override;
  34. end;
  35. timportlibbsd=class(timportlib)
  36. procedure generatelib;override;
  37. end;
  38. texportlibbsd=class(texportlibunix)
  39. end;
  40. texportlibdarwin=class(texportlibbsd)
  41. procedure setinitname(list: TAsmList; const s: string); override;
  42. procedure setfininame(list: TAsmList; const s: string); override;
  43. end;
  44. tlinkerbsd=class(texternallinker)
  45. private
  46. LdSupportsNoResponseFile : boolean;
  47. LibrarySuffix : Char;
  48. prtobj : string[80];
  49. ReOrder : Boolean;
  50. linklibc : boolean;
  51. Function WriteResponseFile(isdll:boolean) : Boolean;
  52. function GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
  53. Function GetDarwinPrtobjName(isdll: boolean): TCmdStr;
  54. Function WriteSymbolOrderFile: TCmdStr;
  55. public
  56. constructor Create;override;
  57. procedure SetDefaultInfo;override;
  58. function MakeExecutable:boolean;override;
  59. function MakeSharedLibrary:boolean;override;
  60. procedure LoadPredefinedLibraryOrder; override;
  61. procedure InitSysInitUnitName; override;
  62. end;
  63. function ModulesLinkToLibc:boolean;
  64. var
  65. hp: tmodule;
  66. begin
  67. { This is called very early, ImportLibraryList is not yet merged into linkothersharedlibs.
  68. The former contains library names qualified with prefix and suffix (coming from
  69. "external 'c' name 'foo' declarations), the latter contains raw names (from "$linklib c"
  70. directives). }
  71. hp:=tmodule(loaded_units.first);
  72. while assigned(hp) do
  73. begin
  74. result:=Assigned(hp.ImportLibraryList.find(target_info.sharedClibprefix+'c'+target_info.sharedClibext));
  75. if result then break;
  76. result:=hp.linkothersharedlibs.find(target_info.sharedClibprefix+'c'+target_info.sharedClibext);
  77. if result then break;
  78. result:=hp.linkothersharedlibs.find('c');
  79. if result then break;
  80. hp:=tmodule(hp.next);
  81. end;
  82. end;
  83. {*****************************************************************************
  84. TIMPORTLIBDARWIN
  85. *****************************************************************************}
  86. procedure timportlibdarwin.generatelib;
  87. begin
  88. end;
  89. {*****************************************************************************
  90. TEXPORTLIBDARWIN
  91. *****************************************************************************}
  92. procedure texportlibdarwin.setinitname(list: TAsmList; const s: string);
  93. begin
  94. new_section(list,sec_init_func,'',sizeof(pint));
  95. list.concat(Tai_const.Createname(s,0));
  96. end;
  97. procedure texportlibdarwin.setfininame(list: TAsmList; const s: string);
  98. begin
  99. new_section(list,sec_term_func,'',sizeof(pint));
  100. list.concat(Tai_const.Createname(s,0));
  101. end;
  102. {*****************************************************************************
  103. TIMPORTLIBBSD
  104. *****************************************************************************}
  105. procedure timportlibbsd.generatelib;
  106. var
  107. i : longint;
  108. ImportLibrary : TImportLibrary;
  109. begin
  110. for i:=0 to current_module.ImportLibraryList.Count-1 do
  111. begin
  112. ImportLibrary:=TImportLibrary(current_module.ImportLibraryList[i]);
  113. current_module.linkothersharedlibs.add(ImportLibrary.Name,link_always);
  114. end;
  115. end;
  116. {*****************************************************************************
  117. TLINKERBSD
  118. *****************************************************************************}
  119. Constructor TLinkerBSD.Create;
  120. begin
  121. Inherited Create;
  122. if not Dontlinkstdlibpath Then
  123. if target_info.system in systems_darwin then
  124. { Mac OS X doesn't have a /lib }
  125. LibrarySearchPath.AddPath(sysrootpath,'/usr/lib',true)
  126. else if target_info.system in systems_openbsd then
  127. LibrarySearchPath.AddPath(sysrootpath,'/usr/lib;$OPENBSD_X11BASE/lib;$OPENBSD_LOCALBASE/lib',true)
  128. else
  129. LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib',true);
  130. end;
  131. procedure TLinkerBSD.SetDefaultInfo;
  132. {
  133. This will also detect which libc version will be used
  134. }
  135. begin
  136. LibrarySuffix:=' ';
  137. LdSupportsNoResponseFile := (target_info.system in ([system_m68k_netbsd]+systems_darwin));
  138. with Info do
  139. begin
  140. if LdSupportsNoResponseFile then
  141. begin
  142. if not(target_info.system in systems_darwin) then
  143. begin
  144. ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -L. -o $EXE $CATRES $FILELIST';
  145. DllCmd[1]:='ld $TARGET $EMUL $OPT $MAP $ORDERSYMS -shared -L. -o $EXE $CATRES $FILELIST'
  146. end
  147. else
  148. begin
  149. {$ifndef cpu64bitaddr}
  150. { Set the size of the page at address zero to 64kb, so nothing
  151. is loaded below that address. This avoids problems with the
  152. strange Windows-compatible resource handling that assumes
  153. that addresses below 64kb do not exist.
  154. On 64bit systems, page zero is 4GB by default, so no problems
  155. there.
  156. }
  157. { In case of valgrind, don't do that, because it cannot deal with
  158. a custom pagezero size -- in general, this should not cause any
  159. problems because the resources are added at the end and most
  160. programs with problems that require Valgrind will have more
  161. than 60KB of data (first 4KB of address space is always invalid)
  162. }
  163. ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
  164. if not(cs_gdb_valgrind in current_settings.globalswitches) then
  165. ExeCmd[1]:=ExeCmd[1]+' -pagezero_size 0x10000';
  166. {$else ndef cpu64bitaddr}
  167. ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
  168. {$endif ndef cpu64bitaddr}
  169. if (apptype<>app_bundle) then
  170. DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP $ORDERSYMS -dynamic -dylib -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
  171. else
  172. DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP $ORDERSYMS -dynamic -bundle -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
  173. end
  174. end
  175. else
  176. begin
  177. ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -L. -o $EXE $RES';
  178. DllCmd[1]:='ld $TARGET $EMUL $OPT $INIT $FINI $SONAME $MAP $ORDERSYMS -shared -L. -o $EXE $RES';
  179. end;
  180. if not(target_info.system in systems_darwin) then
  181. DllCmd[2]:='strip --strip-unneeded $EXE'
  182. else
  183. DllCmd[2]:='strip -x $EXE';
  184. { OpenBSD seems to use a wrong dynamic linker by default }
  185. if target_info.system in systems_openbsd then
  186. DynamicLinker:='/usr/libexec/ld.so'
  187. else if target_info.system in systems_netbsd then
  188. DynamicLinker:='/usr/libexec/ld.elf_so'
  189. else if target_info.system=system_x86_64_dragonfly then
  190. DynamicLinker:='/libexec/ld-elf.so.2'
  191. else
  192. DynamicLinker:='';
  193. end;
  194. end;
  195. procedure TLinkerBSD.LoadPredefinedLibraryOrder;
  196. // put your linkorder/linkalias overrides here.
  197. // Note: assumes only called when reordering/aliasing is used.
  198. Begin
  199. if not(target_info.system in systems_darwin) then
  200. begin
  201. if (target_info.system =system_i386_freebsd) and
  202. not (cs_link_no_default_lib_order in current_settings.globalswitches) Then
  203. Begin
  204. LinkLibraryOrder.add('gcc','',15);
  205. LinkLibraryOrder.add('c','',50); // c and c_p mutual. excl?
  206. LinkLibraryOrder.add('c_p','',55);
  207. LinkLibraryOrder.add('pthread','',75); // pthread and c_r should be mutually exclusive
  208. LinkLibraryOrder.add('c_r','',76);
  209. LinkLibraryOrder.add('kvm','',80); // must be before ncurses
  210. if (cs_link_pthread in current_settings.globalswitches) Then // convert libpthread to libc_r.
  211. LinkLibraryAliases.add('pthread','c_r');
  212. end;
  213. end
  214. else
  215. begin
  216. LinkLibraryOrder.add('gcc','',15);
  217. LinkLibraryOrder.add('c','',50);
  218. end;
  219. End;
  220. procedure TLinkerBSD.InitSysInitUnitName;
  221. var
  222. cprtobj,
  223. gprtobj,
  224. si_cprt,
  225. si_gprt : string[80];
  226. begin
  227. if target_info.system in systems_darwin then
  228. begin
  229. { for darwin: always link dynamically against libc }
  230. linklibc := true;
  231. reorder:=reorderentries;
  232. prtobj:='';
  233. SysInitUnit:='sysinit';
  234. end
  235. else
  236. begin
  237. linklibc:=ModulesLinkToLibc;
  238. if current_module.islibrary and
  239. (target_info.system in systems_bsd) then
  240. begin
  241. prtobj:='dllprt0';
  242. cprtobj:='dllprt0';
  243. gprtobj:='dllprt0';
  244. SysInitUnit:='si_dll';
  245. si_cprt:='si_dll';
  246. si_gprt:='si_dll';
  247. end
  248. else
  249. begin
  250. prtobj:='prt0';
  251. cprtobj:='cprt0';
  252. gprtobj:='gprt0';
  253. SysInitUnit:='si_prc';
  254. si_cprt:='si_c';
  255. si_gprt:='si_g';
  256. end;
  257. // this one is a bit complex.
  258. // Only reorder for now if -XL or -XO params are given
  259. // or when -Xf.
  260. reorder:= linklibc and
  261. (
  262. ReorderEntries
  263. or
  264. (cs_link_pthread in current_settings.globalswitches));
  265. if cs_profile in current_settings.moduleswitches then
  266. begin
  267. prtobj:=gprtobj;
  268. SysInitUnit:=si_gprt;
  269. AddSharedLibrary('c');
  270. LibrarySuffix:='p';
  271. linklibc:=true;
  272. end
  273. else
  274. begin
  275. if linklibc then
  276. begin
  277. prtobj:=cprtobj;
  278. SysInitUnit:=si_cprt;
  279. end;
  280. end;
  281. end;
  282. end;
  283. function TLinkerBSD.GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
  284. begin
  285. if not isdll then
  286. begin
  287. if not(cs_profile in current_settings.moduleswitches) then
  288. begin
  289. case target_info.system of
  290. system_powerpc_darwin,
  291. system_powerpc64_darwin,
  292. system_i386_darwin,
  293. system_x86_64_darwin:
  294. begin
  295. { 10.8 and later: no crt1.* }
  296. if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then
  297. exit('');
  298. { x86: crt1.10.6.o -> crt1.10.5.o -> crt1.o }
  299. { others: crt1.10.5 -> crt1.o }
  300. if (target_info.system in [system_i386_darwin,system_x86_64_darwin]) and
  301. (CompareVersionStrings(MacOSXVersionMin,'10.6')>=0) then
  302. exit('crt1.10.6.o');
  303. if CompareVersionStrings(MacOSXVersionMin,'10.5')>=0 then
  304. exit('crt1.10.5.o');
  305. end;
  306. system_arm_darwin:
  307. begin
  308. { iOS:
  309. iOS 6 and later: nothing
  310. iOS 3.1 - 5.x: crt1.3.1.o
  311. pre-iOS 3.1: crt1.o
  312. }
  313. if (CompareVersionStrings(iPhoneOSVersionMin,'6.0')>=0) then
  314. exit('');
  315. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  316. exit('crt1.3.1.o');
  317. end;
  318. system_i386_iphonesim,
  319. system_x86_64_iphonesim:
  320. begin
  321. { "recent versions" must not use anything (https://github.com/llvm-mirror/clang/commit/e6d04f3d152a22077022cf9287d4c538a0918ab0 )
  322. What those recent versions could be, is anyone's guess. It
  323. still seems to work with 8.1 and no longer with 8.3, so use
  324. 8.1 as a cut-off point }
  325. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  326. exit('');
  327. end;
  328. system_aarch64_darwin:
  329. { never anything }
  330. exit('');
  331. end;
  332. { nothing special -> default }
  333. result:='crt1.o';
  334. end
  335. else
  336. begin
  337. result:='gcrt1.o';
  338. { 10.8 and later: tell the linker to use 'start' instead of "_main"
  339. as entry point }
  340. if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then
  341. Info.ExeCmd[1]:=Info.ExeCmd[1]+' -no_new_main';
  342. end;
  343. end
  344. else
  345. begin
  346. if (apptype=app_bundle) then
  347. begin
  348. case target_info.system of
  349. system_powerpc_darwin,
  350. system_powerpc64_darwin,
  351. system_i386_darwin,
  352. system_x86_64_darwin:
  353. begin
  354. { < 10.6: bundle1.o
  355. >= 10.6: nothing }
  356. if CompareVersionStrings(MacOSXVersionMin,'10.6')>=0 then
  357. exit('');
  358. end;
  359. system_arm_darwin,
  360. system_aarch64_darwin:
  361. begin
  362. { iOS: < 3.1: bundle1.o
  363. >= 3.1: nothing }
  364. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  365. exit('');
  366. end;
  367. system_i386_iphonesim,
  368. system_x86_64_iphonesim:
  369. begin
  370. { see rule for crt1.o }
  371. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  372. exit('');
  373. end;
  374. end;
  375. result:='bundle1.o';
  376. end
  377. else
  378. begin
  379. case target_info.system of
  380. system_powerpc_darwin,
  381. system_powerpc64_darwin,
  382. system_i386_darwin,
  383. system_x86_64_darwin:
  384. begin
  385. { >= 10.6: nothing
  386. = 10.5: dylib1.10.5.o
  387. < 10.5: dylib1.o
  388. }
  389. if CompareVersionStrings(MacOSXVersionMin,'10.6')>=0 then
  390. exit('');
  391. if CompareVersionStrings(MacOSXVersionMin,'10.5')>=0 then
  392. exit('dylib1.10.5.o');
  393. end;
  394. system_arm_darwin,
  395. system_aarch64_darwin:
  396. begin
  397. { iOS: < 3.1: dylib1.o
  398. >= 3.1: nothing }
  399. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  400. exit('');
  401. end;
  402. system_i386_iphonesim,
  403. system_x86_64_iphonesim:
  404. begin
  405. { see rule for crt1.o }
  406. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  407. exit('');
  408. end;
  409. end;
  410. result:='dylib1.o';
  411. end;
  412. end;
  413. end;
  414. Function TLinkerBSD.GetDarwinPrtobjName(isdll: boolean): TCmdStr;
  415. var
  416. startupfile: TCmdStr;
  417. begin
  418. result:='';
  419. startupfile:=GetDarwinCrt1ObjName(isdll);
  420. if startupfile<>'' then
  421. begin
  422. if not librarysearchpath.FindFile(startupfile,false,result) then
  423. result:='/usr/lib/'+startupfile;
  424. end;
  425. result:=maybequoted(result);
  426. end;
  427. function tlinkerbsd.WriteSymbolOrderFile: TCmdStr;
  428. var
  429. item: TCmdStrListItem;
  430. symfile: TScript;
  431. begin
  432. result:='';
  433. { only for darwin for now; can also enable for other platforms when using
  434. the LLVM linker }
  435. if (OrderedSymbols.Empty) or
  436. not(tf_supports_symbolorderfile in target_info.flags) then
  437. exit;
  438. symfile:=TScript.Create(outputexedir+'symbol_order.fpc');
  439. item:=TCmdStrListItem(OrderedSymbols.First);
  440. while assigned(item) do
  441. begin
  442. symfile.add(item.str);
  443. item:=TCmdStrListItem(item.next);
  444. end;
  445. symfile.WriteToDisk;
  446. result:=symfile.fn;
  447. symfile.Free;
  448. end;
  449. Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
  450. Var
  451. linkres : TLinkRes;
  452. FilesList : TLinkRes;
  453. i : longint;
  454. HPath : TCmdStrListItem;
  455. s,s1,s2 : TCmdStr;
  456. linkdynamic : boolean;
  457. Fl1,Fl2 : Boolean;
  458. IsDarwin : Boolean;
  459. begin
  460. WriteResponseFile:=False;
  461. ReOrder:=False;
  462. linkdynamic:=False;
  463. IsDarwin:=target_info.system in systems_darwin;
  464. { set special options for some targets }
  465. if not IsDarwin Then
  466. begin
  467. linkdynamic:=not(SharedLibFiles.empty);
  468. // after this point addition of shared libs not allowed.
  469. end
  470. else
  471. begin
  472. {$ifdef MACOSX104ORHIGHER}
  473. { not sure what this is for, but gcc always links against it }
  474. if not(cs_profile in current_settings.moduleswitches) then
  475. AddSharedLibrary('SystemStubs')
  476. else
  477. AddSharedLibrary('SystemStubs_profile');
  478. {$endif MACOSX104ORHIGHER}
  479. end;
  480. if reorder Then
  481. ExpandAndApplyOrder(SharedLibFiles);
  482. { Open link.res file }
  483. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,not LdSupportsNoResponseFile);
  484. if (target_info.system in systems_darwin) and
  485. (sysrootpath<>'') then
  486. begin
  487. LinkRes.Add('-syslibroot');
  488. LinkRes.Add(sysrootpath);
  489. end;
  490. if (target_info.system in systems_darwin) then
  491. begin
  492. LinkRes.Add('-arch');
  493. case target_info.system of
  494. system_powerpc_darwin:
  495. LinkRes.Add('ppc');
  496. system_i386_darwin,
  497. system_i386_iphonesim:
  498. LinkRes.Add('i386');
  499. system_powerpc64_darwin:
  500. LinkRes.Add('ppc64');
  501. system_x86_64_darwin,
  502. system_x86_64_iphonesim:
  503. LinkRes.Add('x86_64');
  504. system_arm_darwin:
  505. { current versions of the linker require the sub-architecture type
  506. to be specified }
  507. LinkRes.Add(lower(cputypestr[current_settings.cputype]));
  508. system_aarch64_darwin:
  509. LinkRes.Add('arm64');
  510. else
  511. internalerror(2014121801);
  512. end;
  513. if MacOSXVersionMin<>'' then
  514. begin
  515. LinkRes.Add('-macosx_version_min');
  516. LinkRes.Add(MacOSXVersionMin);
  517. end
  518. else if iPhoneOSVersionMin<>'' then
  519. begin
  520. LinkRes.Add('-iphoneos_version_min');
  521. LinkRes.Add(iPhoneOSVersionMin);
  522. end;
  523. end;
  524. { Write path to search libraries }
  525. HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  526. while assigned(HPath) do
  527. begin
  528. if LdSupportsNoResponseFile then
  529. LinkRes.Add('-L'+HPath.Str)
  530. else
  531. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  532. HPath:=TCmdStrListItem(HPath.Next);
  533. end;
  534. HPath:=TCmdStrListItem(LibrarySearchPath.First);
  535. while assigned(HPath) do
  536. begin
  537. if LdSupportsNoResponseFile then
  538. LinkRes.Add('-L'+HPath.Str)
  539. else
  540. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  541. HPath:=TCmdStrListItem(HPath.Next);
  542. end;
  543. if (target_info.system in systems_darwin) then
  544. begin
  545. HPath:=TCmdStrListItem(current_module.localframeworksearchpath.First);
  546. while assigned(HPath) do
  547. begin
  548. LinkRes.Add('-F'+HPath.Str);
  549. HPath:=TCmdStrListItem(HPath.Next);
  550. end;
  551. HPath:=TCmdStrListItem(FrameworkSearchPath.First);
  552. while assigned(HPath) do
  553. begin
  554. LinkRes.Add('-F'+HPath.Str);
  555. HPath:=TCmdStrListItem(HPath.Next);
  556. end;
  557. end;
  558. { force local symbol resolution (i.e., inside the shared }
  559. { library itself) for all non-exorted symbols, otherwise }
  560. { several RTL symbols of FPC-compiled shared libraries }
  561. { will be bound to those of a single shared library or }
  562. { to the main program }
  563. if (isdll) and (target_info.system in systems_bsd) then
  564. begin
  565. LinkRes.add('VERSION');
  566. LinkRes.add('{');
  567. LinkRes.add(' {');
  568. if not texportlibunix(exportlib).exportedsymnames.empty then
  569. begin
  570. LinkRes.add(' global:');
  571. repeat
  572. LinkRes.add(' '+texportlibunix(exportlib).exportedsymnames.getfirst+';');
  573. until texportlibunix(exportlib).exportedsymnames.empty;
  574. end;
  575. LinkRes.add(' local:');
  576. LinkRes.add(' *;');
  577. LinkRes.add(' };');
  578. LinkRes.add('}');
  579. end;
  580. if not LdSupportsNoResponseFile then
  581. LinkRes.Add('INPUT(');
  582. { add objectfiles, start with prt0 always }
  583. if not (target_info.system in systems_internal_sysinit) and (prtobj<>'') then
  584. LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  585. { try to add crti and crtbegin if linking to C }
  586. if linklibc and
  587. not IsDarwin Then
  588. begin
  589. if librarysearchpath.FindFile('crti.o',false,s) then
  590. LinkRes.AddFileName(s);
  591. if ((cs_create_pic in current_settings.moduleswitches) and
  592. not (target_info.system in systems_openbsd)) or
  593. (current_module.islibrary and
  594. (target_info.system in systems_openbsd)) then
  595. begin
  596. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  597. LinkRes.AddFileName(s);
  598. end
  599. else
  600. if (cs_link_staticflag in current_settings.globalswitches) and
  601. librarysearchpath.FindFile('crtbeginT.o',false,s) then
  602. LinkRes.AddFileName(s)
  603. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  604. LinkRes.AddFileName(s);
  605. end;
  606. { main objectfiles }
  607. { Generate linkfiles.res file if needed }
  608. { Only needed on Windows, due to the limitation of 8196 characters for command line }
  609. if (LdSupportsNoResponseFile) and
  610. (source_info.system in systems_all_windows) then
  611. begin
  612. FilesList:=TLinkRes.Create(outputexedir+'linkfiles.res',false);
  613. while not ObjectFiles.Empty do
  614. begin
  615. s:=ObjectFiles.GetFirst;
  616. if s<>'' then
  617. begin
  618. repeat
  619. i:=Pos(source_info.dirsep,s);
  620. if i>0 then
  621. s[i]:=target_info.dirsep;
  622. until i=0;
  623. FilesList.Add(s);
  624. end;
  625. end;
  626. FilesList.writetodisk;
  627. FilesList.Free;
  628. end
  629. else
  630. begin
  631. while not ObjectFiles.Empty do
  632. begin
  633. s:=ObjectFiles.GetFirst;
  634. if s<>'' then
  635. if LdSupportsNoResponseFile then
  636. LinkRes.AddFileName(s)
  637. else
  638. LinkRes.AddFileName(maybequoted(s));
  639. end;
  640. end;
  641. if not LdSupportsNoResponseFile then
  642. LinkRes.Add(')');
  643. { Write staticlibraries }
  644. if not StaticLibFiles.Empty then
  645. begin
  646. if not LdSupportsNoResponseFile then
  647. LinkRes.Add('GROUP(');
  648. While not StaticLibFiles.Empty do
  649. begin
  650. S:=StaticLibFiles.GetFirst;
  651. if LdSupportsNoResponseFile then
  652. LinkRes.AddFileName(s)
  653. else
  654. LinkRes.AddFileName(maybequoted(s))
  655. end;
  656. if not LdSupportsNoResponseFile then
  657. LinkRes.Add(')');
  658. end;
  659. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  660. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  661. if not SharedLibFiles.Empty then
  662. begin
  663. if not LdSupportsNoResponseFile then
  664. LinkRes.Add('INPUT(');
  665. While not SharedLibFiles.Empty do
  666. begin
  667. S:=SharedLibFiles.GetFirst;
  668. if (s<>'c') or reorder then
  669. begin
  670. i:=Pos(target_info.sharedlibext,S);
  671. if i>0 then
  672. Delete(S,i,255);
  673. LinkRes.Add('-l'+s);
  674. end
  675. else
  676. begin
  677. linklibc:=true;
  678. linkdynamic:=false; { libc will include the ld-* for us }
  679. end;
  680. end;
  681. { be sure that libc is the last lib }
  682. if linklibc and not reorder then
  683. Begin
  684. If LibrarySuffix=' ' Then
  685. LinkRes.Add('-lc')
  686. else
  687. LinkRes.Add('-lc_'+LibrarySuffix);
  688. If LibrarySuffix='r' Then
  689. LinkRes.Add('-lc');
  690. end;
  691. { when we have -static for the linker the we also need libgcc }
  692. if (cs_link_staticflag in current_settings.globalswitches) then
  693. LinkRes.Add('-lgcc');
  694. if linkdynamic and (Info.DynamicLinker<>'') and
  695. not(target_info.system in systems_openbsd) then
  696. LinkRes.AddFileName(Info.DynamicLinker);
  697. if not LdSupportsNoResponseFile then
  698. LinkRes.Add(')');
  699. end;
  700. { frameworks for Darwin }
  701. if IsDarwin then
  702. while not FrameworkFiles.empty do
  703. begin
  704. LinkRes.Add('-framework');
  705. LinkRes.Add(FrameworkFiles.GetFirst);
  706. end;
  707. { objects which must be at the end }
  708. if linklibc and
  709. not IsDarwin Then
  710. begin
  711. if ((cs_create_pic in current_settings.moduleswitches) and
  712. not (target_info.system in systems_openbsd)) or
  713. (current_module.islibrary and
  714. (target_info.system in systems_openbsd)) then
  715. Fl1:=librarysearchpath.FindFile('crtendS.o',false,s1)
  716. else
  717. Fl1:=librarysearchpath.FindFile('crtend.o',false,s1);
  718. Fl2:=librarysearchpath.FindFile('crtn.o',false,s2);
  719. if Fl1 or Fl2 then
  720. begin
  721. LinkRes.Add('INPUT(');
  722. If Fl1 Then
  723. LinkRes.AddFileName(s1);
  724. If Fl2 Then
  725. LinkRes.AddFileName(s2);
  726. LinkRes.Add(')');
  727. end;
  728. end;
  729. { Write and Close response }
  730. linkres.writetodisk;
  731. linkres.Free;
  732. WriteResponseFile:=True;
  733. end;
  734. function TLinkerBSD.MakeExecutable:boolean;
  735. var
  736. binstr,
  737. cmdstr,
  738. mapstr,
  739. targetstr,
  740. emulstr,
  741. extdbgbinstr,
  742. extdbgcmdstr,
  743. ordersymfile: TCmdStr;
  744. linkscript: TAsmScript;
  745. DynLinkStr : string[60];
  746. GCSectionsStr,
  747. StaticStr,
  748. StripStr : string[63];
  749. success,
  750. useshell : boolean;
  751. begin
  752. if not(cs_link_nolink in current_settings.globalswitches) then
  753. Message1(exec_i_linking,current_module.exefilename);
  754. { Create some replacements }
  755. StaticStr:='';
  756. StripStr:='';
  757. DynLinkStr:='';
  758. GCSectionsStr:='';
  759. linkscript:=nil;
  760. mapstr:='';
  761. if (cs_link_map in current_settings.globalswitches) then
  762. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
  763. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  764. to avoid creation of a i386:x86_64 arch binary }
  765. if target_info.system=system_i386_freebsd then
  766. begin
  767. targetstr:='-b elf32-i386-freebsd';
  768. emulstr:='-m elf_i386_fbsd';
  769. end
  770. else
  771. begin
  772. targetstr:='';
  773. emulstr:='';
  774. end;
  775. if (cs_link_staticflag in current_settings.globalswitches) then
  776. begin
  777. if (target_info.system=system_m68k_netbsd) and
  778. ((cs_link_on_target in current_settings.globalswitches) or
  779. (target_info.system=source_info.system)) then
  780. StaticStr:='-Bstatic'
  781. else
  782. StaticStr:='-static';
  783. end;
  784. if (cs_link_strip in current_settings.globalswitches) then
  785. if (target_info.system in systems_darwin) then
  786. StripStr:='-x'
  787. else
  788. StripStr:='-s';
  789. if (cs_link_smart in current_settings.globalswitches) and
  790. (tf_smartlink_sections in target_info.flags) then
  791. if not(target_info.system in systems_darwin) then
  792. GCSectionsStr:='--gc-sections'
  793. else
  794. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  795. if(not(target_info.system in systems_darwin) and
  796. (cs_profile in current_settings.moduleswitches)) or
  797. ((Info.DynamicLinker<>'') and
  798. ((not SharedLibFiles.Empty) or
  799. (target_info.system in systems_openbsd))) then
  800. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  801. if CShared Then
  802. begin
  803. if not(target_info.system in systems_darwin) then
  804. DynLinKStr:=DynLinkStr+' --shared'
  805. else
  806. DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
  807. end;
  808. { Use -nopie on OpenBSD if PIC support is turned off }
  809. if (target_info.system in systems_openbsd) and
  810. not(cs_create_pic in current_settings.moduleswitches) then
  811. Info.ExtraOptions:=Info.ExtraOptions+' -nopie';
  812. { -N seems to be needed on NetBSD/earm }
  813. if (target_info.system in [system_arm_netbsd]) then
  814. Info.ExtraOptions:=Info.ExtraOptions+' -N';
  815. { Write used files and libraries }
  816. WriteResponseFile(false);
  817. { Write symbol order file }
  818. ordersymfile:=WriteSymbolOrderFile;
  819. { Call linker }
  820. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  821. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  822. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  823. Replace(cmdstr,'$TARGET',targetstr);
  824. Replace(cmdstr,'$EMUL',EmulStr);
  825. Replace(cmdstr,'$MAP',mapstr);
  826. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  827. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  828. if ordersymfile<>'' then
  829. begin
  830. if target_info.system in systems_darwin then
  831. Replace(cmdstr,'$ORDERSYMS','-order_file '+maybequoted(ordersymfile))
  832. else
  833. Replace(cmdstr,'$ORDERSYMS','--symbol-ordering-file '+maybequoted(ordersymfile))
  834. end
  835. else
  836. Replace(cmdstr,'$ORDERSYMS','');
  837. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  838. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  839. else
  840. Replace(cmdstr,'$FILELIST','');
  841. Replace(cmdstr,'$STATIC',StaticStr);
  842. Replace(cmdstr,'$STRIP',StripStr);
  843. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  844. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  845. if (target_info.system in systems_darwin) then
  846. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(false));
  847. BinStr:=FindUtil(utilsprefix+BinStr);
  848. { create dsym file? }
  849. extdbgbinstr:='';
  850. extdbgcmdstr:='';
  851. if (target_info.system in systems_darwin) and
  852. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  853. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  854. begin
  855. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  856. extdbgcmdstr:=maybequoted(current_module.exefilename);
  857. end;
  858. if (LdSupportsNoResponseFile) and
  859. not(cs_link_nolink in current_settings.globalswitches) then
  860. begin
  861. { we have to use a script to use the IFS hack }
  862. linkscript:=GenerateScript(outputexedir+'ppaslink');
  863. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  864. if (extdbgcmdstr<>'') then
  865. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  866. linkscript.WriteToDisk;
  867. BinStr:=linkscript.fn;
  868. if not path_absolute(BinStr) then
  869. if cs_link_on_target in current_settings.globalswitches then
  870. BinStr:='.'+target_info.dirsep+BinStr
  871. else
  872. BinStr:='.'+source_info.dirsep+BinStr;
  873. CmdStr:='';
  874. end;
  875. useshell:=not (tf_no_backquote_support in source_info.flags);
  876. success:=DoExec(BinStr,CmdStr,true,LdSupportsNoResponseFile or useshell);
  877. if (success and
  878. (extdbgbinstr<>'') and
  879. (cs_link_nolink in current_settings.globalswitches)) then
  880. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  881. { Remove ReponseFile }
  882. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  883. begin
  884. DeleteFile(outputexedir+Info.ResName);
  885. if ordersymfile<>'' then
  886. DeleteFile(ordersymfile);
  887. if LdSupportsNoResponseFile Then
  888. begin
  889. DeleteFile(linkscript.fn);
  890. linkscript.free
  891. end;
  892. end;
  893. { Remove linkfiles.res }
  894. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  895. DeleteFile(outputexedir+'linkfiles.res');
  896. MakeExecutable:=success; { otherwise a recursive call to link method }
  897. end;
  898. Function TLinkerBSD.MakeSharedLibrary:boolean;
  899. var
  900. InitStr,
  901. FiniStr,
  902. SoNameStr : string[80];
  903. linkscript: TAsmScript;
  904. binstr,
  905. cmdstr,
  906. mapstr,
  907. ordersymfile,
  908. targetstr,
  909. emulstr,
  910. extdbgbinstr,
  911. extdbgcmdstr : TCmdStr;
  912. GCSectionsStr : string[63];
  913. exportedsyms: text;
  914. success : boolean;
  915. begin
  916. MakeSharedLibrary:=false;
  917. GCSectionsStr:='';
  918. mapstr:='';
  919. linkscript:=nil;
  920. if not(cs_link_nolink in current_settings.globalswitches) then
  921. Message1(exec_i_linking,current_module.sharedlibfilename);
  922. { Write used files and libraries }
  923. WriteResponseFile(true);
  924. { Write symbol order file }
  925. ordersymfile:=WriteSymbolOrderFile;
  926. if (cs_link_smart in current_settings.globalswitches) and
  927. (tf_smartlink_sections in target_info.flags) then
  928. if not(target_info.system in systems_darwin) then
  929. { disabled because not tested
  930. GCSectionsStr:='--gc-sections' }
  931. else
  932. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  933. if (cs_link_map in current_settings.globalswitches) then
  934. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.sharedlibfilename,'.map'));
  935. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  936. to avoid creation of a i386:x86_64 arch binary }
  937. if target_info.system=system_i386_freebsd then
  938. begin
  939. targetstr:='-b elf32-i386-freebsd';
  940. emulstr:='-m elf_i386_fbsd';
  941. end
  942. else
  943. begin
  944. targetstr:='';
  945. emulstr:='';
  946. end;
  947. InitStr:='-init FPC_LIB_START';
  948. FiniStr:='-fini FPC_LIB_EXIT';
  949. SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
  950. { Call linker }
  951. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  952. {$ifndef darwin}
  953. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  954. {$else darwin}
  955. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename)));
  956. {$endif darwin}
  957. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  958. Replace(cmdstr,'$TARGET',targetstr);
  959. Replace(cmdstr,'$EMUL',EmulStr);
  960. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  961. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  962. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  963. else
  964. Replace(cmdstr,'$FILELIST','');
  965. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  966. Replace(cmdstr,'$INIT',InitStr);
  967. Replace(cmdstr,'$FINI',FiniStr);
  968. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  969. Replace(cmdstr,'$SONAME',SoNameStr);
  970. Replace(cmdstr,'$MAP',mapstr);
  971. if ordersymfile<>'' then
  972. begin
  973. if target_info.system in systems_darwin then
  974. Replace(cmdstr,'$ORDERSYMS','-order_file '+maybequoted(ordersymfile))
  975. else
  976. Replace(cmdstr,'$ORDERSYMS','--symbol-ordering-file '+maybequoted(ordersymfile))
  977. end
  978. else
  979. Replace(cmdstr,'$ORDERSYMS','');
  980. if (target_info.system in systems_darwin) then
  981. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
  982. BinStr:=FindUtil(utilsprefix+BinStr);
  983. { create dsym file? }
  984. extdbgbinstr:='';
  985. extdbgcmdstr:='';
  986. if (target_info.system in systems_darwin) and
  987. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  988. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  989. begin
  990. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  991. extdbgcmdstr:=maybequoted(current_module.sharedlibfilename);
  992. end;
  993. if (target_info.system in systems_darwin) then
  994. begin
  995. { exported symbols for darwin }
  996. if not texportlibunix(exportlib).exportedsymnames.empty then
  997. begin
  998. assign(exportedsyms,outputexedir+'linksyms.fpc');
  999. rewrite(exportedsyms);
  1000. repeat
  1001. writeln(exportedsyms,texportlibunix(exportlib).exportedsymnames.getfirst);
  1002. until texportlibunix(exportlib).exportedsymnames.empty;
  1003. close(exportedsyms);
  1004. cmdstr:=cmdstr+' -exported_symbols_list '+maybequoted(outputexedir)+'linksyms.fpc';
  1005. end;
  1006. end;
  1007. if (LdSupportsNoResponseFile) and
  1008. not(cs_link_nolink in current_settings.globalswitches) then
  1009. begin
  1010. { we have to use a script to use the IFS hack }
  1011. linkscript:=GenerateScript(outputexedir+'ppaslink');
  1012. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  1013. if (extdbgbinstr<>'') then
  1014. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  1015. linkscript.WriteToDisk;
  1016. BinStr:=linkscript.fn;
  1017. if not path_absolute(BinStr) then
  1018. if cs_link_on_target in current_settings.globalswitches then
  1019. BinStr:='.'+target_info.dirsep+BinStr
  1020. else
  1021. BinStr:='.'+source_info.dirsep+BinStr;
  1022. CmdStr:='';
  1023. end;
  1024. success:=DoExec(BinStr,cmdstr,true,LdSupportsNoResponseFile);
  1025. if (success and
  1026. (extdbgbinstr<>'') and
  1027. (cs_link_nolink in current_settings.globalswitches)) then
  1028. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  1029. { Strip the library ? }
  1030. if success and (cs_link_strip in current_settings.globalswitches) then
  1031. begin
  1032. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  1033. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  1034. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
  1035. end;
  1036. { Remove ReponseFile }
  1037. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  1038. begin
  1039. DeleteFile(outputexedir+Info.ResName);
  1040. if ordersymfile<>'' then
  1041. DeleteFile(ordersymfile);
  1042. if LdSupportsNoResponseFile Then
  1043. begin
  1044. DeleteFile(linkscript.fn);
  1045. linkscript.free
  1046. end;
  1047. if (target_info.system in systems_darwin) then
  1048. DeleteFile(outputexedir+'linksyms.fpc');
  1049. end;
  1050. { Remove linkfiles.res }
  1051. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  1052. DeleteFile(outputexedir+'linkfiles.res');
  1053. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  1054. end;
  1055. {*****************************************************************************
  1056. Initialize
  1057. *****************************************************************************}
  1058. initialization
  1059. RegisterLinker(ld_bsd,TLinkerBSD);
  1060. {$ifdef x86_64}
  1061. RegisterImport(system_x86_64_dragonfly,timportlibbsd);
  1062. RegisterExport(system_x86_64_dragonfly,texportlibbsd);
  1063. RegisterTarget(system_x86_64_dragonfly_info);
  1064. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  1065. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  1066. RegisterTarget(system_x86_64_freebsd_info);
  1067. RegisterImport(system_x86_64_openbsd,timportlibbsd);
  1068. RegisterExport(system_x86_64_openbsd,texportlibbsd);
  1069. RegisterTarget(system_x86_64_openbsd_info);
  1070. RegisterImport(system_x86_64_netbsd,timportlibbsd);
  1071. RegisterExport(system_x86_64_netbsd,texportlibbsd);
  1072. RegisterTarget(system_x86_64_netbsd_info);
  1073. RegisterImport(system_x86_64_darwin,timportlibdarwin);
  1074. RegisterExport(system_x86_64_darwin,texportlibdarwin);
  1075. RegisterTarget(system_x86_64_darwin_info);
  1076. RegisterImport(system_x86_64_iphonesim,timportlibdarwin);
  1077. RegisterExport(system_x86_64_iphonesim,texportlibdarwin);
  1078. RegisterTarget(system_x86_64_iphonesim_info);
  1079. {$endif}
  1080. {$ifdef i386}
  1081. RegisterImport(system_i386_freebsd,timportlibbsd);
  1082. RegisterExport(system_i386_freebsd,texportlibbsd);
  1083. RegisterTarget(system_i386_freebsd_info);
  1084. RegisterImport(system_i386_netbsd,timportlibbsd);
  1085. RegisterExport(system_i386_netbsd,texportlibbsd);
  1086. RegisterTarget(system_i386_netbsd_info);
  1087. RegisterImport(system_i386_openbsd,timportlibbsd);
  1088. RegisterExport(system_i386_openbsd,texportlibbsd);
  1089. RegisterTarget(system_i386_openbsd_info);
  1090. RegisterImport(system_i386_darwin,timportlibdarwin);
  1091. RegisterExport(system_i386_darwin,texportlibdarwin);
  1092. RegisterTarget(system_i386_darwin_info);
  1093. RegisterImport(system_i386_iphonesim,timportlibdarwin);
  1094. RegisterExport(system_i386_iphonesim,texportlibdarwin);
  1095. RegisterTarget(system_i386_iphonesim_info);
  1096. {$endif i386}
  1097. {$ifdef m68k}
  1098. RegisterImport(system_m68k_netbsd,timportlibbsd);
  1099. RegisterExport(system_m68k_netbsd,texportlibbsd);
  1100. RegisterTarget(system_m68k_netbsd_info);
  1101. {$endif m68k}
  1102. {$ifdef powerpc}
  1103. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  1104. RegisterExport(system_powerpc_darwin,texportlibdarwin);
  1105. RegisterTarget(system_powerpc_darwin_info);
  1106. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  1107. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  1108. RegisterTarget(system_powerpc_netbsd_info);
  1109. {$endif powerpc}
  1110. {$ifdef powerpc64}
  1111. RegisterImport(system_powerpc64_darwin,timportlibdarwin);
  1112. RegisterExport(system_powerpc64_darwin,texportlibdarwin);
  1113. RegisterTarget(system_powerpc64_darwin_info);
  1114. {$endif powerpc64}
  1115. {$ifdef arm}
  1116. RegisterImport(system_arm_darwin,timportlibdarwin);
  1117. RegisterExport(system_arm_darwin,texportlibdarwin);
  1118. RegisterTarget(system_arm_darwin_info);
  1119. RegisterImport(system_arm_netbsd,timportlibbsd);
  1120. RegisterExport(system_arm_netbsd,texportlibbsd);
  1121. RegisterTarget(system_arm_netbsd_info);
  1122. {$endif arm}
  1123. {$ifdef aarch64}
  1124. RegisterImport(system_aarch64_darwin,timportlibdarwin);
  1125. RegisterExport(system_aarch64_darwin,texportlibdarwin);
  1126. RegisterTarget(system_aarch64_darwin_info);
  1127. {$endif aarch64}
  1128. RegisterRes(res_elf_info,TWinLikeResourceFile);
  1129. RegisterRes(res_macho_info,TWinLikeResourceFile);
  1130. end.