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. result:='';
  418. startupfile:=GetDarwinCrt1ObjName(isdll);
  419. if startupfile<>'' then
  420. begin
  421. if not librarysearchpath.FindFile(startupfile,false,result) then
  422. result:='/usr/lib/'+startupfile;
  423. end;
  424. result:=maybequoted(result);
  425. end;
  426. Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
  427. Var
  428. linkres : TLinkRes;
  429. FilesList : TLinkRes;
  430. i : longint;
  431. HPath : TCmdStrListItem;
  432. s,s1,s2 : TCmdStr;
  433. linkdynamic : boolean;
  434. Fl1,Fl2 : Boolean;
  435. IsDarwin : Boolean;
  436. begin
  437. WriteResponseFile:=False;
  438. ReOrder:=False;
  439. linkdynamic:=False;
  440. IsDarwin:=target_info.system in systems_darwin;
  441. { set special options for some targets }
  442. if not IsDarwin Then
  443. begin
  444. linkdynamic:=not(SharedLibFiles.empty);
  445. // after this point addition of shared libs not allowed.
  446. end
  447. else
  448. begin
  449. {$ifdef MACOSX104ORHIGHER}
  450. { not sure what this is for, but gcc always links against it }
  451. if not(cs_profile in current_settings.moduleswitches) then
  452. AddSharedLibrary('SystemStubs')
  453. else
  454. AddSharedLibrary('SystemStubs_profile');
  455. {$endif MACOSX104ORHIGHER}
  456. end;
  457. if reorder Then
  458. ExpandAndApplyOrder(SharedLibFiles);
  459. { Open link.res file }
  460. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,not LdSupportsNoResponseFile);
  461. if (target_info.system in systems_darwin) and
  462. (sysrootpath<>'') then
  463. begin
  464. LinkRes.Add('-syslibroot');
  465. LinkRes.Add(sysrootpath);
  466. end;
  467. if (target_info.system in systems_darwin) then
  468. begin
  469. LinkRes.Add('-arch');
  470. case target_info.system of
  471. system_powerpc_darwin:
  472. LinkRes.Add('ppc');
  473. system_i386_darwin,
  474. system_i386_iphonesim:
  475. LinkRes.Add('i386');
  476. system_powerpc64_darwin:
  477. LinkRes.Add('ppc64');
  478. system_x86_64_darwin,
  479. system_x86_64_iphonesim:
  480. LinkRes.Add('x86_64');
  481. system_arm_darwin:
  482. { current versions of the linker require the sub-architecture type
  483. to be specified }
  484. LinkRes.Add(lower(cputypestr[current_settings.cputype]));
  485. system_aarch64_darwin:
  486. LinkRes.Add('arm64');
  487. else
  488. internalerror(2014121801);
  489. end;
  490. if MacOSXVersionMin<>'' then
  491. begin
  492. LinkRes.Add('-macosx_version_min');
  493. LinkRes.Add(MacOSXVersionMin);
  494. end
  495. else if iPhoneOSVersionMin<>'' then
  496. begin
  497. LinkRes.Add('-iphoneos_version_min');
  498. LinkRes.Add(iPhoneOSVersionMin);
  499. end;
  500. end;
  501. { Write path to search libraries }
  502. HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  503. while assigned(HPath) do
  504. begin
  505. if LdSupportsNoResponseFile then
  506. LinkRes.Add('-L'+HPath.Str)
  507. else
  508. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  509. HPath:=TCmdStrListItem(HPath.Next);
  510. end;
  511. HPath:=TCmdStrListItem(LibrarySearchPath.First);
  512. while assigned(HPath) do
  513. begin
  514. if LdSupportsNoResponseFile then
  515. LinkRes.Add('-L'+HPath.Str)
  516. else
  517. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  518. HPath:=TCmdStrListItem(HPath.Next);
  519. end;
  520. if (target_info.system in systems_darwin) then
  521. begin
  522. HPath:=TCmdStrListItem(current_module.localframeworksearchpath.First);
  523. while assigned(HPath) do
  524. begin
  525. LinkRes.Add('-F'+HPath.Str);
  526. HPath:=TCmdStrListItem(HPath.Next);
  527. end;
  528. HPath:=TCmdStrListItem(FrameworkSearchPath.First);
  529. while assigned(HPath) do
  530. begin
  531. LinkRes.Add('-F'+HPath.Str);
  532. HPath:=TCmdStrListItem(HPath.Next);
  533. end;
  534. end;
  535. { force local symbol resolution (i.e., inside the shared }
  536. { library itself) for all non-exorted symbols, otherwise }
  537. { several RTL symbols of FPC-compiled shared libraries }
  538. { will be bound to those of a single shared library or }
  539. { to the main program }
  540. if (isdll) and (target_info.system in systems_bsd) then
  541. begin
  542. LinkRes.add('VERSION');
  543. LinkRes.add('{');
  544. LinkRes.add(' {');
  545. if not texportlibunix(exportlib).exportedsymnames.empty then
  546. begin
  547. LinkRes.add(' global:');
  548. repeat
  549. LinkRes.add(' '+texportlibunix(exportlib).exportedsymnames.getfirst+';');
  550. until texportlibunix(exportlib).exportedsymnames.empty;
  551. end;
  552. LinkRes.add(' local:');
  553. LinkRes.add(' *;');
  554. LinkRes.add(' };');
  555. LinkRes.add('}');
  556. end;
  557. if not LdSupportsNoResponseFile then
  558. LinkRes.Add('INPUT(');
  559. { add objectfiles, start with prt0 always }
  560. if not (target_info.system in systems_internal_sysinit) and (prtobj<>'') then
  561. LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  562. { try to add crti and crtbegin if linking to C }
  563. if linklibc and
  564. not IsDarwin Then
  565. begin
  566. if librarysearchpath.FindFile('crti.o',false,s) then
  567. LinkRes.AddFileName(s);
  568. if ((cs_create_pic in current_settings.moduleswitches) and
  569. not (target_info.system in systems_openbsd)) or
  570. (current_module.islibrary and
  571. (target_info.system in systems_openbsd)) then
  572. begin
  573. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  574. LinkRes.AddFileName(s);
  575. end
  576. else
  577. if (cs_link_staticflag in current_settings.globalswitches) and
  578. librarysearchpath.FindFile('crtbeginT.o',false,s) then
  579. LinkRes.AddFileName(s)
  580. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  581. LinkRes.AddFileName(s);
  582. end;
  583. { main objectfiles }
  584. { Generate linkfiles.res file if needed }
  585. { Only needed on Windows, due to the limitation of 8196 characters for command line }
  586. if (LdSupportsNoResponseFile) and
  587. (source_info.system in systems_all_windows) then
  588. begin
  589. FilesList:=TLinkRes.Create(outputexedir+'linkfiles.res',false);
  590. while not ObjectFiles.Empty do
  591. begin
  592. s:=ObjectFiles.GetFirst;
  593. if s<>'' then
  594. begin
  595. repeat
  596. i:=Pos(source_info.dirsep,s);
  597. if i>0 then
  598. s[i]:=target_info.dirsep;
  599. until i=0;
  600. FilesList.Add(s);
  601. end;
  602. end;
  603. FilesList.writetodisk;
  604. FilesList.Free;
  605. end
  606. else
  607. begin
  608. while not ObjectFiles.Empty do
  609. begin
  610. s:=ObjectFiles.GetFirst;
  611. if s<>'' then
  612. if LdSupportsNoResponseFile then
  613. LinkRes.AddFileName(s)
  614. else
  615. LinkRes.AddFileName(maybequoted(s));
  616. end;
  617. end;
  618. if not LdSupportsNoResponseFile then
  619. LinkRes.Add(')');
  620. { Write staticlibraries }
  621. if not StaticLibFiles.Empty then
  622. begin
  623. if not LdSupportsNoResponseFile then
  624. LinkRes.Add('GROUP(');
  625. While not StaticLibFiles.Empty do
  626. begin
  627. S:=StaticLibFiles.GetFirst;
  628. if LdSupportsNoResponseFile then
  629. LinkRes.AddFileName(s)
  630. else
  631. LinkRes.AddFileName(maybequoted(s))
  632. end;
  633. if not LdSupportsNoResponseFile then
  634. LinkRes.Add(')');
  635. end;
  636. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  637. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  638. if not SharedLibFiles.Empty then
  639. begin
  640. if not LdSupportsNoResponseFile then
  641. LinkRes.Add('INPUT(');
  642. While not SharedLibFiles.Empty do
  643. begin
  644. S:=SharedLibFiles.GetFirst;
  645. if (s<>'c') or reorder then
  646. begin
  647. i:=Pos(target_info.sharedlibext,S);
  648. if i>0 then
  649. Delete(S,i,255);
  650. LinkRes.Add('-l'+s);
  651. end
  652. else
  653. begin
  654. linklibc:=true;
  655. linkdynamic:=false; { libc will include the ld-* for us }
  656. end;
  657. end;
  658. { be sure that libc is the last lib }
  659. if linklibc and not reorder then
  660. Begin
  661. If LibrarySuffix=' ' Then
  662. LinkRes.Add('-lc')
  663. else
  664. LinkRes.Add('-lc_'+LibrarySuffix);
  665. If LibrarySuffix='r' Then
  666. LinkRes.Add('-lc');
  667. end;
  668. { when we have -static for the linker the we also need libgcc }
  669. if (cs_link_staticflag in current_settings.globalswitches) then
  670. LinkRes.Add('-lgcc');
  671. if linkdynamic and (Info.DynamicLinker<>'') and
  672. not(target_info.system in systems_openbsd) then
  673. LinkRes.AddFileName(Info.DynamicLinker);
  674. if not LdSupportsNoResponseFile then
  675. LinkRes.Add(')');
  676. end;
  677. { frameworks for Darwin }
  678. if IsDarwin then
  679. while not FrameworkFiles.empty do
  680. begin
  681. LinkRes.Add('-framework');
  682. LinkRes.Add(FrameworkFiles.GetFirst);
  683. end;
  684. { objects which must be at the end }
  685. if linklibc and
  686. not IsDarwin Then
  687. begin
  688. if ((cs_create_pic in current_settings.moduleswitches) and
  689. not (target_info.system in systems_openbsd)) or
  690. (current_module.islibrary and
  691. (target_info.system in systems_openbsd)) then
  692. Fl1:=librarysearchpath.FindFile('crtendS.o',false,s1)
  693. else
  694. Fl1:=librarysearchpath.FindFile('crtend.o',false,s1);
  695. Fl2:=librarysearchpath.FindFile('crtn.o',false,s2);
  696. if Fl1 or Fl2 then
  697. begin
  698. LinkRes.Add('INPUT(');
  699. If Fl1 Then
  700. LinkRes.AddFileName(s1);
  701. If Fl2 Then
  702. LinkRes.AddFileName(s2);
  703. LinkRes.Add(')');
  704. end;
  705. end;
  706. { Write and Close response }
  707. linkres.writetodisk;
  708. linkres.Free;
  709. WriteResponseFile:=True;
  710. end;
  711. function TLinkerBSD.MakeExecutable:boolean;
  712. var
  713. binstr,
  714. cmdstr,
  715. mapstr,
  716. targetstr,
  717. emulstr,
  718. extdbgbinstr,
  719. extdbgcmdstr: TCmdStr;
  720. linkscript: TAsmScript;
  721. DynLinkStr : string[60];
  722. GCSectionsStr,
  723. StaticStr,
  724. StripStr : string[63];
  725. success,
  726. useshell : boolean;
  727. begin
  728. if not(cs_link_nolink in current_settings.globalswitches) then
  729. Message1(exec_i_linking,current_module.exefilename);
  730. { Create some replacements }
  731. StaticStr:='';
  732. StripStr:='';
  733. DynLinkStr:='';
  734. GCSectionsStr:='';
  735. linkscript:=nil;
  736. mapstr:='';
  737. if (cs_link_map in current_settings.globalswitches) then
  738. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
  739. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  740. to avoid creation of a i386:x86_64 arch binary }
  741. if target_info.system=system_i386_freebsd then
  742. begin
  743. targetstr:='-b elf32-i386-freebsd';
  744. emulstr:='-m elf_i386_fbsd';
  745. end
  746. else
  747. begin
  748. targetstr:='';
  749. emulstr:='';
  750. end;
  751. if (cs_link_staticflag in current_settings.globalswitches) then
  752. begin
  753. if (target_info.system=system_m68k_netbsd) and
  754. ((cs_link_on_target in current_settings.globalswitches) or
  755. (target_info.system=source_info.system)) then
  756. StaticStr:='-Bstatic'
  757. else
  758. StaticStr:='-static';
  759. end;
  760. if (cs_link_strip in current_settings.globalswitches) then
  761. if (target_info.system in systems_darwin) then
  762. StripStr:='-x'
  763. else
  764. StripStr:='-s';
  765. if (cs_link_smart in current_settings.globalswitches) and
  766. (tf_smartlink_sections in target_info.flags) then
  767. if not(target_info.system in systems_darwin) then
  768. GCSectionsStr:='--gc-sections'
  769. else
  770. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  771. if(not(target_info.system in systems_darwin) and
  772. (cs_profile in current_settings.moduleswitches)) or
  773. ((Info.DynamicLinker<>'') and
  774. ((not SharedLibFiles.Empty) or
  775. (target_info.system in systems_openbsd))) then
  776. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  777. if CShared Then
  778. begin
  779. if not(target_info.system in systems_darwin) then
  780. DynLinKStr:=DynLinkStr+' --shared'
  781. else
  782. DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
  783. end;
  784. { Use -nopie on OpenBSD if PIC support is turned off }
  785. if (target_info.system in systems_openbsd) and
  786. not(cs_create_pic in current_settings.moduleswitches) then
  787. Info.ExtraOptions:=Info.ExtraOptions+' -nopie';
  788. { -N seems to be needed on NetBSD/earm }
  789. if (target_info.system in [system_arm_netbsd]) then
  790. Info.ExtraOptions:=Info.ExtraOptions+' -N';
  791. { Write used files and libraries }
  792. WriteResponseFile(false);
  793. { Call linker }
  794. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  795. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  796. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  797. Replace(cmdstr,'$TARGET',targetstr);
  798. Replace(cmdstr,'$EMUL',EmulStr);
  799. Replace(cmdstr,'$MAP',mapstr);
  800. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  801. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  802. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  803. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  804. else
  805. Replace(cmdstr,'$FILELIST','');
  806. Replace(cmdstr,'$STATIC',StaticStr);
  807. Replace(cmdstr,'$STRIP',StripStr);
  808. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  809. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  810. if (target_info.system in systems_darwin) then
  811. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(false));
  812. BinStr:=FindUtil(utilsprefix+BinStr);
  813. { create dsym file? }
  814. extdbgbinstr:='';
  815. extdbgcmdstr:='';
  816. if (target_info.system in systems_darwin) and
  817. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  818. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  819. begin
  820. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  821. extdbgcmdstr:=maybequoted(current_module.exefilename);
  822. end;
  823. if (LdSupportsNoResponseFile) and
  824. not(cs_link_nolink in current_settings.globalswitches) then
  825. begin
  826. { we have to use a script to use the IFS hack }
  827. linkscript:=GenerateScript(outputexedir+'ppaslink');
  828. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  829. if (extdbgcmdstr<>'') then
  830. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  831. linkscript.WriteToDisk;
  832. BinStr:=linkscript.fn;
  833. if not path_absolute(BinStr) then
  834. if cs_link_on_target in current_settings.globalswitches then
  835. BinStr:='.'+target_info.dirsep+BinStr
  836. else
  837. BinStr:='.'+source_info.dirsep+BinStr;
  838. CmdStr:='';
  839. end;
  840. useshell:=not (tf_no_backquote_support in source_info.flags);
  841. success:=DoExec(BinStr,CmdStr,true,LdSupportsNoResponseFile or useshell);
  842. if (success and
  843. (extdbgbinstr<>'') and
  844. (cs_link_nolink in current_settings.globalswitches)) then
  845. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  846. { Remove ReponseFile }
  847. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  848. begin
  849. DeleteFile(outputexedir+Info.ResName);
  850. if LdSupportsNoResponseFile Then
  851. begin
  852. DeleteFile(linkscript.fn);
  853. linkscript.free
  854. end;
  855. end;
  856. { Remove linkfiles.res }
  857. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  858. DeleteFile(outputexedir+'linkfiles.res');
  859. MakeExecutable:=success; { otherwise a recursive call to link method }
  860. end;
  861. Function TLinkerBSD.MakeSharedLibrary:boolean;
  862. var
  863. InitStr,
  864. FiniStr,
  865. SoNameStr : string[80];
  866. linkscript: TAsmScript;
  867. binstr,
  868. cmdstr,
  869. mapstr,
  870. targetstr,
  871. emulstr,
  872. extdbgbinstr,
  873. extdbgcmdstr : TCmdStr;
  874. GCSectionsStr : string[63];
  875. exportedsyms: text;
  876. success : boolean;
  877. begin
  878. MakeSharedLibrary:=false;
  879. GCSectionsStr:='';
  880. mapstr:='';
  881. linkscript:=nil;
  882. if not(cs_link_nolink in current_settings.globalswitches) then
  883. Message1(exec_i_linking,current_module.sharedlibfilename);
  884. { Write used files and libraries }
  885. WriteResponseFile(true);
  886. if (cs_link_smart in current_settings.globalswitches) and
  887. (tf_smartlink_sections in target_info.flags) then
  888. if not(target_info.system in systems_darwin) then
  889. { disabled because not tested
  890. GCSectionsStr:='--gc-sections' }
  891. else
  892. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  893. if (cs_link_map in current_settings.globalswitches) then
  894. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.sharedlibfilename,'.map'));
  895. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  896. to avoid creation of a i386:x86_64 arch binary }
  897. if target_info.system=system_i386_freebsd then
  898. begin
  899. targetstr:='-b elf32-i386-freebsd';
  900. emulstr:='-m elf_i386_fbsd';
  901. end
  902. else
  903. begin
  904. targetstr:='';
  905. emulstr:='';
  906. end;
  907. InitStr:='-init FPC_LIB_START';
  908. FiniStr:='-fini FPC_LIB_EXIT';
  909. SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
  910. { Call linker }
  911. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  912. {$ifndef darwin}
  913. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  914. {$else darwin}
  915. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename)));
  916. {$endif darwin}
  917. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  918. Replace(cmdstr,'$TARGET',targetstr);
  919. Replace(cmdstr,'$EMUL',EmulStr);
  920. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  921. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  922. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  923. else
  924. Replace(cmdstr,'$FILELIST','');
  925. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  926. Replace(cmdstr,'$INIT',InitStr);
  927. Replace(cmdstr,'$FINI',FiniStr);
  928. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  929. Replace(cmdstr,'$SONAME',SoNameStr);
  930. Replace(cmdstr,'$MAP',mapstr);
  931. if (target_info.system in systems_darwin) then
  932. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
  933. BinStr:=FindUtil(utilsprefix+BinStr);
  934. { create dsym file? }
  935. extdbgbinstr:='';
  936. extdbgcmdstr:='';
  937. if (target_info.system in systems_darwin) and
  938. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  939. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  940. begin
  941. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  942. extdbgcmdstr:=maybequoted(current_module.sharedlibfilename);
  943. end;
  944. if (target_info.system in systems_darwin) then
  945. begin
  946. { exported symbols for darwin }
  947. if not texportlibunix(exportlib).exportedsymnames.empty then
  948. begin
  949. assign(exportedsyms,outputexedir+'linksyms.fpc');
  950. rewrite(exportedsyms);
  951. repeat
  952. writeln(exportedsyms,texportlibunix(exportlib).exportedsymnames.getfirst);
  953. until texportlibunix(exportlib).exportedsymnames.empty;
  954. close(exportedsyms);
  955. cmdstr:=cmdstr+' -exported_symbols_list '+maybequoted(outputexedir)+'linksyms.fpc';
  956. end;
  957. end;
  958. if (LdSupportsNoResponseFile) and
  959. not(cs_link_nolink in current_settings.globalswitches) then
  960. begin
  961. { we have to use a script to use the IFS hack }
  962. linkscript:=GenerateScript(outputexedir+'ppaslink');
  963. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  964. if (extdbgbinstr<>'') then
  965. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  966. linkscript.WriteToDisk;
  967. BinStr:=linkscript.fn;
  968. if not path_absolute(BinStr) then
  969. if cs_link_on_target in current_settings.globalswitches then
  970. BinStr:='.'+target_info.dirsep+BinStr
  971. else
  972. BinStr:='.'+source_info.dirsep+BinStr;
  973. CmdStr:='';
  974. end;
  975. success:=DoExec(BinStr,cmdstr,true,LdSupportsNoResponseFile);
  976. if (success and
  977. (extdbgbinstr<>'') and
  978. (cs_link_nolink in current_settings.globalswitches)) then
  979. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  980. { Strip the library ? }
  981. if success and (cs_link_strip in current_settings.globalswitches) then
  982. begin
  983. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  984. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  985. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
  986. end;
  987. { Remove ReponseFile }
  988. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  989. begin
  990. DeleteFile(outputexedir+Info.ResName);
  991. if LdSupportsNoResponseFile Then
  992. begin
  993. DeleteFile(linkscript.fn);
  994. linkscript.free
  995. end;
  996. if (target_info.system in systems_darwin) then
  997. DeleteFile(outputexedir+'linksyms.fpc');
  998. end;
  999. { Remove linkfiles.res }
  1000. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  1001. DeleteFile(outputexedir+'linkfiles.res');
  1002. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  1003. end;
  1004. {*****************************************************************************
  1005. Initialize
  1006. *****************************************************************************}
  1007. initialization
  1008. RegisterLinker(ld_bsd,TLinkerBSD);
  1009. {$ifdef x86_64}
  1010. RegisterImport(system_x86_64_dragonfly,timportlibbsd);
  1011. RegisterExport(system_x86_64_dragonfly,texportlibbsd);
  1012. RegisterTarget(system_x86_64_dragonfly_info);
  1013. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  1014. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  1015. RegisterTarget(system_x86_64_freebsd_info);
  1016. RegisterImport(system_x86_64_openbsd,timportlibbsd);
  1017. RegisterExport(system_x86_64_openbsd,texportlibbsd);
  1018. RegisterTarget(system_x86_64_openbsd_info);
  1019. RegisterImport(system_x86_64_netbsd,timportlibbsd);
  1020. RegisterExport(system_x86_64_netbsd,texportlibbsd);
  1021. RegisterTarget(system_x86_64_netbsd_info);
  1022. RegisterImport(system_x86_64_darwin,timportlibdarwin);
  1023. RegisterExport(system_x86_64_darwin,texportlibdarwin);
  1024. RegisterTarget(system_x86_64_darwin_info);
  1025. RegisterImport(system_x86_64_iphonesim,timportlibdarwin);
  1026. RegisterExport(system_x86_64_iphonesim,texportlibdarwin);
  1027. RegisterTarget(system_x86_64_iphonesim_info);
  1028. {$endif}
  1029. {$ifdef i386}
  1030. RegisterImport(system_i386_freebsd,timportlibbsd);
  1031. RegisterExport(system_i386_freebsd,texportlibbsd);
  1032. RegisterTarget(system_i386_freebsd_info);
  1033. RegisterImport(system_i386_netbsd,timportlibbsd);
  1034. RegisterExport(system_i386_netbsd,texportlibbsd);
  1035. RegisterTarget(system_i386_netbsd_info);
  1036. RegisterImport(system_i386_openbsd,timportlibbsd);
  1037. RegisterExport(system_i386_openbsd,texportlibbsd);
  1038. RegisterTarget(system_i386_openbsd_info);
  1039. RegisterImport(system_i386_darwin,timportlibdarwin);
  1040. RegisterExport(system_i386_darwin,texportlibdarwin);
  1041. RegisterTarget(system_i386_darwin_info);
  1042. RegisterImport(system_i386_iphonesim,timportlibdarwin);
  1043. RegisterExport(system_i386_iphonesim,texportlibdarwin);
  1044. RegisterTarget(system_i386_iphonesim_info);
  1045. {$endif i386}
  1046. {$ifdef m68k}
  1047. RegisterImport(system_m68k_netbsd,timportlibbsd);
  1048. RegisterExport(system_m68k_netbsd,texportlibbsd);
  1049. RegisterTarget(system_m68k_netbsd_info);
  1050. {$endif m68k}
  1051. {$ifdef powerpc}
  1052. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  1053. RegisterExport(system_powerpc_darwin,texportlibdarwin);
  1054. RegisterTarget(system_powerpc_darwin_info);
  1055. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  1056. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  1057. RegisterTarget(system_powerpc_netbsd_info);
  1058. {$endif powerpc}
  1059. {$ifdef powerpc64}
  1060. RegisterImport(system_powerpc64_darwin,timportlibdarwin);
  1061. RegisterExport(system_powerpc64_darwin,texportlibdarwin);
  1062. RegisterTarget(system_powerpc64_darwin_info);
  1063. {$endif powerpc64}
  1064. {$ifdef arm}
  1065. RegisterImport(system_arm_darwin,timportlibdarwin);
  1066. RegisterExport(system_arm_darwin,texportlibdarwin);
  1067. RegisterTarget(system_arm_darwin_info);
  1068. RegisterImport(system_arm_netbsd,timportlibbsd);
  1069. RegisterExport(system_arm_netbsd,texportlibbsd);
  1070. RegisterTarget(system_arm_netbsd_info);
  1071. {$endif arm}
  1072. {$ifdef aarch64}
  1073. RegisterImport(system_aarch64_darwin,timportlibdarwin);
  1074. RegisterExport(system_aarch64_darwin,texportlibdarwin);
  1075. RegisterTarget(system_aarch64_darwin_info);
  1076. {$endif aarch64}
  1077. RegisterRes(res_elf_info,TWinLikeResourceFile);
  1078. RegisterRes(res_macho_info,TWinLikeResourceFile);
  1079. end.