t_bsd.pas 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  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.AddLibraryPath(sysrootpath,'=/usr/lib',true)
  125. else if target_info.system in systems_openbsd then
  126. LibrarySearchPath.AddLibraryPath(sysrootpath,'=/usr/lib;=$OPENBSD_X11BASE/lib;=$OPENBSD_LOCALBASE/lib',true)
  127. else
  128. LibrarySearchPath.AddLibraryPath(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. var
  135. LdProgram: string='ld';
  136. begin
  137. if target_info.system in (systems_openbsd+[system_x86_64_dragonfly]) then
  138. LdProgram:='ld.bfd';
  139. LibrarySuffix:=' ';
  140. LdSupportsNoResponseFile := (target_info.system in ([system_m68k_netbsd]+systems_darwin));
  141. with Info do
  142. begin
  143. if LdSupportsNoResponseFile then
  144. begin
  145. if not(target_info.system in systems_darwin) then
  146. begin
  147. ExeCmd[1]:=LdProgram+' $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE $CATRES $FILELIST';
  148. DllCmd[1]:=LdProgram+' $TARGET $EMUL $OPT $MAP -shared -L. -o $EXE $CATRES $FILELIST'
  149. end
  150. else
  151. begin
  152. {$ifndef cpu64bitaddr}
  153. { Set the size of the page at address zero to 64kb, so nothing
  154. is loaded below that address. This avoids problems with the
  155. strange Windows-compatible resource handling that assumes
  156. that addresses below 64kb do not exist.
  157. On 64bit systems, page zero is 4GB by default, so no problems
  158. there.
  159. }
  160. { In case of valgrind, don't do that, because it cannot deal with
  161. a custom pagezero size -- in general, this should not cause any
  162. problems because the resources are added at the end and most
  163. programs with problems that require Valgrind will have more
  164. than 60KB of data (first 4KB of address space is always invalid)
  165. }
  166. ExeCmd[1]:=LdProgram+' $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
  167. if not(cs_gdb_valgrind in current_settings.globalswitches) then
  168. ExeCmd[1]:=ExeCmd[1]+' -pagezero_size 0x10000';
  169. {$else ndef cpu64bitaddr}
  170. ExeCmd[1]:=LdProgram+' $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
  171. {$endif ndef cpu64bitaddr}
  172. if (apptype<>app_bundle) then
  173. DllCmd[1]:=LdProgram+' $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP -dynamic -dylib -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
  174. else
  175. DllCmd[1]:=LdProgram+' $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP -dynamic -bundle -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
  176. end
  177. end
  178. else
  179. begin
  180. ExeCmd[1]:=LdProgram+' $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE $RES';
  181. DllCmd[1]:=LdProgram+' $TARGET $EMUL $OPT $INIT $FINI $SONAME $MAP -shared -L. -o $EXE $RES';
  182. end;
  183. if not(target_info.system in systems_darwin) then
  184. DllCmd[2]:='strip --strip-unneeded $EXE'
  185. else
  186. DllCmd[2]:='strip -x $EXE';
  187. { OpenBSD seems to use a wrong dynamic linker by default }
  188. if target_info.system in systems_openbsd then
  189. DynamicLinker:='/usr/libexec/ld.so'
  190. else if target_info.system in systems_netbsd then
  191. DynamicLinker:='/usr/libexec/ld.elf_so'
  192. else if target_info.system=system_x86_64_dragonfly then
  193. DynamicLinker:='/libexec/ld-elf.so.2'
  194. else
  195. DynamicLinker:='';
  196. end;
  197. end;
  198. procedure TLinkerBSD.LoadPredefinedLibraryOrder;
  199. // put your linkorder/linkalias overrides here.
  200. // Note: assumes only called when reordering/aliasing is used.
  201. Begin
  202. if not(target_info.system in systems_darwin) then
  203. begin
  204. if (target_info.system =system_i386_freebsd) and
  205. not (cs_link_no_default_lib_order in current_settings.globalswitches) Then
  206. Begin
  207. LinkLibraryOrder.add('gcc','',15);
  208. LinkLibraryOrder.add('c','',50); // c and c_p mutual. excl?
  209. LinkLibraryOrder.add('c_p','',55);
  210. LinkLibraryOrder.add('pthread','',75); // pthread and c_r should be mutually exclusive
  211. LinkLibraryOrder.add('c_r','',76);
  212. LinkLibraryOrder.add('kvm','',80); // must be before ncurses
  213. if (cs_link_pthread in current_settings.globalswitches) Then // convert libpthread to libc_r.
  214. LinkLibraryAliases.add('pthread','c_r');
  215. end;
  216. end
  217. else
  218. begin
  219. LinkLibraryOrder.add('gcc','',15);
  220. LinkLibraryOrder.add('c','',50);
  221. end;
  222. End;
  223. procedure TLinkerBSD.InitSysInitUnitName;
  224. var
  225. cprtobj,
  226. gprtobj,
  227. si_cprt,
  228. si_gprt : string[80];
  229. begin
  230. if target_info.system in systems_darwin then
  231. begin
  232. { for darwin: always link dynamically against libc }
  233. linklibc := true;
  234. reorder:=reorderentries;
  235. prtobj:='';
  236. SysInitUnit:='sysinit';
  237. end
  238. else
  239. begin
  240. linklibc:=ModulesLinkToLibc;
  241. if current_module.islibrary and
  242. (target_info.system in systems_bsd) then
  243. begin
  244. prtobj:='dllprt0';
  245. cprtobj:='dllprt0';
  246. gprtobj:='dllprt0';
  247. SysInitUnit:='si_dll';
  248. si_cprt:='si_dll';
  249. si_gprt:='si_dll';
  250. end
  251. else
  252. begin
  253. prtobj:='prt0';
  254. cprtobj:='cprt0';
  255. gprtobj:='gprt0';
  256. SysInitUnit:='si_prc';
  257. si_cprt:='si_c';
  258. si_gprt:='si_g';
  259. end;
  260. // this one is a bit complex.
  261. // Only reorder for now if -XL or -XO params are given
  262. // or when -Xf.
  263. reorder:= linklibc and
  264. (
  265. ReorderEntries
  266. or
  267. (cs_link_pthread in current_settings.globalswitches));
  268. if cs_profile in current_settings.moduleswitches then
  269. begin
  270. prtobj:=gprtobj;
  271. SysInitUnit:=si_gprt;
  272. AddSharedLibrary('c');
  273. LibrarySuffix:='p';
  274. linklibc:=true;
  275. end
  276. else
  277. begin
  278. if linklibc then
  279. begin
  280. prtobj:=cprtobj;
  281. SysInitUnit:=si_cprt;
  282. end;
  283. end;
  284. end;
  285. end;
  286. function TLinkerBSD.GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
  287. begin
  288. if not isdll then
  289. begin
  290. if not(cs_profile in current_settings.moduleswitches) then
  291. begin
  292. case target_info.system of
  293. system_powerpc_darwin,
  294. system_powerpc64_darwin,
  295. system_i386_darwin,
  296. system_x86_64_darwin:
  297. begin
  298. { 10.8 and later: no crt1.* }
  299. if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then
  300. exit('');
  301. { x86: crt1.10.6.o -> crt1.10.5.o -> crt1.o }
  302. { others: crt1.10.5 -> crt1.o }
  303. if (target_info.system in [system_i386_darwin,system_x86_64_darwin]) and
  304. (CompareVersionStrings(MacOSXVersionMin,'10.6')>=0) then
  305. exit('crt1.10.6.o');
  306. if CompareVersionStrings(MacOSXVersionMin,'10.5')>=0 then
  307. exit('crt1.10.5.o');
  308. end;
  309. system_arm_darwin:
  310. begin
  311. { iOS:
  312. iOS 6 and later: nothing
  313. iOS 3.1 - 5.x: crt1.3.1.o
  314. pre-iOS 3.1: crt1.o
  315. }
  316. if (CompareVersionStrings(iPhoneOSVersionMin,'6.0')>=0) then
  317. exit('');
  318. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  319. exit('crt1.3.1.o');
  320. end;
  321. system_i386_iphonesim,
  322. system_x86_64_iphonesim:
  323. begin
  324. { "recent versions" must not use anything (https://github.com/llvm-mirror/clang/commit/e6d04f3d152a22077022cf9287d4c538a0918ab0 )
  325. What those recent versions could be, is anyone's guess. It
  326. still seems to work with 8.1 and no longer with 8.3, so use
  327. 8.1 as a cut-off point }
  328. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  329. exit('');
  330. end;
  331. system_aarch64_darwin:
  332. { never anything }
  333. exit('');
  334. end;
  335. { nothing special -> default }
  336. result:='crt1.o';
  337. end
  338. else
  339. begin
  340. result:='gcrt1.o';
  341. { 10.8 and later: tell the linker to use 'start' instead of "_main"
  342. as entry point }
  343. if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then
  344. Info.ExeCmd[1]:=Info.ExeCmd[1]+' -no_new_main';
  345. end;
  346. end
  347. else
  348. begin
  349. if (apptype=app_bundle) then
  350. begin
  351. case target_info.system of
  352. system_powerpc_darwin,
  353. system_powerpc64_darwin,
  354. system_i386_darwin,
  355. system_x86_64_darwin:
  356. begin
  357. { < 10.6: bundle1.o
  358. >= 10.6: nothing }
  359. if CompareVersionStrings(MacOSXVersionMin,'10.6')>=0 then
  360. exit('');
  361. end;
  362. system_arm_darwin,
  363. system_aarch64_darwin:
  364. begin
  365. { iOS: < 3.1: bundle1.o
  366. >= 3.1: nothing }
  367. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  368. exit('');
  369. end;
  370. system_i386_iphonesim,
  371. system_x86_64_iphonesim:
  372. begin
  373. { see rule for crt1.o }
  374. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  375. exit('');
  376. end;
  377. end;
  378. result:='bundle1.o';
  379. end
  380. else
  381. begin
  382. case target_info.system of
  383. system_powerpc_darwin,
  384. system_powerpc64_darwin,
  385. system_i386_darwin,
  386. system_x86_64_darwin:
  387. begin
  388. { >= 10.6: nothing
  389. = 10.5: dylib1.10.5.o
  390. < 10.5: dylib1.o
  391. }
  392. if CompareVersionStrings(MacOSXVersionMin,'10.6')>=0 then
  393. exit('');
  394. if CompareVersionStrings(MacOSXVersionMin,'10.5')>=0 then
  395. exit('dylib1.10.5.o');
  396. end;
  397. system_arm_darwin,
  398. system_aarch64_darwin:
  399. begin
  400. { iOS: < 3.1: dylib1.o
  401. >= 3.1: nothing }
  402. if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then
  403. exit('');
  404. end;
  405. system_i386_iphonesim,
  406. system_x86_64_iphonesim:
  407. begin
  408. { see rule for crt1.o }
  409. if (CompareVersionStrings(iPhoneOSVersionMin,'8.1')>0) then
  410. exit('');
  411. end;
  412. end;
  413. result:='dylib1.o';
  414. end;
  415. end;
  416. end;
  417. Function TLinkerBSD.GetDarwinPrtobjName(isdll: boolean): TCmdStr;
  418. var
  419. startupfile: TCmdStr;
  420. begin
  421. result:='';
  422. startupfile:=GetDarwinCrt1ObjName(isdll);
  423. if startupfile<>'' then
  424. begin
  425. if not librarysearchpath.FindFile(startupfile,false,result) then
  426. result:='/usr/lib/'+startupfile;
  427. end;
  428. result:=maybequoted(result);
  429. end;
  430. Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
  431. Var
  432. linkres : TLinkRes;
  433. FilesList : TLinkRes;
  434. i : longint;
  435. HPath : TCmdStrListItem;
  436. s,s1,s2 : TCmdStr;
  437. linkdynamic : boolean;
  438. Fl1,Fl2 : Boolean;
  439. IsDarwin : Boolean;
  440. begin
  441. WriteResponseFile:=False;
  442. ReOrder:=False;
  443. linkdynamic:=False;
  444. IsDarwin:=target_info.system in systems_darwin;
  445. { set special options for some targets }
  446. if not IsDarwin Then
  447. begin
  448. linkdynamic:=not(SharedLibFiles.empty);
  449. // after this point addition of shared libs not allowed.
  450. end
  451. else
  452. begin
  453. {$ifdef MACOSX104ORHIGHER}
  454. { not sure what this is for, but gcc always links against it }
  455. if not(cs_profile in current_settings.moduleswitches) then
  456. AddSharedLibrary('SystemStubs')
  457. else
  458. AddSharedLibrary('SystemStubs_profile');
  459. {$endif MACOSX104ORHIGHER}
  460. end;
  461. if reorder Then
  462. ExpandAndApplyOrder(SharedLibFiles);
  463. { Open link.res file }
  464. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,not LdSupportsNoResponseFile);
  465. if (target_info.system in systems_darwin) and
  466. (sysrootpath<>'') then
  467. begin
  468. LinkRes.Add('-syslibroot');
  469. LinkRes.Add(sysrootpath);
  470. end;
  471. if (target_info.system in systems_darwin) then
  472. begin
  473. LinkRes.Add('-arch');
  474. case target_info.system of
  475. system_powerpc_darwin:
  476. LinkRes.Add('ppc');
  477. system_i386_darwin,
  478. system_i386_iphonesim:
  479. LinkRes.Add('i386');
  480. system_powerpc64_darwin:
  481. LinkRes.Add('ppc64');
  482. system_x86_64_darwin,
  483. system_x86_64_iphonesim:
  484. LinkRes.Add('x86_64');
  485. system_arm_darwin:
  486. { current versions of the linker require the sub-architecture type
  487. to be specified }
  488. LinkRes.Add(lower(cputypestr[current_settings.cputype]));
  489. system_aarch64_darwin:
  490. LinkRes.Add('arm64');
  491. else
  492. internalerror(2014121801);
  493. end;
  494. if MacOSXVersionMin<>'' then
  495. begin
  496. LinkRes.Add('-macosx_version_min');
  497. LinkRes.Add(MacOSXVersionMin);
  498. end
  499. else if iPhoneOSVersionMin<>'' then
  500. begin
  501. LinkRes.Add('-iphoneos_version_min');
  502. LinkRes.Add(iPhoneOSVersionMin);
  503. end;
  504. end;
  505. { Write path to search libraries }
  506. HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  507. while assigned(HPath) do
  508. begin
  509. if LdSupportsNoResponseFile then
  510. LinkRes.Add('-L'+HPath.Str)
  511. else
  512. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  513. HPath:=TCmdStrListItem(HPath.Next);
  514. end;
  515. HPath:=TCmdStrListItem(LibrarySearchPath.First);
  516. while assigned(HPath) do
  517. begin
  518. if LdSupportsNoResponseFile then
  519. LinkRes.Add('-L'+HPath.Str)
  520. else
  521. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  522. HPath:=TCmdStrListItem(HPath.Next);
  523. end;
  524. if (target_info.system in systems_darwin) then
  525. begin
  526. HPath:=TCmdStrListItem(current_module.localframeworksearchpath.First);
  527. while assigned(HPath) do
  528. begin
  529. LinkRes.Add('-F'+HPath.Str);
  530. HPath:=TCmdStrListItem(HPath.Next);
  531. end;
  532. HPath:=TCmdStrListItem(FrameworkSearchPath.First);
  533. while assigned(HPath) do
  534. begin
  535. LinkRes.Add('-F'+HPath.Str);
  536. HPath:=TCmdStrListItem(HPath.Next);
  537. end;
  538. end;
  539. { force local symbol resolution (i.e., inside the shared }
  540. { library itself) for all non-exorted symbols, otherwise }
  541. { several RTL symbols of FPC-compiled shared libraries }
  542. { will be bound to those of a single shared library or }
  543. { to the main program }
  544. if (isdll) and (target_info.system in systems_bsd) then
  545. begin
  546. LinkRes.add('VERSION');
  547. LinkRes.add('{');
  548. LinkRes.add(' {');
  549. if not texportlibunix(exportlib).exportedsymnames.empty then
  550. begin
  551. LinkRes.add(' global:');
  552. repeat
  553. LinkRes.add(' '+texportlibunix(exportlib).exportedsymnames.getfirst+';');
  554. until texportlibunix(exportlib).exportedsymnames.empty;
  555. end;
  556. LinkRes.add(' local:');
  557. LinkRes.add(' *;');
  558. LinkRes.add(' };');
  559. LinkRes.add('}');
  560. end;
  561. if not LdSupportsNoResponseFile then
  562. LinkRes.Add('INPUT(');
  563. { add objectfiles, start with prt0 always }
  564. if not (target_info.system in systems_internal_sysinit) and (prtobj<>'') then
  565. LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  566. { try to add crti and crtbegin if linking to C }
  567. if linklibc and
  568. not IsDarwin Then
  569. begin
  570. if librarysearchpath.FindFile('crti.o',false,s) then
  571. LinkRes.AddFileName(s);
  572. if ((cs_create_pic in current_settings.moduleswitches) and
  573. not (target_info.system in systems_openbsd)) or
  574. (current_module.islibrary and
  575. (target_info.system in systems_openbsd)) then
  576. begin
  577. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  578. LinkRes.AddFileName(s);
  579. end
  580. else
  581. if (cs_link_staticflag in current_settings.globalswitches) and
  582. librarysearchpath.FindFile('crtbeginT.o',false,s) then
  583. LinkRes.AddFileName(s)
  584. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  585. LinkRes.AddFileName(s);
  586. end;
  587. { main objectfiles }
  588. if (target_info.system in systems_darwin) then
  589. begin
  590. FilesList:=TLinkRes.Create(outputexedir+'linkfiles.res',false);
  591. while not ObjectFiles.Empty do
  592. begin
  593. s:=ObjectFiles.GetFirst;
  594. if s<>'' then
  595. begin
  596. s:=TargetFixFileName(s);
  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) and
  686. not (target_info.system in systems_openbsd)) or
  687. (current_module.islibrary and
  688. (target_info.system in systems_openbsd)) then
  689. Fl1:=librarysearchpath.FindFile('crtendS.o',false,s1)
  690. else
  691. Fl1:=librarysearchpath.FindFile('crtend.o',false,s1);
  692. Fl2:=librarysearchpath.FindFile('crtn.o',false,s2);
  693. if Fl1 or Fl2 then
  694. begin
  695. LinkRes.Add('INPUT(');
  696. If Fl1 Then
  697. LinkRes.AddFileName(s1);
  698. If Fl2 Then
  699. LinkRes.AddFileName(s2);
  700. LinkRes.Add(')');
  701. end;
  702. end;
  703. { Write and Close response }
  704. linkres.writetodisk;
  705. linkres.Free;
  706. WriteResponseFile:=True;
  707. end;
  708. function TLinkerBSD.MakeExecutable:boolean;
  709. var
  710. binstr,
  711. cmdstr,
  712. mapstr,
  713. targetstr,
  714. emulstr,
  715. extdbgbinstr,
  716. extdbgcmdstr: TCmdStr;
  717. linkscript: TAsmScript;
  718. DynLinkStr : string[60];
  719. GCSectionsStr,
  720. StaticStr,
  721. StripStr : string[63];
  722. success,
  723. useshell : boolean;
  724. begin
  725. if not(cs_link_nolink in current_settings.globalswitches) then
  726. Message1(exec_i_linking,current_module.exefilename);
  727. { Create some replacements }
  728. StaticStr:='';
  729. StripStr:='';
  730. DynLinkStr:='';
  731. GCSectionsStr:='';
  732. linkscript:=nil;
  733. mapstr:='';
  734. if (cs_link_map in current_settings.globalswitches) then
  735. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
  736. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  737. to avoid creation of a i386:x86_64 arch binary }
  738. if target_info.system=system_i386_freebsd then
  739. begin
  740. targetstr:='-b elf32-i386-freebsd';
  741. emulstr:='-m elf_i386_fbsd';
  742. end
  743. else
  744. begin
  745. targetstr:='';
  746. emulstr:='';
  747. end;
  748. if (cs_link_staticflag in current_settings.globalswitches) then
  749. begin
  750. if (target_info.system=system_m68k_netbsd) and
  751. ((cs_link_on_target in current_settings.globalswitches) or
  752. (target_info.system=source_info.system)) then
  753. StaticStr:='-Bstatic'
  754. else
  755. StaticStr:='-static';
  756. end;
  757. if (cs_link_strip in current_settings.globalswitches) then
  758. if (target_info.system in systems_darwin) then
  759. StripStr:='-x'
  760. else
  761. StripStr:='-s';
  762. if (cs_link_smart in current_settings.globalswitches) and
  763. (tf_smartlink_sections in target_info.flags) then
  764. if not(target_info.system in systems_darwin) then
  765. GCSectionsStr:='--gc-sections'
  766. else
  767. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  768. if(not(target_info.system in systems_darwin) and
  769. (cs_profile in current_settings.moduleswitches)) or
  770. ((Info.DynamicLinker<>'') and
  771. ((not SharedLibFiles.Empty) or
  772. (target_info.system in systems_openbsd))) then
  773. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  774. if CShared Then
  775. begin
  776. if not(target_info.system in systems_darwin) then
  777. DynLinKStr:=DynLinkStr+' --shared'
  778. else
  779. DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
  780. end;
  781. { Use -nopie on OpenBSD if PIC support is turned off }
  782. if (target_info.system in systems_openbsd) and
  783. not(cs_create_pic in current_settings.moduleswitches) then
  784. Info.ExtraOptions:=Info.ExtraOptions+' -nopie';
  785. { -N seems to be needed on NetBSD/earm }
  786. if (target_info.system in [system_arm_netbsd]) then
  787. Info.ExtraOptions:=Info.ExtraOptions+' -N';
  788. { Write used files and libraries }
  789. WriteResponseFile(false);
  790. { Call linker }
  791. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  792. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  793. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  794. Replace(cmdstr,'$TARGET',targetstr);
  795. Replace(cmdstr,'$EMUL',EmulStr);
  796. Replace(cmdstr,'$MAP',mapstr);
  797. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  798. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  799. if (target_info.system in systems_darwin) then
  800. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  801. else
  802. Replace(cmdstr,'$FILELIST','');
  803. Replace(cmdstr,'$STATIC',StaticStr);
  804. Replace(cmdstr,'$STRIP',StripStr);
  805. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  806. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  807. if (target_info.system in systems_darwin) then
  808. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(false));
  809. BinStr:=FindUtil(utilsprefix+BinStr);
  810. { create dsym file? }
  811. extdbgbinstr:='';
  812. extdbgcmdstr:='';
  813. if (target_info.system in systems_darwin) and
  814. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  815. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  816. begin
  817. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  818. extdbgcmdstr:=maybequoted(current_module.exefilename);
  819. end;
  820. if (LdSupportsNoResponseFile) and
  821. not(cs_link_nolink in current_settings.globalswitches) then
  822. begin
  823. { we have to use a script to use the IFS hack }
  824. linkscript:=GenerateScript(outputexedir+'ppaslink');
  825. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  826. if (extdbgcmdstr<>'') then
  827. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  828. linkscript.WriteToDisk;
  829. BinStr:=linkscript.fn;
  830. if not path_absolute(BinStr) then
  831. if cs_link_on_target in current_settings.globalswitches then
  832. BinStr:='.'+target_info.dirsep+BinStr
  833. else
  834. BinStr:='.'+source_info.dirsep+BinStr;
  835. CmdStr:='';
  836. end;
  837. useshell:=not (tf_no_backquote_support in source_info.flags);
  838. success:=DoExec(BinStr,CmdStr,true,LdSupportsNoResponseFile or useshell);
  839. if (success and
  840. (extdbgbinstr<>'') and
  841. (cs_link_nolink in current_settings.globalswitches)) then
  842. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  843. { Remove ReponseFile }
  844. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  845. begin
  846. DeleteFile(outputexedir+Info.ResName);
  847. if LdSupportsNoResponseFile Then
  848. begin
  849. DeleteFile(linkscript.fn);
  850. linkscript.free
  851. end;
  852. if target_info.system in systems_darwin then
  853. DeleteFile(outputexedir+'linkfiles.res');
  854. end;
  855. MakeExecutable:=success; { otherwise a recursive call to link method }
  856. end;
  857. Function TLinkerBSD.MakeSharedLibrary:boolean;
  858. var
  859. InitStr,
  860. FiniStr,
  861. SoNameStr : string[80];
  862. linkscript: TAsmScript;
  863. binstr,
  864. cmdstr,
  865. mapstr,
  866. targetstr,
  867. emulstr,
  868. extdbgbinstr,
  869. extdbgcmdstr : TCmdStr;
  870. GCSectionsStr : string[63];
  871. exportedsyms: text;
  872. success : boolean;
  873. begin
  874. MakeSharedLibrary:=false;
  875. GCSectionsStr:='';
  876. mapstr:='';
  877. linkscript:=nil;
  878. if not(cs_link_nolink in current_settings.globalswitches) then
  879. Message1(exec_i_linking,current_module.sharedlibfilename);
  880. { Write used files and libraries }
  881. WriteResponseFile(true);
  882. if (cs_link_smart in current_settings.globalswitches) and
  883. (tf_smartlink_sections in target_info.flags) then
  884. if not(target_info.system in systems_darwin) then
  885. { disabled because not tested
  886. GCSectionsStr:='--gc-sections' }
  887. else
  888. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  889. if (cs_link_map in current_settings.globalswitches) then
  890. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.sharedlibfilename,'.map'));
  891. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  892. to avoid creation of a i386:x86_64 arch binary }
  893. if target_info.system=system_i386_freebsd then
  894. begin
  895. targetstr:='-b elf32-i386-freebsd';
  896. emulstr:='-m elf_i386_fbsd';
  897. end
  898. else
  899. begin
  900. targetstr:='';
  901. emulstr:='';
  902. end;
  903. InitStr:='-init FPC_LIB_START';
  904. FiniStr:='-fini FPC_LIB_EXIT';
  905. SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
  906. { Call linker }
  907. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  908. {$ifndef darwin}
  909. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  910. {$else darwin}
  911. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename)));
  912. {$endif darwin}
  913. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  914. Replace(cmdstr,'$TARGET',targetstr);
  915. Replace(cmdstr,'$EMUL',EmulStr);
  916. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  917. if (target_info.system in systems_darwin) then
  918. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  919. else
  920. Replace(cmdstr,'$FILELIST','');
  921. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  922. Replace(cmdstr,'$INIT',InitStr);
  923. Replace(cmdstr,'$FINI',FiniStr);
  924. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  925. Replace(cmdstr,'$SONAME',SoNameStr);
  926. Replace(cmdstr,'$MAP',mapstr);
  927. if (target_info.system in systems_darwin) then
  928. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
  929. BinStr:=FindUtil(utilsprefix+BinStr);
  930. { create dsym file? }
  931. extdbgbinstr:='';
  932. extdbgcmdstr:='';
  933. if (target_info.system in systems_darwin) and
  934. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  935. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  936. begin
  937. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  938. extdbgcmdstr:=maybequoted(current_module.sharedlibfilename);
  939. end;
  940. if (target_info.system in systems_darwin) then
  941. begin
  942. { exported symbols for darwin }
  943. if not texportlibunix(exportlib).exportedsymnames.empty then
  944. begin
  945. assign(exportedsyms,outputexedir+'linksyms.fpc');
  946. rewrite(exportedsyms);
  947. repeat
  948. writeln(exportedsyms,texportlibunix(exportlib).exportedsymnames.getfirst);
  949. until texportlibunix(exportlib).exportedsymnames.empty;
  950. close(exportedsyms);
  951. cmdstr:=cmdstr+' -exported_symbols_list '+maybequoted(outputexedir)+'linksyms.fpc';
  952. end;
  953. end;
  954. if (LdSupportsNoResponseFile) and
  955. not(cs_link_nolink in current_settings.globalswitches) then
  956. begin
  957. { we have to use a script to use the IFS hack }
  958. linkscript:=GenerateScript(outputexedir+'ppaslink');
  959. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  960. if (extdbgbinstr<>'') then
  961. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  962. linkscript.WriteToDisk;
  963. BinStr:=linkscript.fn;
  964. if not path_absolute(BinStr) then
  965. if cs_link_on_target in current_settings.globalswitches then
  966. BinStr:='.'+target_info.dirsep+BinStr
  967. else
  968. BinStr:='.'+source_info.dirsep+BinStr;
  969. CmdStr:='';
  970. end;
  971. success:=DoExec(BinStr,cmdstr,true,LdSupportsNoResponseFile);
  972. if (success and
  973. (extdbgbinstr<>'') and
  974. (cs_link_nolink in current_settings.globalswitches)) then
  975. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  976. { Strip the library ? }
  977. if success and (cs_link_strip in current_settings.globalswitches) then
  978. begin
  979. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  980. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  981. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
  982. end;
  983. { Remove ReponseFile }
  984. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  985. begin
  986. DeleteFile(outputexedir+Info.ResName);
  987. if LdSupportsNoResponseFile Then
  988. begin
  989. DeleteFile(linkscript.fn);
  990. linkscript.free
  991. end;
  992. if (target_info.system in systems_darwin) then
  993. begin
  994. DeleteFile(outputexedir+'linksyms.fpc');
  995. DeleteFile(outputexedir+'linkfiles.res');
  996. end;
  997. end;
  998. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  999. end;
  1000. {*****************************************************************************
  1001. Initialize
  1002. *****************************************************************************}
  1003. initialization
  1004. RegisterLinker(ld_bsd,TLinkerBSD);
  1005. {$ifdef x86_64}
  1006. RegisterImport(system_x86_64_dragonfly,timportlibbsd);
  1007. RegisterExport(system_x86_64_dragonfly,texportlibbsd);
  1008. RegisterTarget(system_x86_64_dragonfly_info);
  1009. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  1010. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  1011. RegisterTarget(system_x86_64_freebsd_info);
  1012. RegisterImport(system_x86_64_openbsd,timportlibbsd);
  1013. RegisterExport(system_x86_64_openbsd,texportlibbsd);
  1014. RegisterTarget(system_x86_64_openbsd_info);
  1015. RegisterImport(system_x86_64_netbsd,timportlibbsd);
  1016. RegisterExport(system_x86_64_netbsd,texportlibbsd);
  1017. RegisterTarget(system_x86_64_netbsd_info);
  1018. RegisterImport(system_x86_64_darwin,timportlibdarwin);
  1019. RegisterExport(system_x86_64_darwin,texportlibdarwin);
  1020. RegisterTarget(system_x86_64_darwin_info);
  1021. RegisterImport(system_x86_64_iphonesim,timportlibdarwin);
  1022. RegisterExport(system_x86_64_iphonesim,texportlibdarwin);
  1023. RegisterTarget(system_x86_64_iphonesim_info);
  1024. {$endif}
  1025. {$ifdef i386}
  1026. RegisterImport(system_i386_freebsd,timportlibbsd);
  1027. RegisterExport(system_i386_freebsd,texportlibbsd);
  1028. RegisterTarget(system_i386_freebsd_info);
  1029. RegisterImport(system_i386_netbsd,timportlibbsd);
  1030. RegisterExport(system_i386_netbsd,texportlibbsd);
  1031. RegisterTarget(system_i386_netbsd_info);
  1032. RegisterImport(system_i386_openbsd,timportlibbsd);
  1033. RegisterExport(system_i386_openbsd,texportlibbsd);
  1034. RegisterTarget(system_i386_openbsd_info);
  1035. RegisterImport(system_i386_darwin,timportlibdarwin);
  1036. RegisterExport(system_i386_darwin,texportlibdarwin);
  1037. RegisterTarget(system_i386_darwin_info);
  1038. RegisterImport(system_i386_iphonesim,timportlibdarwin);
  1039. RegisterExport(system_i386_iphonesim,texportlibdarwin);
  1040. RegisterTarget(system_i386_iphonesim_info);
  1041. {$endif i386}
  1042. {$ifdef m68k}
  1043. RegisterImport(system_m68k_netbsd,timportlibbsd);
  1044. RegisterExport(system_m68k_netbsd,texportlibbsd);
  1045. RegisterTarget(system_m68k_netbsd_info);
  1046. {$endif m68k}
  1047. {$ifdef powerpc}
  1048. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  1049. RegisterExport(system_powerpc_darwin,texportlibdarwin);
  1050. RegisterTarget(system_powerpc_darwin_info);
  1051. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  1052. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  1053. RegisterTarget(system_powerpc_netbsd_info);
  1054. {$endif powerpc}
  1055. {$ifdef powerpc64}
  1056. RegisterImport(system_powerpc64_darwin,timportlibdarwin);
  1057. RegisterExport(system_powerpc64_darwin,texportlibdarwin);
  1058. RegisterTarget(system_powerpc64_darwin_info);
  1059. {$endif powerpc64}
  1060. {$ifdef arm}
  1061. RegisterImport(system_arm_darwin,timportlibdarwin);
  1062. RegisterExport(system_arm_darwin,texportlibdarwin);
  1063. RegisterTarget(system_arm_darwin_info);
  1064. RegisterImport(system_arm_netbsd,timportlibbsd);
  1065. RegisterExport(system_arm_netbsd,texportlibbsd);
  1066. RegisterTarget(system_arm_netbsd_info);
  1067. {$endif arm}
  1068. {$ifdef aarch64}
  1069. RegisterImport(system_aarch64_darwin,timportlibdarwin);
  1070. RegisterExport(system_aarch64_darwin,texportlibdarwin);
  1071. RegisterTarget(system_aarch64_darwin_info);
  1072. {$endif aarch64}
  1073. RegisterRes(res_elf_info,TWinLikeResourceFile);
  1074. RegisterRes(res_macho_info,TWinLikeResourceFile);
  1075. end.