t_bsd.pas 39 KB

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