t_bsd.pas 39 KB

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