t_bsd.pas 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  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 : string[80];
  223. begin
  224. if target_info.system in systems_darwin then
  225. begin
  226. { for darwin: always link dynamically against libc }
  227. linklibc := true;
  228. reorder:=reorderentries;
  229. prtobj:='';
  230. SysInitUnit:='sysinit';
  231. end
  232. else
  233. begin
  234. linklibc:=ModulesLinkToLibc;
  235. if current_module.islibrary and
  236. (target_info.system in systems_bsd) then
  237. begin
  238. prtobj:='dllprt0';
  239. cprtobj:='dllprt0';
  240. gprtobj:='dllprt0';
  241. end
  242. else
  243. begin
  244. prtobj:='prt0';
  245. cprtobj:='cprt0';
  246. gprtobj:='gprt0';
  247. end;
  248. // this one is a bit complex.
  249. // Only reorder for now if -XL or -XO params are given
  250. // or when -Xf.
  251. reorder:= linklibc and
  252. (
  253. ReorderEntries
  254. or
  255. (cs_link_pthread in current_settings.globalswitches));
  256. if cs_profile in current_settings.moduleswitches then
  257. begin
  258. prtobj:=gprtobj;
  259. AddSharedLibrary('c');
  260. LibrarySuffix:='p';
  261. linklibc:=true;
  262. end
  263. else
  264. begin
  265. if linklibc then
  266. prtobj:=cprtobj;
  267. end;
  268. end;
  269. end;
  270. function TLinkerBSD.GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
  271. begin
  272. if not isdll then
  273. begin
  274. if not(cs_profile in current_settings.moduleswitches) then
  275. begin
  276. case target_info.system of
  277. system_powerpc_darwin,
  278. system_powerpc64_darwin,
  279. system_i386_darwin,
  280. system_x86_64_darwin:
  281. begin
  282. { 10.8 and later: no crt1.* }
  283. if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then
  284. exit('');
  285. { x86: crt1.10.6.o -> crt1.10.5.o -> crt1.o }
  286. { others: crt1.10.5 -> crt1.o }
  287. if (target_info.system in [system_i386_darwin,system_x86_64_darwin]) and
  288. (CompareVersionStrings(MacOSXVersionMin,'10.6')>=0) then
  289. exit('crt1.10.6.o');
  290. if CompareVersionStrings(MacOSXVersionMin,'10.5')>=0 then
  291. exit('crt1.10.5.o');
  292. end;
  293. system_arm_darwin:
  294. begin
  295. { iOS:
  296. iOS 6 and later: nothing
  297. iOS 3.1 - 5.x: crt1.3.1.o
  298. pre-iOS 3.1: crt1.o
  299. }
  300. if (CompareVersionStrings(iPhoneOSVersionMin,'6.0')>=0) then
  301. exit('');
  302. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  303. exit('crt1.3.1.o');
  304. end;
  305. system_i386_iphonesim,
  306. system_x86_64_iphonesim:
  307. begin
  308. { "recent versions" must not use anything (https://github.com/llvm-mirror/clang/commit/e6d04f3d152a22077022cf9287d4c538a0918ab0 )
  309. What those recent versions could be, is anyone's guess. It
  310. still seems to work with 8.1 and no longer with 8.3, so use
  311. 8.1 as a cut-off point }
  312. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  313. exit('');
  314. end;
  315. system_aarch64_darwin:
  316. { never anything }
  317. exit('');
  318. end;
  319. { nothing special -> default }
  320. result:='crt1.o';
  321. end
  322. else
  323. begin
  324. result:='gcrt1.o';
  325. { 10.8 and later: tell the linker to use 'start' instead of "_main"
  326. as entry point }
  327. if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then
  328. Info.ExeCmd[1]:=Info.ExeCmd[1]+' -no_new_main';
  329. end;
  330. end
  331. else
  332. begin
  333. if (apptype=app_bundle) then
  334. begin
  335. case target_info.system of
  336. system_powerpc_darwin,
  337. system_powerpc64_darwin,
  338. system_i386_darwin,
  339. system_x86_64_darwin:
  340. begin
  341. { < 10.6: bundle1.o
  342. >= 10.6: nothing }
  343. if CompareVersionStrings(MacOSXVersionMin,'10.6')>=0 then
  344. exit('');
  345. end;
  346. system_arm_darwin,
  347. system_aarch64_darwin:
  348. begin
  349. { iOS: < 3.1: bundle1.o
  350. >= 3.1: nothing }
  351. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  352. exit('');
  353. end;
  354. system_i386_iphonesim,
  355. system_x86_64_iphonesim:
  356. begin
  357. { see rule for crt1.o }
  358. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  359. exit('');
  360. end;
  361. end;
  362. result:='bundle1.o';
  363. end
  364. else
  365. begin
  366. case target_info.system of
  367. system_powerpc_darwin,
  368. system_powerpc64_darwin,
  369. system_i386_darwin,
  370. system_x86_64_darwin:
  371. begin
  372. { >= 10.6: nothing
  373. = 10.5: dylib1.10.5.o
  374. < 10.5: dylib1.o
  375. }
  376. if CompareVersionStrings(MacOSXVersionMin,'10.6')>=0 then
  377. exit('');
  378. if CompareVersionStrings(MacOSXVersionMin,'10.5')>=0 then
  379. exit('dylib1.10.5.o');
  380. end;
  381. system_arm_darwin,
  382. system_aarch64_darwin:
  383. begin
  384. { iOS: < 3.1: dylib1.o
  385. >= 3.1: nothing }
  386. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  387. exit('');
  388. end;
  389. system_i386_iphonesim,
  390. system_x86_64_iphonesim:
  391. begin
  392. { see rule for crt1.o }
  393. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  394. exit('');
  395. end;
  396. end;
  397. result:='dylib1.o';
  398. end;
  399. end;
  400. end;
  401. Function TLinkerBSD.GetDarwinPrtobjName(isdll: boolean): TCmdStr;
  402. var
  403. startupfile: TCmdStr;
  404. begin
  405. result:='';
  406. startupfile:=GetDarwinCrt1ObjName(isdll);
  407. if startupfile<>'' then
  408. begin
  409. if not librarysearchpath.FindFile(startupfile,false,result) then
  410. result:='/usr/lib/'+startupfile;
  411. end;
  412. result:=maybequoted(result);
  413. end;
  414. Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
  415. Var
  416. linkres : TLinkRes;
  417. FilesList : TLinkRes;
  418. i : longint;
  419. HPath : TCmdStrListItem;
  420. s,s1,s2 : TCmdStr;
  421. linkdynamic : boolean;
  422. Fl1,Fl2 : Boolean;
  423. IsDarwin : Boolean;
  424. begin
  425. WriteResponseFile:=False;
  426. ReOrder:=False;
  427. linkdynamic:=False;
  428. IsDarwin:=target_info.system in systems_darwin;
  429. { set special options for some targets }
  430. if not IsDarwin Then
  431. begin
  432. linkdynamic:=not(SharedLibFiles.empty);
  433. // after this point addition of shared libs not allowed.
  434. end
  435. else
  436. begin
  437. {$ifdef MACOSX104ORHIGHER}
  438. { not sure what this is for, but gcc always links against it }
  439. if not(cs_profile in current_settings.moduleswitches) then
  440. AddSharedLibrary('SystemStubs')
  441. else
  442. AddSharedLibrary('SystemStubs_profile');
  443. {$endif MACOSX104ORHIGHER}
  444. end;
  445. if reorder Then
  446. ExpandAndApplyOrder(SharedLibFiles);
  447. { Open link.res file }
  448. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,not LdSupportsNoResponseFile);
  449. if (target_info.system in systems_darwin) and
  450. (sysrootpath<>'') then
  451. begin
  452. LinkRes.Add('-syslibroot');
  453. LinkRes.Add(sysrootpath);
  454. end;
  455. if (target_info.system in systems_darwin) then
  456. begin
  457. LinkRes.Add('-arch');
  458. case target_info.system of
  459. system_powerpc_darwin:
  460. LinkRes.Add('ppc');
  461. system_i386_darwin,
  462. system_i386_iphonesim:
  463. LinkRes.Add('i386');
  464. system_powerpc64_darwin:
  465. LinkRes.Add('ppc64');
  466. system_x86_64_darwin,
  467. system_x86_64_iphonesim:
  468. LinkRes.Add('x86_64');
  469. system_arm_darwin:
  470. { current versions of the linker require the sub-architecture type
  471. to be specified }
  472. LinkRes.Add(lower(cputypestr[current_settings.cputype]));
  473. system_aarch64_darwin:
  474. LinkRes.Add('arm64');
  475. else
  476. internalerror(2014121801);
  477. end;
  478. if MacOSXVersionMin<>'' then
  479. begin
  480. LinkRes.Add('-macosx_version_min');
  481. LinkRes.Add(MacOSXVersionMin);
  482. end
  483. else if iPhoneOSVersionMin<>'' then
  484. begin
  485. LinkRes.Add('-iphoneos_version_min');
  486. LinkRes.Add(iPhoneOSVersionMin);
  487. end;
  488. end;
  489. { Write path to search libraries }
  490. HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  491. while assigned(HPath) do
  492. begin
  493. if LdSupportsNoResponseFile then
  494. LinkRes.Add('-L'+HPath.Str)
  495. else
  496. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  497. HPath:=TCmdStrListItem(HPath.Next);
  498. end;
  499. HPath:=TCmdStrListItem(LibrarySearchPath.First);
  500. while assigned(HPath) do
  501. begin
  502. if LdSupportsNoResponseFile then
  503. LinkRes.Add('-L'+HPath.Str)
  504. else
  505. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  506. HPath:=TCmdStrListItem(HPath.Next);
  507. end;
  508. if (target_info.system in systems_darwin) then
  509. begin
  510. HPath:=TCmdStrListItem(current_module.localframeworksearchpath.First);
  511. while assigned(HPath) do
  512. begin
  513. LinkRes.Add('-F'+HPath.Str);
  514. HPath:=TCmdStrListItem(HPath.Next);
  515. end;
  516. HPath:=TCmdStrListItem(FrameworkSearchPath.First);
  517. while assigned(HPath) do
  518. begin
  519. LinkRes.Add('-F'+HPath.Str);
  520. HPath:=TCmdStrListItem(HPath.Next);
  521. end;
  522. end;
  523. { force local symbol resolution (i.e., inside the shared }
  524. { library itself) for all non-exorted symbols, otherwise }
  525. { several RTL symbols of FPC-compiled shared libraries }
  526. { will be bound to those of a single shared library or }
  527. { to the main program }
  528. if (isdll) and (target_info.system in systems_bsd) then
  529. begin
  530. LinkRes.add('VERSION');
  531. LinkRes.add('{');
  532. LinkRes.add(' {');
  533. if not texportlibunix(exportlib).exportedsymnames.empty then
  534. begin
  535. LinkRes.add(' global:');
  536. repeat
  537. LinkRes.add(' '+texportlibunix(exportlib).exportedsymnames.getfirst+';');
  538. until texportlibunix(exportlib).exportedsymnames.empty;
  539. end;
  540. LinkRes.add(' local:');
  541. LinkRes.add(' *;');
  542. LinkRes.add(' };');
  543. LinkRes.add('}');
  544. end;
  545. if not LdSupportsNoResponseFile then
  546. LinkRes.Add('INPUT(');
  547. { add objectfiles, start with prt0 always }
  548. if not (target_info.system in systems_internal_sysinit) and (prtobj<>'') then
  549. LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  550. { try to add crti and crtbegin if linking to C }
  551. if linklibc and
  552. not IsDarwin Then
  553. begin
  554. if librarysearchpath.FindFile('crti.o',false,s) then
  555. LinkRes.AddFileName(s);
  556. if cs_create_pic in current_settings.moduleswitches then
  557. begin
  558. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  559. LinkRes.AddFileName(s);
  560. end
  561. else
  562. if (cs_link_staticflag in current_settings.globalswitches) and
  563. librarysearchpath.FindFile('crtbeginT.o',false,s) then
  564. LinkRes.AddFileName(s)
  565. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  566. LinkRes.AddFileName(s);
  567. end;
  568. { main objectfiles }
  569. { Generate linkfiles.res file if needed }
  570. { Only needed on Windows, due to the limitation of 8196 characters for command line }
  571. if (LdSupportsNoResponseFile) and
  572. (source_info.system in systems_all_windows) then
  573. begin
  574. FilesList:=TLinkRes.Create(outputexedir+'linkfiles.res',false);
  575. while not ObjectFiles.Empty do
  576. begin
  577. s:=ObjectFiles.GetFirst;
  578. if s<>'' then
  579. begin
  580. repeat
  581. i:=Pos(source_info.dirsep,s);
  582. if i>0 then
  583. s[i]:=target_info.dirsep;
  584. until i=0;
  585. FilesList.Add(s);
  586. end;
  587. end;
  588. FilesList.writetodisk;
  589. FilesList.Free;
  590. end
  591. else
  592. begin
  593. while not ObjectFiles.Empty do
  594. begin
  595. s:=ObjectFiles.GetFirst;
  596. if s<>'' then
  597. if LdSupportsNoResponseFile then
  598. LinkRes.AddFileName(s)
  599. else
  600. LinkRes.AddFileName(maybequoted(s));
  601. end;
  602. end;
  603. if not LdSupportsNoResponseFile then
  604. LinkRes.Add(')');
  605. { Write staticlibraries }
  606. if not StaticLibFiles.Empty then
  607. begin
  608. if not LdSupportsNoResponseFile then
  609. LinkRes.Add('GROUP(');
  610. While not StaticLibFiles.Empty do
  611. begin
  612. S:=StaticLibFiles.GetFirst;
  613. if LdSupportsNoResponseFile then
  614. LinkRes.AddFileName(s)
  615. else
  616. LinkRes.AddFileName(maybequoted(s))
  617. end;
  618. if not LdSupportsNoResponseFile then
  619. LinkRes.Add(')');
  620. end;
  621. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  622. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  623. if not SharedLibFiles.Empty then
  624. begin
  625. if not LdSupportsNoResponseFile then
  626. LinkRes.Add('INPUT(');
  627. While not SharedLibFiles.Empty do
  628. begin
  629. S:=SharedLibFiles.GetFirst;
  630. if (s<>'c') or reorder then
  631. begin
  632. i:=Pos(target_info.sharedlibext,S);
  633. if i>0 then
  634. Delete(S,i,255);
  635. LinkRes.Add('-l'+s);
  636. end
  637. else
  638. begin
  639. linklibc:=true;
  640. linkdynamic:=false; { libc will include the ld-* for us }
  641. end;
  642. end;
  643. { be sure that libc is the last lib }
  644. if linklibc and not reorder then
  645. Begin
  646. If LibrarySuffix=' ' Then
  647. LinkRes.Add('-lc')
  648. else
  649. LinkRes.Add('-lc_'+LibrarySuffix);
  650. If LibrarySuffix='r' Then
  651. LinkRes.Add('-lc');
  652. end;
  653. { when we have -static for the linker the we also need libgcc }
  654. if (cs_link_staticflag in current_settings.globalswitches) then
  655. LinkRes.Add('-lgcc');
  656. if linkdynamic and (Info.DynamicLinker<>'') and
  657. not(target_info.system in systems_openbsd) then
  658. LinkRes.AddFileName(Info.DynamicLinker);
  659. if not LdSupportsNoResponseFile then
  660. LinkRes.Add(')');
  661. end;
  662. { frameworks for Darwin }
  663. if IsDarwin then
  664. while not FrameworkFiles.empty do
  665. begin
  666. LinkRes.Add('-framework');
  667. LinkRes.Add(FrameworkFiles.GetFirst);
  668. end;
  669. { objects which must be at the end }
  670. if linklibc and
  671. not IsDarwin Then
  672. begin
  673. if cs_create_pic in current_settings.moduleswitches then
  674. Fl1:=librarysearchpath.FindFile('crtendS.o',false,s1)
  675. else
  676. Fl1:=librarysearchpath.FindFile('crtend.o',false,s1);
  677. Fl2:=librarysearchpath.FindFile('crtn.o',false,s2);
  678. if Fl1 or Fl2 then
  679. begin
  680. LinkRes.Add('INPUT(');
  681. If Fl1 Then
  682. LinkRes.AddFileName(s1);
  683. If Fl2 Then
  684. LinkRes.AddFileName(s2);
  685. LinkRes.Add(')');
  686. end;
  687. end;
  688. { Write and Close response }
  689. linkres.writetodisk;
  690. linkres.Free;
  691. WriteResponseFile:=True;
  692. end;
  693. function TLinkerBSD.MakeExecutable:boolean;
  694. var
  695. binstr,
  696. cmdstr,
  697. targetstr,
  698. emulstr,
  699. extdbgbinstr,
  700. extdbgcmdstr: TCmdStr;
  701. linkscript: TAsmScript;
  702. DynLinkStr : string[60];
  703. GCSectionsStr,
  704. StaticStr,
  705. StripStr : string[63];
  706. success,
  707. useshell : boolean;
  708. begin
  709. if not(cs_link_nolink in current_settings.globalswitches) then
  710. Message1(exec_i_linking,current_module.exefilename);
  711. { Create some replacements }
  712. StaticStr:='';
  713. StripStr:='';
  714. DynLinkStr:='';
  715. GCSectionsStr:='';
  716. linkscript:=nil;
  717. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  718. to avoid creation of a i386:x86_64 arch binary }
  719. if target_info.system=system_i386_freebsd then
  720. begin
  721. targetstr:='-b elf32-i386-freebsd';
  722. emulstr:='-m elf_i386_fbsd';
  723. end
  724. else
  725. begin
  726. targetstr:='';
  727. emulstr:='';
  728. end;
  729. if (cs_link_staticflag in current_settings.globalswitches) then
  730. begin
  731. if (target_info.system=system_m68k_netbsd) and
  732. ((cs_link_on_target in current_settings.globalswitches) or
  733. (target_info.system=source_info.system)) then
  734. StaticStr:='-Bstatic'
  735. else
  736. StaticStr:='-static';
  737. end;
  738. if (cs_link_strip in current_settings.globalswitches) then
  739. if (target_info.system in systems_darwin) then
  740. StripStr:='-x'
  741. else
  742. StripStr:='-s';
  743. if (cs_link_smart in current_settings.globalswitches) and
  744. (tf_smartlink_sections in target_info.flags) then
  745. if not(target_info.system in systems_darwin) then
  746. GCSectionsStr:='--gc-sections'
  747. else
  748. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  749. if(not(target_info.system in systems_darwin) and
  750. (cs_profile in current_settings.moduleswitches)) or
  751. ((Info.DynamicLinker<>'') and
  752. ((not SharedLibFiles.Empty) or
  753. (target_info.system in systems_openbsd))) then
  754. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  755. if CShared Then
  756. begin
  757. if not(target_info.system in systems_darwin) then
  758. DynLinKStr:=DynLinkStr+' --shared'
  759. else
  760. DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
  761. end;
  762. { Use -nopie on OpenBSD if PIC support is turned off }
  763. if (target_info.system in systems_openbsd) and
  764. not(cs_create_pic in current_settings.moduleswitches) then
  765. Info.ExtraOptions:=Info.ExtraOptions+' -nopie';
  766. { -N seems to be needed on NetBSD/earm }
  767. if (target_info.system in [system_arm_netbsd]) then
  768. Info.ExtraOptions:=Info.ExtraOptions+' -N';
  769. { Write used files and libraries }
  770. WriteResponseFile(false);
  771. { Call linker }
  772. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  773. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  774. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  775. Replace(cmdstr,'$TARGET',targetstr);
  776. Replace(cmdstr,'$EMUL',EmulStr);
  777. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  778. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  779. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  780. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  781. else
  782. Replace(cmdstr,'$FILELIST','');
  783. Replace(cmdstr,'$STATIC',StaticStr);
  784. Replace(cmdstr,'$STRIP',StripStr);
  785. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  786. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  787. if (target_info.system in systems_darwin) then
  788. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(false));
  789. BinStr:=FindUtil(utilsprefix+BinStr);
  790. { create dsym file? }
  791. extdbgbinstr:='';
  792. extdbgcmdstr:='';
  793. if (target_info.system in systems_darwin) and
  794. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  795. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  796. begin
  797. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  798. extdbgcmdstr:=maybequoted(current_module.exefilename);
  799. end;
  800. if (LdSupportsNoResponseFile) and
  801. not(cs_link_nolink in current_settings.globalswitches) then
  802. begin
  803. { we have to use a script to use the IFS hack }
  804. linkscript:=GenerateScript(outputexedir+'ppaslink');
  805. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  806. if (extdbgcmdstr<>'') then
  807. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  808. linkscript.WriteToDisk;
  809. BinStr:=linkscript.fn;
  810. if not path_absolute(BinStr) then
  811. if cs_link_on_target in current_settings.globalswitches then
  812. BinStr:='.'+target_info.dirsep+BinStr
  813. else
  814. BinStr:='.'+source_info.dirsep+BinStr;
  815. CmdStr:='';
  816. end;
  817. useshell:=not (tf_no_backquote_support in source_info.flags);
  818. success:=DoExec(BinStr,CmdStr,true,LdSupportsNoResponseFile or useshell);
  819. if (success and
  820. (extdbgbinstr<>'') and
  821. (cs_link_nolink in current_settings.globalswitches)) then
  822. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  823. { Remove ReponseFile }
  824. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  825. begin
  826. DeleteFile(outputexedir+Info.ResName);
  827. if LdSupportsNoResponseFile Then
  828. begin
  829. DeleteFile(linkscript.fn);
  830. linkscript.free
  831. end;
  832. end;
  833. { Remove linkfiles.res }
  834. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  835. DeleteFile(outputexedir+'linkfiles.res');
  836. MakeExecutable:=success; { otherwise a recursive call to link method }
  837. end;
  838. Function TLinkerBSD.MakeSharedLibrary:boolean;
  839. var
  840. InitStr,
  841. FiniStr,
  842. SoNameStr : string[80];
  843. linkscript: TAsmScript;
  844. binstr,
  845. cmdstr,
  846. targetstr,
  847. emulstr,
  848. extdbgbinstr,
  849. extdbgcmdstr : TCmdStr;
  850. GCSectionsStr : string[63];
  851. exportedsyms: text;
  852. success : boolean;
  853. begin
  854. MakeSharedLibrary:=false;
  855. GCSectionsStr:='';
  856. linkscript:=nil;
  857. if not(cs_link_nolink in current_settings.globalswitches) then
  858. Message1(exec_i_linking,current_module.sharedlibfilename);
  859. { Write used files and libraries }
  860. WriteResponseFile(true);
  861. if (cs_link_smart in current_settings.globalswitches) and
  862. (tf_smartlink_sections in target_info.flags) then
  863. if not(target_info.system in systems_darwin) then
  864. { disabled because not tested
  865. GCSectionsStr:='--gc-sections' }
  866. else
  867. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  868. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  869. to avoid creation of a i386:x86_64 arch binary }
  870. if target_info.system=system_i386_freebsd then
  871. begin
  872. targetstr:='-b elf32-i386-freebsd';
  873. emulstr:='-m elf_i386_fbsd';
  874. end
  875. else
  876. begin
  877. targetstr:='';
  878. emulstr:='';
  879. end;
  880. InitStr:='-init FPC_LIB_START';
  881. FiniStr:='-fini FPC_LIB_EXIT';
  882. SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
  883. { Call linker }
  884. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  885. {$ifndef darwin}
  886. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  887. {$else darwin}
  888. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename)));
  889. {$endif darwin}
  890. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  891. Replace(cmdstr,'$TARGET',targetstr);
  892. Replace(cmdstr,'$EMUL',EmulStr);
  893. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  894. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  895. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  896. else
  897. Replace(cmdstr,'$FILELIST','');
  898. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  899. Replace(cmdstr,'$INIT',InitStr);
  900. Replace(cmdstr,'$FINI',FiniStr);
  901. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  902. Replace(cmdstr,'$SONAME',SoNameStr);
  903. if (target_info.system in systems_darwin) then
  904. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
  905. BinStr:=FindUtil(utilsprefix+BinStr);
  906. { create dsym file? }
  907. extdbgbinstr:='';
  908. extdbgcmdstr:='';
  909. if (target_info.system in systems_darwin) and
  910. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  911. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  912. begin
  913. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  914. extdbgcmdstr:=maybequoted(current_module.sharedlibfilename);
  915. end;
  916. if (target_info.system in systems_darwin) then
  917. begin
  918. { exported symbols for darwin }
  919. if not texportlibunix(exportlib).exportedsymnames.empty then
  920. begin
  921. assign(exportedsyms,outputexedir+'linksyms.fpc');
  922. rewrite(exportedsyms);
  923. repeat
  924. writeln(exportedsyms,texportlibunix(exportlib).exportedsymnames.getfirst);
  925. until texportlibunix(exportlib).exportedsymnames.empty;
  926. close(exportedsyms);
  927. cmdstr:=cmdstr+' -exported_symbols_list '+maybequoted(outputexedir)+'linksyms.fpc';
  928. end;
  929. end;
  930. if (LdSupportsNoResponseFile) and
  931. not(cs_link_nolink in current_settings.globalswitches) then
  932. begin
  933. { we have to use a script to use the IFS hack }
  934. linkscript:=GenerateScript(outputexedir+'ppaslink');
  935. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  936. if (extdbgbinstr<>'') then
  937. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  938. linkscript.WriteToDisk;
  939. BinStr:=linkscript.fn;
  940. if not path_absolute(BinStr) then
  941. if cs_link_on_target in current_settings.globalswitches then
  942. BinStr:='.'+target_info.dirsep+BinStr
  943. else
  944. BinStr:='.'+source_info.dirsep+BinStr;
  945. CmdStr:='';
  946. end;
  947. success:=DoExec(BinStr,cmdstr,true,LdSupportsNoResponseFile);
  948. if (success and
  949. (extdbgbinstr<>'') and
  950. (cs_link_nolink in current_settings.globalswitches)) then
  951. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  952. { Strip the library ? }
  953. if success and (cs_link_strip in current_settings.globalswitches) then
  954. begin
  955. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  956. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  957. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
  958. end;
  959. { Remove ReponseFile }
  960. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  961. begin
  962. DeleteFile(outputexedir+Info.ResName);
  963. if LdSupportsNoResponseFile Then
  964. begin
  965. DeleteFile(linkscript.fn);
  966. linkscript.free
  967. end;
  968. if (target_info.system in systems_darwin) then
  969. DeleteFile(outputexedir+'linksyms.fpc');
  970. end;
  971. { Remove linkfiles.res }
  972. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  973. DeleteFile(outputexedir+'linkfiles.res');
  974. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  975. end;
  976. {*****************************************************************************
  977. Initialize
  978. *****************************************************************************}
  979. initialization
  980. RegisterLinker(ld_bsd,TLinkerBSD);
  981. {$ifdef x86_64}
  982. RegisterImport(system_x86_64_dragonfly,timportlibbsd);
  983. RegisterExport(system_x86_64_dragonfly,texportlibbsd);
  984. RegisterTarget(system_x86_64_dragonfly_info);
  985. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  986. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  987. RegisterTarget(system_x86_64_freebsd_info);
  988. RegisterImport(system_x86_64_openbsd,timportlibbsd);
  989. RegisterExport(system_x86_64_openbsd,texportlibbsd);
  990. RegisterTarget(system_x86_64_openbsd_info);
  991. RegisterImport(system_x86_64_netbsd,timportlibbsd);
  992. RegisterExport(system_x86_64_netbsd,texportlibbsd);
  993. RegisterTarget(system_x86_64_netbsd_info);
  994. RegisterImport(system_x86_64_darwin,timportlibdarwin);
  995. RegisterExport(system_x86_64_darwin,texportlibdarwin);
  996. RegisterTarget(system_x86_64_darwin_info);
  997. RegisterImport(system_x86_64_iphonesim,timportlibdarwin);
  998. RegisterExport(system_x86_64_iphonesim,texportlibdarwin);
  999. RegisterTarget(system_x86_64_iphonesim_info);
  1000. {$endif}
  1001. {$ifdef i386}
  1002. RegisterImport(system_i386_freebsd,timportlibbsd);
  1003. RegisterExport(system_i386_freebsd,texportlibbsd);
  1004. RegisterTarget(system_i386_freebsd_info);
  1005. RegisterImport(system_i386_netbsd,timportlibbsd);
  1006. RegisterExport(system_i386_netbsd,texportlibbsd);
  1007. RegisterTarget(system_i386_netbsd_info);
  1008. RegisterImport(system_i386_openbsd,timportlibbsd);
  1009. RegisterExport(system_i386_openbsd,texportlibbsd);
  1010. RegisterTarget(system_i386_openbsd_info);
  1011. RegisterImport(system_i386_darwin,timportlibdarwin);
  1012. RegisterExport(system_i386_darwin,texportlibdarwin);
  1013. RegisterTarget(system_i386_darwin_info);
  1014. RegisterImport(system_i386_iphonesim,timportlibdarwin);
  1015. RegisterExport(system_i386_iphonesim,texportlibdarwin);
  1016. RegisterTarget(system_i386_iphonesim_info);
  1017. {$endif i386}
  1018. {$ifdef m68k}
  1019. RegisterImport(system_m68k_netbsd,timportlibbsd);
  1020. RegisterExport(system_m68k_netbsd,texportlibbsd);
  1021. RegisterTarget(system_m68k_netbsd_info);
  1022. {$endif m68k}
  1023. {$ifdef powerpc}
  1024. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  1025. RegisterExport(system_powerpc_darwin,texportlibdarwin);
  1026. RegisterTarget(system_powerpc_darwin_info);
  1027. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  1028. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  1029. RegisterTarget(system_powerpc_netbsd_info);
  1030. {$endif powerpc}
  1031. {$ifdef powerpc64}
  1032. RegisterImport(system_powerpc64_darwin,timportlibdarwin);
  1033. RegisterExport(system_powerpc64_darwin,texportlibdarwin);
  1034. RegisterTarget(system_powerpc64_darwin_info);
  1035. {$endif powerpc64}
  1036. {$ifdef arm}
  1037. RegisterImport(system_arm_darwin,timportlibdarwin);
  1038. RegisterExport(system_arm_darwin,texportlibdarwin);
  1039. RegisterTarget(system_arm_darwin_info);
  1040. RegisterImport(system_arm_netbsd,timportlibbsd);
  1041. RegisterExport(system_arm_netbsd,texportlibbsd);
  1042. RegisterTarget(system_arm_netbsd_info);
  1043. {$endif arm}
  1044. {$ifdef aarch64}
  1045. RegisterImport(system_aarch64_darwin,timportlibdarwin);
  1046. RegisterExport(system_aarch64_darwin,texportlibdarwin);
  1047. RegisterTarget(system_aarch64_darwin_info);
  1048. {$endif aarch64}
  1049. RegisterRes(res_elf_info,TWinLikeResourceFile);
  1050. RegisterRes(res_macho_info,TWinLikeResourceFile);
  1051. end.