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