t_bsd.pas 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  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;${X11BASE}/lib;${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 -L. -o $EXE $CATRES $FILELIST';
  144. DllCmd[1]:='ld $TARGET $EMUL $OPT -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 -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 -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 -dynamic -dylib -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
  170. else
  171. DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS -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 -L. -o $EXE $RES';
  177. DllCmd[1]:='ld $TARGET $EMUL $OPT $INIT $FINI $SONAME -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 then
  570. begin
  571. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  572. LinkRes.AddFileName(s);
  573. end
  574. else
  575. if (cs_link_staticflag in current_settings.globalswitches) and
  576. librarysearchpath.FindFile('crtbeginT.o',false,s) then
  577. LinkRes.AddFileName(s)
  578. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  579. LinkRes.AddFileName(s);
  580. end;
  581. { main objectfiles }
  582. { Generate linkfiles.res file if needed }
  583. { Only needed on Windows, due to the limitation of 8196 characters for command line }
  584. if (LdSupportsNoResponseFile) and
  585. (source_info.system in systems_all_windows) then
  586. begin
  587. FilesList:=TLinkRes.Create(outputexedir+'linkfiles.res',false);
  588. while not ObjectFiles.Empty do
  589. begin
  590. s:=ObjectFiles.GetFirst;
  591. if s<>'' then
  592. begin
  593. repeat
  594. i:=Pos(source_info.dirsep,s);
  595. if i>0 then
  596. s[i]:=target_info.dirsep;
  597. until i=0;
  598. FilesList.Add(s);
  599. end;
  600. end;
  601. FilesList.writetodisk;
  602. FilesList.Free;
  603. end
  604. else
  605. begin
  606. while not ObjectFiles.Empty do
  607. begin
  608. s:=ObjectFiles.GetFirst;
  609. if s<>'' then
  610. if LdSupportsNoResponseFile then
  611. LinkRes.AddFileName(s)
  612. else
  613. LinkRes.AddFileName(maybequoted(s));
  614. end;
  615. end;
  616. if not LdSupportsNoResponseFile then
  617. LinkRes.Add(')');
  618. { Write staticlibraries }
  619. if not StaticLibFiles.Empty then
  620. begin
  621. if not LdSupportsNoResponseFile then
  622. LinkRes.Add('GROUP(');
  623. While not StaticLibFiles.Empty do
  624. begin
  625. S:=StaticLibFiles.GetFirst;
  626. if LdSupportsNoResponseFile then
  627. LinkRes.AddFileName(s)
  628. else
  629. LinkRes.AddFileName(maybequoted(s))
  630. end;
  631. if not LdSupportsNoResponseFile then
  632. LinkRes.Add(')');
  633. end;
  634. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  635. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  636. if not SharedLibFiles.Empty then
  637. begin
  638. if not LdSupportsNoResponseFile then
  639. LinkRes.Add('INPUT(');
  640. While not SharedLibFiles.Empty do
  641. begin
  642. S:=SharedLibFiles.GetFirst;
  643. if (s<>'c') or reorder then
  644. begin
  645. i:=Pos(target_info.sharedlibext,S);
  646. if i>0 then
  647. Delete(S,i,255);
  648. LinkRes.Add('-l'+s);
  649. end
  650. else
  651. begin
  652. linklibc:=true;
  653. linkdynamic:=false; { libc will include the ld-* for us }
  654. end;
  655. end;
  656. { be sure that libc is the last lib }
  657. if linklibc and not reorder then
  658. Begin
  659. If LibrarySuffix=' ' Then
  660. LinkRes.Add('-lc')
  661. else
  662. LinkRes.Add('-lc_'+LibrarySuffix);
  663. If LibrarySuffix='r' Then
  664. LinkRes.Add('-lc');
  665. end;
  666. { when we have -static for the linker the we also need libgcc }
  667. if (cs_link_staticflag in current_settings.globalswitches) then
  668. LinkRes.Add('-lgcc');
  669. if linkdynamic and (Info.DynamicLinker<>'') and
  670. not(target_info.system in systems_openbsd) then
  671. LinkRes.AddFileName(Info.DynamicLinker);
  672. if not LdSupportsNoResponseFile then
  673. LinkRes.Add(')');
  674. end;
  675. { frameworks for Darwin }
  676. if IsDarwin then
  677. while not FrameworkFiles.empty do
  678. begin
  679. LinkRes.Add('-framework');
  680. LinkRes.Add(FrameworkFiles.GetFirst);
  681. end;
  682. { objects which must be at the end }
  683. if linklibc and
  684. not IsDarwin Then
  685. begin
  686. if cs_create_pic in current_settings.moduleswitches then
  687. Fl1:=librarysearchpath.FindFile('crtendS.o',false,s1)
  688. else
  689. Fl1:=librarysearchpath.FindFile('crtend.o',false,s1);
  690. Fl2:=librarysearchpath.FindFile('crtn.o',false,s2);
  691. if Fl1 or Fl2 then
  692. begin
  693. LinkRes.Add('INPUT(');
  694. If Fl1 Then
  695. LinkRes.AddFileName(s1);
  696. If Fl2 Then
  697. LinkRes.AddFileName(s2);
  698. LinkRes.Add(')');
  699. end;
  700. end;
  701. { Write and Close response }
  702. linkres.writetodisk;
  703. linkres.Free;
  704. WriteResponseFile:=True;
  705. end;
  706. function TLinkerBSD.MakeExecutable:boolean;
  707. var
  708. binstr,
  709. cmdstr,
  710. targetstr,
  711. emulstr,
  712. extdbgbinstr,
  713. extdbgcmdstr: TCmdStr;
  714. linkscript: TAsmScript;
  715. DynLinkStr : string[60];
  716. GCSectionsStr,
  717. StaticStr,
  718. StripStr : string[63];
  719. success,
  720. useshell : boolean;
  721. begin
  722. if not(cs_link_nolink in current_settings.globalswitches) then
  723. Message1(exec_i_linking,current_module.exefilename);
  724. { Create some replacements }
  725. StaticStr:='';
  726. StripStr:='';
  727. DynLinkStr:='';
  728. GCSectionsStr:='';
  729. linkscript:=nil;
  730. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  731. to avoid creation of a i386:x86_64 arch binary }
  732. if target_info.system=system_i386_freebsd then
  733. begin
  734. targetstr:='-b elf32-i386-freebsd';
  735. emulstr:='-m elf_i386_fbsd';
  736. end
  737. else
  738. begin
  739. targetstr:='';
  740. emulstr:='';
  741. end;
  742. if (cs_link_staticflag in current_settings.globalswitches) then
  743. begin
  744. if (target_info.system=system_m68k_netbsd) and
  745. ((cs_link_on_target in current_settings.globalswitches) or
  746. (target_info.system=source_info.system)) then
  747. StaticStr:='-Bstatic'
  748. else
  749. StaticStr:='-static';
  750. end;
  751. if (cs_link_strip in current_settings.globalswitches) then
  752. if (target_info.system in systems_darwin) then
  753. StripStr:='-x'
  754. else
  755. StripStr:='-s';
  756. if (cs_link_smart in current_settings.globalswitches) and
  757. (tf_smartlink_sections in target_info.flags) then
  758. if not(target_info.system in systems_darwin) then
  759. GCSectionsStr:='--gc-sections'
  760. else
  761. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  762. if(not(target_info.system in systems_darwin) and
  763. (cs_profile in current_settings.moduleswitches)) or
  764. ((Info.DynamicLinker<>'') and
  765. ((not SharedLibFiles.Empty) or
  766. (target_info.system in systems_openbsd))) then
  767. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  768. if CShared Then
  769. begin
  770. if not(target_info.system in systems_darwin) then
  771. DynLinKStr:=DynLinkStr+' --shared'
  772. else
  773. DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
  774. end;
  775. { Use -nopie on OpenBSD if PIC support is turned off }
  776. if (target_info.system in systems_openbsd) and
  777. not(cs_create_pic in current_settings.moduleswitches) then
  778. Info.ExtraOptions:=Info.ExtraOptions+' -nopie';
  779. { -N seems to be needed on NetBSD/earm }
  780. if (target_info.system in [system_arm_netbsd]) then
  781. Info.ExtraOptions:=Info.ExtraOptions+' -N';
  782. { Write used files and libraries }
  783. WriteResponseFile(false);
  784. { Call linker }
  785. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  786. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  787. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  788. Replace(cmdstr,'$TARGET',targetstr);
  789. Replace(cmdstr,'$EMUL',EmulStr);
  790. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  791. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  792. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  793. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  794. else
  795. Replace(cmdstr,'$FILELIST','');
  796. Replace(cmdstr,'$STATIC',StaticStr);
  797. Replace(cmdstr,'$STRIP',StripStr);
  798. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  799. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  800. if (target_info.system in systems_darwin) then
  801. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(false));
  802. BinStr:=FindUtil(utilsprefix+BinStr);
  803. { create dsym file? }
  804. extdbgbinstr:='';
  805. extdbgcmdstr:='';
  806. if (target_info.system in systems_darwin) and
  807. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  808. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  809. begin
  810. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  811. extdbgcmdstr:=maybequoted(current_module.exefilename);
  812. end;
  813. if (LdSupportsNoResponseFile) and
  814. not(cs_link_nolink in current_settings.globalswitches) then
  815. begin
  816. { we have to use a script to use the IFS hack }
  817. linkscript:=GenerateScript(outputexedir+'ppaslink');
  818. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  819. if (extdbgcmdstr<>'') then
  820. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  821. linkscript.WriteToDisk;
  822. BinStr:=linkscript.fn;
  823. if not path_absolute(BinStr) then
  824. if cs_link_on_target in current_settings.globalswitches then
  825. BinStr:='.'+target_info.dirsep+BinStr
  826. else
  827. BinStr:='.'+source_info.dirsep+BinStr;
  828. CmdStr:='';
  829. end;
  830. useshell:=not (tf_no_backquote_support in source_info.flags);
  831. success:=DoExec(BinStr,CmdStr,true,LdSupportsNoResponseFile or useshell);
  832. if (success and
  833. (extdbgbinstr<>'') and
  834. (cs_link_nolink in current_settings.globalswitches)) then
  835. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  836. { Remove ReponseFile }
  837. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  838. begin
  839. DeleteFile(outputexedir+Info.ResName);
  840. if LdSupportsNoResponseFile Then
  841. begin
  842. DeleteFile(linkscript.fn);
  843. linkscript.free
  844. end;
  845. end;
  846. { Remove linkfiles.res }
  847. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  848. DeleteFile(outputexedir+'linkfiles.res');
  849. MakeExecutable:=success; { otherwise a recursive call to link method }
  850. end;
  851. Function TLinkerBSD.MakeSharedLibrary:boolean;
  852. var
  853. InitStr,
  854. FiniStr,
  855. SoNameStr : string[80];
  856. linkscript: TAsmScript;
  857. binstr,
  858. cmdstr,
  859. targetstr,
  860. emulstr,
  861. extdbgbinstr,
  862. extdbgcmdstr : TCmdStr;
  863. GCSectionsStr : string[63];
  864. exportedsyms: text;
  865. success : boolean;
  866. begin
  867. MakeSharedLibrary:=false;
  868. GCSectionsStr:='';
  869. linkscript:=nil;
  870. if not(cs_link_nolink in current_settings.globalswitches) then
  871. Message1(exec_i_linking,current_module.sharedlibfilename);
  872. { Write used files and libraries }
  873. WriteResponseFile(true);
  874. if (cs_link_smart in current_settings.globalswitches) and
  875. (tf_smartlink_sections in target_info.flags) then
  876. if not(target_info.system in systems_darwin) then
  877. { disabled because not tested
  878. GCSectionsStr:='--gc-sections' }
  879. else
  880. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  881. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  882. to avoid creation of a i386:x86_64 arch binary }
  883. if target_info.system=system_i386_freebsd then
  884. begin
  885. targetstr:='-b elf32-i386-freebsd';
  886. emulstr:='-m elf_i386_fbsd';
  887. end
  888. else
  889. begin
  890. targetstr:='';
  891. emulstr:='';
  892. end;
  893. InitStr:='-init FPC_LIB_START';
  894. FiniStr:='-fini FPC_LIB_EXIT';
  895. SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
  896. { Call linker }
  897. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  898. {$ifndef darwin}
  899. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  900. {$else darwin}
  901. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename)));
  902. {$endif darwin}
  903. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  904. Replace(cmdstr,'$TARGET',targetstr);
  905. Replace(cmdstr,'$EMUL',EmulStr);
  906. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  907. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  908. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  909. else
  910. Replace(cmdstr,'$FILELIST','');
  911. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  912. Replace(cmdstr,'$INIT',InitStr);
  913. Replace(cmdstr,'$FINI',FiniStr);
  914. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  915. Replace(cmdstr,'$SONAME',SoNameStr);
  916. if (target_info.system in systems_darwin) then
  917. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
  918. BinStr:=FindUtil(utilsprefix+BinStr);
  919. { create dsym file? }
  920. extdbgbinstr:='';
  921. extdbgcmdstr:='';
  922. if (target_info.system in systems_darwin) and
  923. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  924. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  925. begin
  926. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  927. extdbgcmdstr:=maybequoted(current_module.sharedlibfilename);
  928. end;
  929. if (target_info.system in systems_darwin) then
  930. begin
  931. { exported symbols for darwin }
  932. if not texportlibunix(exportlib).exportedsymnames.empty then
  933. begin
  934. assign(exportedsyms,outputexedir+'linksyms.fpc');
  935. rewrite(exportedsyms);
  936. repeat
  937. writeln(exportedsyms,texportlibunix(exportlib).exportedsymnames.getfirst);
  938. until texportlibunix(exportlib).exportedsymnames.empty;
  939. close(exportedsyms);
  940. cmdstr:=cmdstr+' -exported_symbols_list '+maybequoted(outputexedir)+'linksyms.fpc';
  941. end;
  942. end;
  943. if (LdSupportsNoResponseFile) and
  944. not(cs_link_nolink in current_settings.globalswitches) then
  945. begin
  946. { we have to use a script to use the IFS hack }
  947. linkscript:=GenerateScript(outputexedir+'ppaslink');
  948. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  949. if (extdbgbinstr<>'') then
  950. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  951. linkscript.WriteToDisk;
  952. BinStr:=linkscript.fn;
  953. if not path_absolute(BinStr) then
  954. if cs_link_on_target in current_settings.globalswitches then
  955. BinStr:='.'+target_info.dirsep+BinStr
  956. else
  957. BinStr:='.'+source_info.dirsep+BinStr;
  958. CmdStr:='';
  959. end;
  960. success:=DoExec(BinStr,cmdstr,true,LdSupportsNoResponseFile);
  961. if (success and
  962. (extdbgbinstr<>'') and
  963. (cs_link_nolink in current_settings.globalswitches)) then
  964. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  965. { Strip the library ? }
  966. if success and (cs_link_strip in current_settings.globalswitches) then
  967. begin
  968. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  969. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  970. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
  971. end;
  972. { Remove ReponseFile }
  973. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  974. begin
  975. DeleteFile(outputexedir+Info.ResName);
  976. if LdSupportsNoResponseFile Then
  977. begin
  978. DeleteFile(linkscript.fn);
  979. linkscript.free
  980. end;
  981. if (target_info.system in systems_darwin) then
  982. DeleteFile(outputexedir+'linksyms.fpc');
  983. end;
  984. { Remove linkfiles.res }
  985. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  986. DeleteFile(outputexedir+'linkfiles.res');
  987. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  988. end;
  989. {*****************************************************************************
  990. Initialize
  991. *****************************************************************************}
  992. initialization
  993. RegisterLinker(ld_bsd,TLinkerBSD);
  994. {$ifdef x86_64}
  995. RegisterImport(system_x86_64_dragonfly,timportlibbsd);
  996. RegisterExport(system_x86_64_dragonfly,texportlibbsd);
  997. RegisterTarget(system_x86_64_dragonfly_info);
  998. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  999. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  1000. RegisterTarget(system_x86_64_freebsd_info);
  1001. RegisterImport(system_x86_64_openbsd,timportlibbsd);
  1002. RegisterExport(system_x86_64_openbsd,texportlibbsd);
  1003. RegisterTarget(system_x86_64_openbsd_info);
  1004. RegisterImport(system_x86_64_netbsd,timportlibbsd);
  1005. RegisterExport(system_x86_64_netbsd,texportlibbsd);
  1006. RegisterTarget(system_x86_64_netbsd_info);
  1007. RegisterImport(system_x86_64_darwin,timportlibdarwin);
  1008. RegisterExport(system_x86_64_darwin,texportlibdarwin);
  1009. RegisterTarget(system_x86_64_darwin_info);
  1010. RegisterImport(system_x86_64_iphonesim,timportlibdarwin);
  1011. RegisterExport(system_x86_64_iphonesim,texportlibdarwin);
  1012. RegisterTarget(system_x86_64_iphonesim_info);
  1013. {$endif}
  1014. {$ifdef i386}
  1015. RegisterImport(system_i386_freebsd,timportlibbsd);
  1016. RegisterExport(system_i386_freebsd,texportlibbsd);
  1017. RegisterTarget(system_i386_freebsd_info);
  1018. RegisterImport(system_i386_netbsd,timportlibbsd);
  1019. RegisterExport(system_i386_netbsd,texportlibbsd);
  1020. RegisterTarget(system_i386_netbsd_info);
  1021. RegisterImport(system_i386_openbsd,timportlibbsd);
  1022. RegisterExport(system_i386_openbsd,texportlibbsd);
  1023. RegisterTarget(system_i386_openbsd_info);
  1024. RegisterImport(system_i386_darwin,timportlibdarwin);
  1025. RegisterExport(system_i386_darwin,texportlibdarwin);
  1026. RegisterTarget(system_i386_darwin_info);
  1027. RegisterImport(system_i386_iphonesim,timportlibdarwin);
  1028. RegisterExport(system_i386_iphonesim,texportlibdarwin);
  1029. RegisterTarget(system_i386_iphonesim_info);
  1030. {$endif i386}
  1031. {$ifdef m68k}
  1032. RegisterImport(system_m68k_netbsd,timportlibbsd);
  1033. RegisterExport(system_m68k_netbsd,texportlibbsd);
  1034. RegisterTarget(system_m68k_netbsd_info);
  1035. {$endif m68k}
  1036. {$ifdef powerpc}
  1037. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  1038. RegisterExport(system_powerpc_darwin,texportlibdarwin);
  1039. RegisterTarget(system_powerpc_darwin_info);
  1040. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  1041. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  1042. RegisterTarget(system_powerpc_netbsd_info);
  1043. {$endif powerpc}
  1044. {$ifdef powerpc64}
  1045. RegisterImport(system_powerpc64_darwin,timportlibdarwin);
  1046. RegisterExport(system_powerpc64_darwin,texportlibdarwin);
  1047. RegisterTarget(system_powerpc64_darwin_info);
  1048. {$endif powerpc64}
  1049. {$ifdef arm}
  1050. RegisterImport(system_arm_darwin,timportlibdarwin);
  1051. RegisterExport(system_arm_darwin,texportlibdarwin);
  1052. RegisterTarget(system_arm_darwin_info);
  1053. RegisterImport(system_arm_netbsd,timportlibbsd);
  1054. RegisterExport(system_arm_netbsd,texportlibbsd);
  1055. RegisterTarget(system_arm_netbsd_info);
  1056. {$endif arm}
  1057. {$ifdef aarch64}
  1058. RegisterImport(system_aarch64_darwin,timportlibdarwin);
  1059. RegisterExport(system_aarch64_darwin,texportlibdarwin);
  1060. RegisterTarget(system_aarch64_darwin_info);
  1061. {$endif aarch64}
  1062. RegisterRes(res_elf_info,TWinLikeResourceFile);
  1063. RegisterRes(res_macho_info,TWinLikeResourceFile);
  1064. end.