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.AddPath(sysrootpath,'/usr/lib',true)
  125. else if target_info.system in systems_openbsd then
  126. LibrarySearchPath.AddPath(sysrootpath,'/usr/lib;$OPENBSD_X11BASE/lib;$OPENBSD_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. var
  135. LdProgram: string='ld';
  136. begin
  137. if target_info.system in systems_openbsd 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. startupfile:=GetDarwinCrt1ObjName(isdll);
  422. if startupfile<>'' then
  423. begin
  424. if not librarysearchpath.FindFile(startupfile,false,result) then
  425. result:='/usr/lib/'+startupfile
  426. end
  427. else
  428. result:='';
  429. result:=maybequoted(result);
  430. end;
  431. Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
  432. Var
  433. linkres : TLinkRes;
  434. FilesList : TLinkRes;
  435. i : longint;
  436. HPath : TCmdStrListItem;
  437. s,s1,s2 : TCmdStr;
  438. linkdynamic : boolean;
  439. Fl1,Fl2 : Boolean;
  440. IsDarwin : Boolean;
  441. begin
  442. WriteResponseFile:=False;
  443. ReOrder:=False;
  444. linkdynamic:=False;
  445. IsDarwin:=target_info.system in systems_darwin;
  446. { set special options for some targets }
  447. if not IsDarwin Then
  448. begin
  449. linkdynamic:=not(SharedLibFiles.empty);
  450. // after this point addition of shared libs not allowed.
  451. end
  452. else
  453. begin
  454. {$ifdef MACOSX104ORHIGHER}
  455. { not sure what this is for, but gcc always links against it }
  456. if not(cs_profile in current_settings.moduleswitches) then
  457. AddSharedLibrary('SystemStubs')
  458. else
  459. AddSharedLibrary('SystemStubs_profile');
  460. {$endif MACOSX104ORHIGHER}
  461. end;
  462. if reorder Then
  463. ExpandAndApplyOrder(SharedLibFiles);
  464. { Open link.res file }
  465. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,not LdSupportsNoResponseFile);
  466. if (target_info.system in systems_darwin) and
  467. (sysrootpath<>'') then
  468. begin
  469. LinkRes.Add('-syslibroot');
  470. LinkRes.Add(sysrootpath);
  471. end;
  472. if (target_info.system in systems_darwin) then
  473. begin
  474. LinkRes.Add('-arch');
  475. case target_info.system of
  476. system_powerpc_darwin:
  477. LinkRes.Add('ppc');
  478. system_i386_darwin,
  479. system_i386_iphonesim:
  480. LinkRes.Add('i386');
  481. system_powerpc64_darwin:
  482. LinkRes.Add('ppc64');
  483. system_x86_64_darwin,
  484. system_x86_64_iphonesim:
  485. LinkRes.Add('x86_64');
  486. system_arm_darwin:
  487. { current versions of the linker require the sub-architecture type
  488. to be specified }
  489. LinkRes.Add(lower(cputypestr[current_settings.cputype]));
  490. system_aarch64_darwin:
  491. LinkRes.Add('arm64');
  492. else
  493. internalerror(2014121801);
  494. end;
  495. if MacOSXVersionMin<>'' then
  496. begin
  497. LinkRes.Add('-macosx_version_min');
  498. LinkRes.Add(MacOSXVersionMin);
  499. end
  500. else if iPhoneOSVersionMin<>'' then
  501. begin
  502. LinkRes.Add('-iphoneos_version_min');
  503. LinkRes.Add(iPhoneOSVersionMin);
  504. end;
  505. end;
  506. { Write path to search libraries }
  507. HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  508. while assigned(HPath) do
  509. begin
  510. if LdSupportsNoResponseFile then
  511. LinkRes.Add('-L'+HPath.Str)
  512. else
  513. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  514. HPath:=TCmdStrListItem(HPath.Next);
  515. end;
  516. HPath:=TCmdStrListItem(LibrarySearchPath.First);
  517. while assigned(HPath) do
  518. begin
  519. if LdSupportsNoResponseFile then
  520. LinkRes.Add('-L'+HPath.Str)
  521. else
  522. LinkRes.Add('SEARCH_DIR("'+HPath.Str+'")');
  523. HPath:=TCmdStrListItem(HPath.Next);
  524. end;
  525. if (target_info.system in systems_darwin) then
  526. begin
  527. HPath:=TCmdStrListItem(current_module.localframeworksearchpath.First);
  528. while assigned(HPath) do
  529. begin
  530. LinkRes.Add('-F'+HPath.Str);
  531. HPath:=TCmdStrListItem(HPath.Next);
  532. end;
  533. HPath:=TCmdStrListItem(FrameworkSearchPath.First);
  534. while assigned(HPath) do
  535. begin
  536. LinkRes.Add('-F'+HPath.Str);
  537. HPath:=TCmdStrListItem(HPath.Next);
  538. end;
  539. end;
  540. { force local symbol resolution (i.e., inside the shared }
  541. { library itself) for all non-exorted symbols, otherwise }
  542. { several RTL symbols of FPC-compiled shared libraries }
  543. { will be bound to those of a single shared library or }
  544. { to the main program }
  545. if (isdll) and (target_info.system in systems_bsd) then
  546. begin
  547. LinkRes.add('VERSION');
  548. LinkRes.add('{');
  549. LinkRes.add(' {');
  550. if not texportlibunix(exportlib).exportedsymnames.empty then
  551. begin
  552. LinkRes.add(' global:');
  553. repeat
  554. LinkRes.add(' '+texportlibunix(exportlib).exportedsymnames.getfirst+';');
  555. until texportlibunix(exportlib).exportedsymnames.empty;
  556. end;
  557. LinkRes.add(' local:');
  558. LinkRes.add(' *;');
  559. LinkRes.add(' };');
  560. LinkRes.add('}');
  561. end;
  562. if not LdSupportsNoResponseFile then
  563. LinkRes.Add('INPUT(');
  564. { add objectfiles, start with prt0 always }
  565. if not (target_info.system in systems_internal_sysinit) and (prtobj<>'') then
  566. LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  567. { try to add crti and crtbegin if linking to C }
  568. if linklibc and
  569. not IsDarwin Then
  570. begin
  571. if librarysearchpath.FindFile('crti.o',false,s) then
  572. LinkRes.AddFileName(s);
  573. if ((cs_create_pic in current_settings.moduleswitches) and
  574. not (target_info.system in systems_openbsd)) or
  575. (current_module.islibrary and
  576. (target_info.system in systems_openbsd)) then
  577. begin
  578. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  579. LinkRes.AddFileName(s);
  580. end
  581. else
  582. if (cs_link_staticflag in current_settings.globalswitches) and
  583. librarysearchpath.FindFile('crtbeginT.o',false,s) then
  584. LinkRes.AddFileName(s)
  585. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  586. LinkRes.AddFileName(s);
  587. end;
  588. { main objectfiles }
  589. { Generate linkfiles.res file if needed }
  590. { Only needed on Windows, due to the limitation of 8196 characters for command line }
  591. if (LdSupportsNoResponseFile) and
  592. (source_info.system in systems_all_windows) then
  593. begin
  594. FilesList:=TLinkRes.Create(outputexedir+'linkfiles.res',false);
  595. while not ObjectFiles.Empty do
  596. begin
  597. s:=ObjectFiles.GetFirst;
  598. if s<>'' then
  599. begin
  600. repeat
  601. i:=Pos(source_info.dirsep,s);
  602. if i>0 then
  603. s[i]:=target_info.dirsep;
  604. until i=0;
  605. FilesList.Add(s);
  606. end;
  607. end;
  608. FilesList.writetodisk;
  609. FilesList.Free;
  610. end
  611. else
  612. begin
  613. while not ObjectFiles.Empty do
  614. begin
  615. s:=ObjectFiles.GetFirst;
  616. if s<>'' then
  617. if LdSupportsNoResponseFile then
  618. LinkRes.AddFileName(s)
  619. else
  620. LinkRes.AddFileName(maybequoted(s));
  621. end;
  622. end;
  623. if not LdSupportsNoResponseFile then
  624. LinkRes.Add(')');
  625. { Write staticlibraries }
  626. if not StaticLibFiles.Empty then
  627. begin
  628. if not LdSupportsNoResponseFile then
  629. LinkRes.Add('GROUP(');
  630. While not StaticLibFiles.Empty do
  631. begin
  632. S:=StaticLibFiles.GetFirst;
  633. if LdSupportsNoResponseFile then
  634. LinkRes.AddFileName(s)
  635. else
  636. LinkRes.AddFileName(maybequoted(s))
  637. end;
  638. if not LdSupportsNoResponseFile then
  639. LinkRes.Add(')');
  640. end;
  641. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  642. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  643. if not SharedLibFiles.Empty then
  644. begin
  645. if not LdSupportsNoResponseFile then
  646. LinkRes.Add('INPUT(');
  647. While not SharedLibFiles.Empty do
  648. begin
  649. S:=SharedLibFiles.GetFirst;
  650. if (s<>'c') or reorder then
  651. begin
  652. i:=Pos(target_info.sharedlibext,S);
  653. if i>0 then
  654. Delete(S,i,255);
  655. LinkRes.Add('-l'+s);
  656. end
  657. else
  658. begin
  659. linklibc:=true;
  660. linkdynamic:=false; { libc will include the ld-* for us }
  661. end;
  662. end;
  663. { be sure that libc is the last lib }
  664. if linklibc and not reorder then
  665. Begin
  666. If LibrarySuffix=' ' Then
  667. LinkRes.Add('-lc')
  668. else
  669. LinkRes.Add('-lc_'+LibrarySuffix);
  670. If LibrarySuffix='r' Then
  671. LinkRes.Add('-lc');
  672. end;
  673. { when we have -static for the linker the we also need libgcc }
  674. if (cs_link_staticflag in current_settings.globalswitches) then
  675. LinkRes.Add('-lgcc');
  676. if linkdynamic and (Info.DynamicLinker<>'') and
  677. not(target_info.system in systems_openbsd) then
  678. LinkRes.AddFileName(Info.DynamicLinker);
  679. if not LdSupportsNoResponseFile then
  680. LinkRes.Add(')');
  681. end;
  682. { frameworks for Darwin }
  683. if IsDarwin then
  684. while not FrameworkFiles.empty do
  685. begin
  686. LinkRes.Add('-framework');
  687. LinkRes.Add(FrameworkFiles.GetFirst);
  688. end;
  689. { objects which must be at the end }
  690. if linklibc and
  691. not IsDarwin Then
  692. begin
  693. if ((cs_create_pic in current_settings.moduleswitches) and
  694. not (target_info.system in systems_openbsd)) or
  695. (current_module.islibrary and
  696. (target_info.system in systems_openbsd)) then
  697. Fl1:=librarysearchpath.FindFile('crtendS.o',false,s1)
  698. else
  699. Fl1:=librarysearchpath.FindFile('crtend.o',false,s1);
  700. Fl2:=librarysearchpath.FindFile('crtn.o',false,s2);
  701. if Fl1 or Fl2 then
  702. begin
  703. LinkRes.Add('INPUT(');
  704. If Fl1 Then
  705. LinkRes.AddFileName(s1);
  706. If Fl2 Then
  707. LinkRes.AddFileName(s2);
  708. LinkRes.Add(')');
  709. end;
  710. end;
  711. { Write and Close response }
  712. linkres.writetodisk;
  713. linkres.Free;
  714. WriteResponseFile:=True;
  715. end;
  716. function TLinkerBSD.MakeExecutable:boolean;
  717. var
  718. binstr,
  719. cmdstr,
  720. mapstr,
  721. targetstr,
  722. emulstr,
  723. extdbgbinstr,
  724. extdbgcmdstr: TCmdStr;
  725. linkscript: TAsmScript;
  726. DynLinkStr : string[60];
  727. GCSectionsStr,
  728. StaticStr,
  729. StripStr : string[63];
  730. success,
  731. useshell : boolean;
  732. begin
  733. if not(cs_link_nolink in current_settings.globalswitches) then
  734. Message1(exec_i_linking,current_module.exefilename);
  735. { Create some replacements }
  736. StaticStr:='';
  737. StripStr:='';
  738. DynLinkStr:='';
  739. GCSectionsStr:='';
  740. linkscript:=nil;
  741. mapstr:='';
  742. if (cs_link_map in current_settings.globalswitches) then
  743. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
  744. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  745. to avoid creation of a i386:x86_64 arch binary }
  746. if target_info.system=system_i386_freebsd then
  747. begin
  748. targetstr:='-b elf32-i386-freebsd';
  749. emulstr:='-m elf_i386_fbsd';
  750. end
  751. else
  752. begin
  753. targetstr:='';
  754. emulstr:='';
  755. end;
  756. if (cs_link_staticflag in current_settings.globalswitches) then
  757. begin
  758. if (target_info.system=system_m68k_netbsd) and
  759. ((cs_link_on_target in current_settings.globalswitches) or
  760. (target_info.system=source_info.system)) then
  761. StaticStr:='-Bstatic'
  762. else
  763. StaticStr:='-static';
  764. end;
  765. if (cs_link_strip in current_settings.globalswitches) then
  766. if (target_info.system in systems_darwin) then
  767. StripStr:='-x'
  768. else
  769. StripStr:='-s';
  770. if (cs_link_smart in current_settings.globalswitches) and
  771. (tf_smartlink_sections in target_info.flags) then
  772. if not(target_info.system in systems_darwin) then
  773. GCSectionsStr:='--gc-sections'
  774. else
  775. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  776. if(not(target_info.system in systems_darwin) and
  777. (cs_profile in current_settings.moduleswitches)) or
  778. ((Info.DynamicLinker<>'') and
  779. ((not SharedLibFiles.Empty) or
  780. (target_info.system in systems_openbsd))) then
  781. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  782. if CShared Then
  783. begin
  784. if not(target_info.system in systems_darwin) then
  785. DynLinKStr:=DynLinkStr+' --shared'
  786. else
  787. DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
  788. end;
  789. { Use -nopie on OpenBSD if PIC support is turned off }
  790. if (target_info.system in systems_openbsd) and
  791. not(cs_create_pic in current_settings.moduleswitches) then
  792. Info.ExtraOptions:=Info.ExtraOptions+' -nopie';
  793. { -N seems to be needed on NetBSD/earm }
  794. if (target_info.system in [system_arm_netbsd]) then
  795. Info.ExtraOptions:=Info.ExtraOptions+' -N';
  796. { Write used files and libraries }
  797. WriteResponseFile(false);
  798. { Call linker }
  799. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  800. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  801. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  802. Replace(cmdstr,'$TARGET',targetstr);
  803. Replace(cmdstr,'$EMUL',EmulStr);
  804. Replace(cmdstr,'$MAP',mapstr);
  805. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  806. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  807. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  808. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  809. else
  810. Replace(cmdstr,'$FILELIST','');
  811. Replace(cmdstr,'$STATIC',StaticStr);
  812. Replace(cmdstr,'$STRIP',StripStr);
  813. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  814. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  815. if (target_info.system in systems_darwin) then
  816. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(false));
  817. BinStr:=FindUtil(utilsprefix+BinStr);
  818. { create dsym file? }
  819. extdbgbinstr:='';
  820. extdbgcmdstr:='';
  821. if (target_info.system in systems_darwin) and
  822. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  823. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  824. begin
  825. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  826. extdbgcmdstr:=maybequoted(current_module.exefilename);
  827. end;
  828. if (LdSupportsNoResponseFile) and
  829. not(cs_link_nolink in current_settings.globalswitches) then
  830. begin
  831. { we have to use a script to use the IFS hack }
  832. linkscript:=GenerateScript(outputexedir+'ppaslink');
  833. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  834. if (extdbgcmdstr<>'') then
  835. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  836. linkscript.WriteToDisk;
  837. BinStr:=linkscript.fn;
  838. if not path_absolute(BinStr) then
  839. if cs_link_on_target in current_settings.globalswitches then
  840. BinStr:='.'+target_info.dirsep+BinStr
  841. else
  842. BinStr:='.'+source_info.dirsep+BinStr;
  843. CmdStr:='';
  844. end;
  845. useshell:=not (tf_no_backquote_support in source_info.flags);
  846. success:=DoExec(BinStr,CmdStr,true,LdSupportsNoResponseFile or useshell);
  847. if (success and
  848. (extdbgbinstr<>'') and
  849. (cs_link_nolink in current_settings.globalswitches)) then
  850. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  851. { Remove ReponseFile }
  852. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  853. begin
  854. DeleteFile(outputexedir+Info.ResName);
  855. if LdSupportsNoResponseFile Then
  856. begin
  857. DeleteFile(linkscript.fn);
  858. linkscript.free
  859. end;
  860. end;
  861. { Remove linkfiles.res }
  862. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  863. DeleteFile(outputexedir+'linkfiles.res');
  864. MakeExecutable:=success; { otherwise a recursive call to link method }
  865. end;
  866. Function TLinkerBSD.MakeSharedLibrary:boolean;
  867. var
  868. InitStr,
  869. FiniStr,
  870. SoNameStr : string[80];
  871. linkscript: TAsmScript;
  872. binstr,
  873. cmdstr,
  874. mapstr,
  875. targetstr,
  876. emulstr,
  877. extdbgbinstr,
  878. extdbgcmdstr : TCmdStr;
  879. GCSectionsStr : string[63];
  880. exportedsyms: text;
  881. success : boolean;
  882. begin
  883. MakeSharedLibrary:=false;
  884. GCSectionsStr:='';
  885. mapstr:='';
  886. linkscript:=nil;
  887. if not(cs_link_nolink in current_settings.globalswitches) then
  888. Message1(exec_i_linking,current_module.sharedlibfilename);
  889. { Write used files and libraries }
  890. WriteResponseFile(true);
  891. if (cs_link_smart in current_settings.globalswitches) and
  892. (tf_smartlink_sections in target_info.flags) then
  893. if not(target_info.system in systems_darwin) then
  894. { disabled because not tested
  895. GCSectionsStr:='--gc-sections' }
  896. else
  897. GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';
  898. if (cs_link_map in current_settings.globalswitches) then
  899. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.sharedlibfilename,'.map'));
  900. { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
  901. to avoid creation of a i386:x86_64 arch binary }
  902. if target_info.system=system_i386_freebsd then
  903. begin
  904. targetstr:='-b elf32-i386-freebsd';
  905. emulstr:='-m elf_i386_fbsd';
  906. end
  907. else
  908. begin
  909. targetstr:='';
  910. emulstr:='';
  911. end;
  912. InitStr:='-init FPC_LIB_START';
  913. FiniStr:='-fini FPC_LIB_EXIT';
  914. SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
  915. { Call linker }
  916. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  917. {$ifndef darwin}
  918. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  919. {$else darwin}
  920. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename)));
  921. {$endif darwin}
  922. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  923. Replace(cmdstr,'$TARGET',targetstr);
  924. Replace(cmdstr,'$EMUL',EmulStr);
  925. Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
  926. if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  927. Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
  928. else
  929. Replace(cmdstr,'$FILELIST','');
  930. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  931. Replace(cmdstr,'$INIT',InitStr);
  932. Replace(cmdstr,'$FINI',FiniStr);
  933. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  934. Replace(cmdstr,'$SONAME',SoNameStr);
  935. Replace(cmdstr,'$MAP',mapstr);
  936. if (target_info.system in systems_darwin) then
  937. Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
  938. BinStr:=FindUtil(utilsprefix+BinStr);
  939. { create dsym file? }
  940. extdbgbinstr:='';
  941. extdbgcmdstr:='';
  942. if (target_info.system in systems_darwin) and
  943. (target_dbg.id in [dbg_dwarf2,dbg_dwarf3]) and
  944. (cs_link_separate_dbg_file in current_settings.globalswitches) then
  945. begin
  946. extdbgbinstr:=FindUtil(utilsprefix+'dsymutil');
  947. extdbgcmdstr:=maybequoted(current_module.sharedlibfilename);
  948. end;
  949. if (target_info.system in systems_darwin) then
  950. begin
  951. { exported symbols for darwin }
  952. if not texportlibunix(exportlib).exportedsymnames.empty then
  953. begin
  954. assign(exportedsyms,outputexedir+'linksyms.fpc');
  955. rewrite(exportedsyms);
  956. repeat
  957. writeln(exportedsyms,texportlibunix(exportlib).exportedsymnames.getfirst);
  958. until texportlibunix(exportlib).exportedsymnames.empty;
  959. close(exportedsyms);
  960. cmdstr:=cmdstr+' -exported_symbols_list '+maybequoted(outputexedir)+'linksyms.fpc';
  961. end;
  962. end;
  963. if (LdSupportsNoResponseFile) and
  964. not(cs_link_nolink in current_settings.globalswitches) then
  965. begin
  966. { we have to use a script to use the IFS hack }
  967. linkscript:=GenerateScript(outputexedir+'ppaslink');
  968. linkscript.AddLinkCommand(BinStr,CmdStr,'');
  969. if (extdbgbinstr<>'') then
  970. linkscript.AddLinkCommand(extdbgbinstr,extdbgcmdstr,'');
  971. linkscript.WriteToDisk;
  972. BinStr:=linkscript.fn;
  973. if not path_absolute(BinStr) then
  974. if cs_link_on_target in current_settings.globalswitches then
  975. BinStr:='.'+target_info.dirsep+BinStr
  976. else
  977. BinStr:='.'+source_info.dirsep+BinStr;
  978. CmdStr:='';
  979. end;
  980. success:=DoExec(BinStr,cmdstr,true,LdSupportsNoResponseFile);
  981. if (success and
  982. (extdbgbinstr<>'') and
  983. (cs_link_nolink in current_settings.globalswitches)) then
  984. success:=DoExec(extdbgbinstr,extdbgcmdstr,false,LdSupportsNoResponseFile);
  985. { Strip the library ? }
  986. if success and (cs_link_strip in current_settings.globalswitches) then
  987. begin
  988. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  989. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  990. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
  991. end;
  992. { Remove ReponseFile }
  993. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  994. begin
  995. DeleteFile(outputexedir+Info.ResName);
  996. if LdSupportsNoResponseFile Then
  997. begin
  998. DeleteFile(linkscript.fn);
  999. linkscript.free
  1000. end;
  1001. if (target_info.system in systems_darwin) then
  1002. DeleteFile(outputexedir+'linksyms.fpc');
  1003. end;
  1004. { Remove linkfiles.res }
  1005. if (success) and (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
  1006. DeleteFile(outputexedir+'linkfiles.res');
  1007. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  1008. end;
  1009. {*****************************************************************************
  1010. Initialize
  1011. *****************************************************************************}
  1012. initialization
  1013. RegisterLinker(ld_bsd,TLinkerBSD);
  1014. {$ifdef x86_64}
  1015. RegisterImport(system_x86_64_dragonfly,timportlibbsd);
  1016. RegisterExport(system_x86_64_dragonfly,texportlibbsd);
  1017. RegisterTarget(system_x86_64_dragonfly_info);
  1018. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  1019. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  1020. RegisterTarget(system_x86_64_freebsd_info);
  1021. RegisterImport(system_x86_64_openbsd,timportlibbsd);
  1022. RegisterExport(system_x86_64_openbsd,texportlibbsd);
  1023. RegisterTarget(system_x86_64_openbsd_info);
  1024. RegisterImport(system_x86_64_netbsd,timportlibbsd);
  1025. RegisterExport(system_x86_64_netbsd,texportlibbsd);
  1026. RegisterTarget(system_x86_64_netbsd_info);
  1027. RegisterImport(system_x86_64_darwin,timportlibdarwin);
  1028. RegisterExport(system_x86_64_darwin,texportlibdarwin);
  1029. RegisterTarget(system_x86_64_darwin_info);
  1030. RegisterImport(system_x86_64_iphonesim,timportlibdarwin);
  1031. RegisterExport(system_x86_64_iphonesim,texportlibdarwin);
  1032. RegisterTarget(system_x86_64_iphonesim_info);
  1033. {$endif}
  1034. {$ifdef i386}
  1035. RegisterImport(system_i386_freebsd,timportlibbsd);
  1036. RegisterExport(system_i386_freebsd,texportlibbsd);
  1037. RegisterTarget(system_i386_freebsd_info);
  1038. RegisterImport(system_i386_netbsd,timportlibbsd);
  1039. RegisterExport(system_i386_netbsd,texportlibbsd);
  1040. RegisterTarget(system_i386_netbsd_info);
  1041. RegisterImport(system_i386_openbsd,timportlibbsd);
  1042. RegisterExport(system_i386_openbsd,texportlibbsd);
  1043. RegisterTarget(system_i386_openbsd_info);
  1044. RegisterImport(system_i386_darwin,timportlibdarwin);
  1045. RegisterExport(system_i386_darwin,texportlibdarwin);
  1046. RegisterTarget(system_i386_darwin_info);
  1047. RegisterImport(system_i386_iphonesim,timportlibdarwin);
  1048. RegisterExport(system_i386_iphonesim,texportlibdarwin);
  1049. RegisterTarget(system_i386_iphonesim_info);
  1050. {$endif i386}
  1051. {$ifdef m68k}
  1052. RegisterImport(system_m68k_netbsd,timportlibbsd);
  1053. RegisterExport(system_m68k_netbsd,texportlibbsd);
  1054. RegisterTarget(system_m68k_netbsd_info);
  1055. {$endif m68k}
  1056. {$ifdef powerpc}
  1057. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  1058. RegisterExport(system_powerpc_darwin,texportlibdarwin);
  1059. RegisterTarget(system_powerpc_darwin_info);
  1060. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  1061. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  1062. RegisterTarget(system_powerpc_netbsd_info);
  1063. {$endif powerpc}
  1064. {$ifdef powerpc64}
  1065. RegisterImport(system_powerpc64_darwin,timportlibdarwin);
  1066. RegisterExport(system_powerpc64_darwin,texportlibdarwin);
  1067. RegisterTarget(system_powerpc64_darwin_info);
  1068. {$endif powerpc64}
  1069. {$ifdef arm}
  1070. RegisterImport(system_arm_darwin,timportlibdarwin);
  1071. RegisterExport(system_arm_darwin,texportlibdarwin);
  1072. RegisterTarget(system_arm_darwin_info);
  1073. RegisterImport(system_arm_netbsd,timportlibbsd);
  1074. RegisterExport(system_arm_netbsd,texportlibbsd);
  1075. RegisterTarget(system_arm_netbsd_info);
  1076. {$endif arm}
  1077. {$ifdef aarch64}
  1078. RegisterImport(system_aarch64_darwin,timportlibdarwin);
  1079. RegisterExport(system_aarch64_darwin,texportlibdarwin);
  1080. RegisterTarget(system_aarch64_darwin_info);
  1081. {$endif aarch64}
  1082. RegisterRes(res_elf_info,TWinLikeResourceFile);
  1083. RegisterRes(res_macho_info,TWinLikeResourceFile);
  1084. end.