t_bsd.pas 38 KB

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