t_linux.pas 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559
  1. {
  2. Copyright (c) 1998-2008 by Peter Vreman
  3. This unit implements support import,export,link routines
  4. for the (i386) Linux target
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit t_linux;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. aasmdata,
  23. symsym,symdef,ppu,
  24. import,export,expunix,link;
  25. type
  26. timportliblinux=class(timportlib)
  27. procedure generatelib;override;
  28. end;
  29. texportliblinux=class(texportlibunix)
  30. procedure setfininame(list: TAsmList; const s: string); override;
  31. end;
  32. TLibcType=(libc5,glibc2,glibc21,uclibc);
  33. tlinkerlinux=class(texternallinker)
  34. private
  35. libctype: TLibcType;
  36. prtobj : string[80];
  37. reorder : boolean;
  38. linklibc: boolean;
  39. Function WriteResponseFile(isdll:boolean) : Boolean;
  40. public
  41. constructor Create;override;
  42. procedure SetDefaultInfo;override;
  43. procedure InitSysInitUnitName;override;
  44. function MakeExecutable:boolean;override;
  45. function MakeSharedLibrary:boolean;override;
  46. procedure LoadPredefinedLibraryOrder; override;
  47. end;
  48. TInternalLinkerLinux=class(TInternalLinker)
  49. private
  50. libctype: TLibcType;
  51. reorder: boolean;
  52. linklibc: boolean;
  53. prtobj: string[20];
  54. dynlinker: string[100];
  55. public
  56. constructor Create;override;
  57. procedure DefaultLinkScript;override;
  58. procedure InitSysInitUnitName;override;
  59. end;
  60. implementation
  61. uses
  62. SysUtils,
  63. cutils,cfileutl,cclasses,
  64. verbose,systems,globtype,globals,
  65. symconst,script,
  66. fmodule,
  67. aasmbase,aasmtai,aasmcpu,cpubase,
  68. cgbase,cgobj,cgutils,ogbase,ncgutil,
  69. comprsrc,
  70. ogelf,
  71. rescmn, i_linux
  72. ;
  73. {*****************************************************************************
  74. TIMPORTLIBLINUX
  75. *****************************************************************************}
  76. procedure timportliblinux.generatelib;
  77. var
  78. i : longint;
  79. ImportLibrary : TImportLibrary;
  80. begin
  81. for i:=0 to current_module.ImportLibraryList.Count-1 do
  82. begin
  83. ImportLibrary:=TImportLibrary(current_module.ImportLibraryList[i]);
  84. current_module.linkothersharedlibs.add(ImportLibrary.Name,link_always);
  85. end;
  86. end;
  87. {*****************************************************************************
  88. TEXPORTLIBLINUX
  89. *****************************************************************************}
  90. procedure texportliblinux.setfininame(list: TAsmList; const s: string);
  91. begin
  92. { the problem with not having a .fini section is that a finalization
  93. routine in regular code can get "smart" linked away -> reference it
  94. just like the debug info }
  95. new_section(list,sec_fpc,'links',0);
  96. list.concat(Tai_const.Createname(s,0));
  97. inherited setfininame(list,s);
  98. end;
  99. {*****************************************************************************
  100. TLINKERLINUX
  101. *****************************************************************************}
  102. procedure SetupLibrarySearchPath;
  103. begin
  104. if not Dontlinkstdlibpath Then
  105. {$ifdef x86_64}
  106. LibrarySearchPath.AddPath(sysrootpath,'/lib64;/usr/lib64;/usr/X11R6/lib64',true);
  107. {$else}
  108. {$ifdef powerpc64}
  109. LibrarySearchPath.AddPath(sysrootpath,'/lib64;/usr/lib64;/usr/X11R6/lib64',true);
  110. {$else powerpc64}
  111. LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib',true);
  112. {$endif powerpc64}
  113. {$endif x86_64}
  114. {$ifdef arm}
  115. { some newer Debian have the crt*.o files at uncommon locations,
  116. for other arm flavours, this cannot hurt }
  117. if not Dontlinkstdlibpath Then
  118. {$ifdef FPC_ARMHF}
  119. LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/arm-linux-gnueabihf',true);
  120. {$endif FPC_ARMHF}
  121. {$ifdef FPC_ARMEL}
  122. LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/arm-linux-gnueabi',true);
  123. {$endif}
  124. {$endif arm}
  125. {$ifdef x86_64}
  126. LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/x86_64-linux-gnu',true);
  127. {$endif x86_64}
  128. {$ifdef i386}
  129. LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/i386-linux-gnu',true);
  130. {$endif i386}
  131. end;
  132. {$ifdef m68k}
  133. const defdynlinker='/lib/ld.so.1';
  134. {$endif m68k}
  135. {$ifdef i386}
  136. const defdynlinker='/lib/ld-linux.so.2';
  137. {$endif}
  138. {$ifdef x86_64}
  139. const defdynlinker='/lib64/ld-linux-x86-64.so.2';
  140. {$endif x86_64}
  141. {$ifdef sparc}
  142. const defdynlinker='/lib/ld-linux.so.2';
  143. {$endif sparc}
  144. {$ifdef powerpc}
  145. const defdynlinker='/lib/ld.so.1';
  146. {$endif powerpc}
  147. {$ifdef powerpc64}
  148. const defdynlinker='/lib64/ld64.so.1';
  149. {$endif powerpc64}
  150. {$ifdef arm}
  151. {$ifdef FPC_ARMHF}
  152. const defdynlinker='/lib/ld-linux-armhf.so.3';
  153. {$else FPC_ARMHF}
  154. {$ifdef FPC_ARMEL}
  155. const defdynlinker='/lib/ld-linux.so.3';
  156. {$else FPC_ARMEL}
  157. const defdynlinker='/lib/ld-linux.so.2';
  158. {$endif FPC_ARMEL}
  159. {$endif FPC_ARMHF}
  160. {$endif arm}
  161. {$ifdef mips}
  162. const defdynlinker='/lib/ld.so.1';
  163. {$endif mips}
  164. procedure SetupDynlinker(out DynamicLinker:string;out libctype:TLibcType);
  165. begin
  166. {
  167. Search order:
  168. glibc 2.1+
  169. uclibc
  170. glibc 2.0
  171. If none is found (e.g. when cross compiling) glibc21 is assumed
  172. }
  173. if fileexists(sysrootpath+defdynlinker,false) then
  174. begin
  175. DynamicLinker:=defdynlinker;
  176. {$ifdef i386}
  177. libctype:=glibc21;
  178. {$else i386}
  179. libctype:=glibc2;
  180. {$endif i386}
  181. end
  182. else if fileexists(sysrootpath+'/lib/ld-uClibc.so.0',false) then
  183. begin
  184. DynamicLinker:='/lib/ld-uClibc.so.0';
  185. libctype:=uclibc;
  186. end
  187. {$ifdef i386}
  188. else if FileExists(sysrootpath+'/lib/ld-linux.so.1',false) then
  189. begin
  190. DynamicLinker:='/lib/ld-linux.so.1';
  191. libctype:=glibc2;
  192. end
  193. {$endif i386}
  194. else
  195. begin
  196. { when no dyn. linker is found, we are probably
  197. cross compiling, so use the default dyn. linker }
  198. DynamicLinker:=defdynlinker;
  199. {
  200. the default c startup script is gcrt0.as on all platforms
  201. except i386
  202. }
  203. {$ifdef i386}
  204. libctype:=glibc21;
  205. {$else i386}
  206. libctype:=glibc2;
  207. {$endif i386}
  208. end;
  209. end;
  210. function ModulesLinkToLibc:boolean;
  211. var
  212. hp: tmodule;
  213. begin
  214. { This is called very early, ImportLibraryList is not yet merged into linkothersharedlibs.
  215. The former contains library names qualified with prefix and suffix (coming from
  216. "external 'c' name 'foo' declarations), the latter contains raw names (from "$linklib c"
  217. directives). }
  218. hp:=tmodule(loaded_units.first);
  219. while assigned(hp) do
  220. begin
  221. result:=Assigned(hp.ImportLibraryList.find(target_info.sharedClibprefix+'c'+target_info.sharedClibext));
  222. if result then break;
  223. result:=hp.linkothersharedlibs.find(target_info.sharedClibprefix+'c'+target_info.sharedClibext);
  224. if result then break;
  225. result:=hp.linkothersharedlibs.find('c');
  226. if result then break;
  227. hp:=tmodule(hp.next);
  228. end;
  229. end;
  230. Constructor TLinkerLinux.Create;
  231. begin
  232. Inherited Create;
  233. SetupLibrarySearchPath;
  234. end;
  235. procedure TLinkerLinux.SetDefaultInfo;
  236. {
  237. This will also detect which libc version will be used
  238. }
  239. const
  240. {$ifdef i386} platform_select='-b elf32-i386 -m elf_i386';{$endif}
  241. {$ifdef x86_64} platform_select='-b elf64-x86-64 -m elf_x86_64';{$endif}
  242. {$ifdef powerpc} platform_select='-b elf32-powerpc -m elf32ppclinux';{$endif}
  243. {$ifdef POWERPC64} platform_select='-b elf64-powerpc -m elf64ppc';{$endif}
  244. {$ifdef sparc} platform_select='-b elf32-sparc -m elf32_sparc';{$endif}
  245. {$ifdef arm} platform_select='';{$endif} {unknown :( }
  246. {$ifdef m68k} platform_select='';{$endif} {unknown :( }
  247. {$ifdef mips}
  248. {$ifdef mipsel}
  249. platform_select='-EL';
  250. {$else}
  251. platform_select='-EB';
  252. {$endif}
  253. {$endif}
  254. begin
  255. with Info do
  256. begin
  257. ExeCmd[1]:='ld '+platform_select+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE';
  258. { when we want to cross-link we need to override default library paths }
  259. if length(sysrootpath) > 0 then
  260. ExeCmd[1]:=ExeCmd[1]+' -T';
  261. ExeCmd[1]:=ExeCmd[1]+' $RES';
  262. DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
  263. DllCmd[2]:='strip --strip-unneeded $EXE';
  264. ExtDbgCmd[1]:='objcopy --only-keep-debug $EXE $DBG';
  265. ExtDbgCmd[2]:='objcopy --add-gnu-debuglink=$DBG $EXE';
  266. ExtDbgCmd[3]:='strip --strip-unneeded $EXE';
  267. SetupDynlinker(DynamicLinker,libctype);
  268. end;
  269. end;
  270. procedure TLinkerLinux.LoadPredefinedLibraryOrder;
  271. // put your linkorder/linkalias overrides here.
  272. // Note: assumes only called when reordering/aliasing is used.
  273. Begin
  274. if not (cs_link_no_default_lib_order in current_settings.globalswitches) Then
  275. Begin
  276. LinkLibraryOrder.add('gcc','',15);
  277. LinkLibraryOrder.add('c','',100);
  278. LinkLibraryOrder.add('gmon','',120);
  279. LinkLibraryOrder.add('dl','',140);
  280. LinkLibraryOrder.add('pthread','',160);
  281. end;
  282. End;
  283. type
  284. tlibcnames=array [TLibcType] of string[8];
  285. const { libc5 glibc2 glibc21 uclibc }
  286. cprtnames: tlibcnames = ('cprt0', 'cprt0', 'cprt21', 'ucprt0');
  287. csinames: tlibcnames = ('si_c', 'si_c', 'si_c21', 'si_uc');
  288. gprtnames: tlibcnames = ('gprt0', 'gprt0', 'gprt21', 'ugprt0');
  289. gsinames: tlibcnames = ('si_g', 'si_g', 'si_c21g','si_ucg');
  290. defprtnames: array[boolean] of string[8] = ('prt0', 'dllprt0');
  291. defsinames: array[boolean] of string[8] = ('si_prc','si_dll');
  292. { uclibc and glibc21 are not available on x86_64! si_g is also absent. }
  293. Procedure TLinkerLinux.InitSysInitUnitName;
  294. begin
  295. linklibc:=ModulesLinkToLibc;
  296. reorder:=linklibc and ReOrderEntries;
  297. sysinitunit:=defsinames[current_module.islibrary];
  298. prtobj:=defprtnames[current_module.islibrary];
  299. if current_module.islibrary then
  300. exit;
  301. if cs_profile in current_settings.moduleswitches then
  302. begin
  303. prtobj:=gprtnames[libctype];
  304. sysinitunit:=gsinames[libctype];
  305. linklibc:=true;
  306. end
  307. else if linklibc then
  308. begin
  309. prtobj:=cprtnames[libctype];
  310. sysinitunit:=csinames[libctype];
  311. end;
  312. end;
  313. Function TLinkerLinux.WriteResponseFile(isdll:boolean) : Boolean;
  314. Var
  315. linkres : TLinkRes;
  316. i : longint;
  317. HPath : TCmdStrListItem;
  318. s,s1,s2 : TCmdStr;
  319. found1,
  320. found2 : boolean;
  321. linksToSharedLibFiles : boolean;
  322. begin
  323. result:=False;
  324. { set special options for some targets }
  325. if cs_profile in current_settings.moduleswitches then
  326. begin
  327. if not(libctype in [glibc2,glibc21]) then
  328. AddSharedLibrary('gmon');
  329. AddSharedLibrary('c');
  330. end;
  331. { Open link.res file }
  332. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
  333. with linkres do
  334. begin
  335. { Write path to search libraries }
  336. HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  337. while assigned(HPath) do
  338. begin
  339. Add('SEARCH_DIR("'+HPath.Str+'")');
  340. HPath:=TCmdStrListItem(HPath.Next);
  341. end;
  342. HPath:=TCmdStrListItem(LibrarySearchPath.First);
  343. while assigned(HPath) do
  344. begin
  345. Add('SEARCH_DIR("'+HPath.Str+'")');
  346. HPath:=TCmdStrListItem(HPath.Next);
  347. end;
  348. { force local symbol resolution (i.e., inside the shared }
  349. { library itself) for all non-exorted symbols, otherwise }
  350. { several RTL symbols of FPC-compiled shared libraries }
  351. { will be bound to those of a single shared library or }
  352. { to the main program }
  353. if (isdll) then
  354. begin
  355. add('VERSION');
  356. add('{');
  357. add(' {');
  358. if not texportlibunix(exportlib).exportedsymnames.empty then
  359. begin
  360. add(' global:');
  361. repeat
  362. add(' '+texportlibunix(exportlib).exportedsymnames.getfirst+';');
  363. until texportlibunix(exportlib).exportedsymnames.empty;
  364. end;
  365. add(' local:');
  366. add(' *;');
  367. add(' };');
  368. add('}');
  369. end;
  370. StartSection('INPUT(');
  371. { add objectfiles, start with prt0 always }
  372. if not (target_info.system in systems_internal_sysinit) and (prtobj<>'') then
  373. AddFileName(maybequoted(FindObjectFile(prtobj,'',false)));
  374. { try to add crti and crtbegin if linking to C }
  375. if linklibc and (libctype<>uclibc) then
  376. begin
  377. { crti.o must come first }
  378. if librarysearchpath.FindFile('crti.o',false,s) then
  379. AddFileName(s)
  380. else
  381. Message1(exec_w_init_file_not_found,'crti.o');
  382. { then the crtbegin* }
  383. if cs_create_pic in current_settings.moduleswitches then
  384. begin
  385. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  386. AddFileName(s)
  387. else
  388. Message1(exec_w_init_file_not_found,'crtbeginS.o');
  389. end
  390. else
  391. if (cs_link_staticflag in current_settings.globalswitches) then
  392. begin
  393. if librarysearchpath.FindFile('crtbeginT.o',false,s) then
  394. AddFileName(s)
  395. else
  396. Message1(exec_w_init_file_not_found,'crtbeginT.o');
  397. end
  398. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  399. AddFileName(s)
  400. else
  401. Message1(exec_w_init_file_not_found,'crtbegin.o');
  402. end;
  403. { main objectfiles }
  404. while not ObjectFiles.Empty do
  405. begin
  406. s:=ObjectFiles.GetFirst;
  407. if s<>'' then
  408. AddFileName(maybequoted(s));
  409. end;
  410. EndSection(')');
  411. { Write staticlibraries }
  412. if not StaticLibFiles.Empty then
  413. begin
  414. Add('GROUP(');
  415. While not StaticLibFiles.Empty do
  416. begin
  417. S:=StaticLibFiles.GetFirst;
  418. AddFileName(maybequoted(s))
  419. end;
  420. Add(')');
  421. end;
  422. // we must reorder here because the result could empty sharedlibfiles
  423. if reorder Then
  424. ExpandAndApplyOrder(SharedLibFiles);
  425. // after this point addition of shared libs not allowed.
  426. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  427. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  428. if (isdll) then
  429. begin
  430. Add('INPUT(');
  431. Add(info.DynamicLinker);
  432. Add(')');
  433. end;
  434. linksToSharedLibFiles := not SharedLibFiles.Empty;
  435. if not SharedLibFiles.Empty then
  436. begin
  437. if (SharedLibFiles.Count<>1) or
  438. (TCmdStrListItem(SharedLibFiles.First).Str<>'c') or
  439. reorder then
  440. begin
  441. Add('INPUT(');
  442. While not SharedLibFiles.Empty do
  443. begin
  444. S:=SharedLibFiles.GetFirst;
  445. if (s<>'c') or reorder then
  446. begin
  447. i:=Pos(target_info.sharedlibext,S);
  448. if i>0 then
  449. Delete(S,i,255);
  450. Add('-l'+s);
  451. end
  452. else
  453. begin
  454. linklibc:=true;
  455. end;
  456. end;
  457. Add(')');
  458. end
  459. else
  460. linklibc:=true;
  461. if (cs_link_staticflag in current_settings.globalswitches) or
  462. (linklibc and not reorder) then
  463. begin
  464. Add('GROUP(');
  465. { when we have -static for the linker the we also need libgcc }
  466. if (cs_link_staticflag in current_settings.globalswitches) then
  467. begin
  468. Add('-lgcc');
  469. if librarysearchpath.FindFile('libgcc_eh.a',false,s1) then
  470. Add('-lgcc_eh');
  471. end;
  472. { be sure that libc is the last lib }
  473. if linklibc and not reorder then
  474. Add('-lc');
  475. Add(')');
  476. end;
  477. end;
  478. { objects which must be at the end }
  479. if linklibc and (libctype<>uclibc) then
  480. begin
  481. if cs_create_pic in current_settings.moduleswitches then
  482. begin
  483. found1:=librarysearchpath.FindFile('crtendS.o',false,s1);
  484. if not(found1) then
  485. Message1(exec_w_init_file_not_found,'crtendS.o');
  486. end
  487. else
  488. begin
  489. found1:=librarysearchpath.FindFile('crtend.o',false,s1);
  490. if not(found1) then
  491. Message1(exec_w_init_file_not_found,'crtend.o');
  492. end;
  493. found2:=librarysearchpath.FindFile('crtn.o',false,s2);
  494. if not(found2) then
  495. Message1(exec_w_init_file_not_found,'crtn.o');
  496. if found1 or found2 then
  497. begin
  498. Add('INPUT(');
  499. if found1 then
  500. AddFileName(s1);
  501. if found2 then
  502. AddFileName(s2);
  503. Add(')');
  504. end;
  505. end;
  506. {Entry point. Only needed for executables, set on the linker command line for
  507. shared libraries. }
  508. if (not isdll) then
  509. if (linksToSharedLibFiles and not linklibc) then
  510. add('ENTRY(_dynamic_start)')
  511. else
  512. add('ENTRY(_start)');
  513. {$ifdef x86_64}
  514. {$define LINKERSCRIPT_INCLUDED}
  515. add('SECTIONS');
  516. add('{');
  517. {Read-only sections, merged into text segment:}
  518. if current_module.islibrary then
  519. add(' . = 0 + SIZEOF_HEADERS;')
  520. else
  521. add(' PROVIDE (__executable_start = 0x0400000); . = 0x0400000 + SIZEOF_HEADERS;');
  522. add(' . = 0 + SIZEOF_HEADERS;');
  523. add(' .interp : { *(.interp) }');
  524. add(' .hash : { *(.hash) }');
  525. add(' .dynsym : { *(.dynsym) }');
  526. add(' .dynstr : { *(.dynstr) }');
  527. add(' .gnu.version : { *(.gnu.version) }');
  528. add(' .gnu.version_d : { *(.gnu.version_d) }');
  529. add(' .gnu.version_r : { *(.gnu.version_r) }');
  530. add(' .rel.dyn :');
  531. add(' {');
  532. add(' *(.rel.init)');
  533. add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
  534. add(' *(.rel.fini)');
  535. add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
  536. add(' *(.rel.data.rel.ro*)');
  537. add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
  538. add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
  539. add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
  540. add(' *(.rel.got)');
  541. add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
  542. add(' }');
  543. add(' .rela.dyn :');
  544. add(' {');
  545. add(' *(.rela.init)');
  546. add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
  547. add(' *(.rela.fini)');
  548. add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
  549. add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
  550. add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
  551. add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
  552. add(' *(.rela.got)');
  553. add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
  554. add(' }');
  555. add(' .rel.plt : { *(.rel.plt) }');
  556. add(' .rela.plt : { *(.rela.plt) }');
  557. add(' .init :');
  558. add(' {');
  559. add(' KEEP (*(.init))');
  560. add(' } =0x90909090');
  561. add(' .plt : { *(.plt) }');
  562. add(' .text :');
  563. add(' {');
  564. add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
  565. add(' KEEP (*(.text.*personality*))');
  566. {.gnu.warning sections are handled specially by elf32.em.}
  567. add(' *(.gnu.warning)');
  568. add(' } =0x90909090');
  569. add(' .fini :');
  570. add(' {');
  571. add(' KEEP (*(.fini))');
  572. add(' } =0x90909090');
  573. add(' PROVIDE (_etext = .);');
  574. add(' .rodata :');
  575. add(' {');
  576. add(' *(.rodata .rodata.* .gnu.linkonce.r.*)');
  577. add(' }');
  578. {Adjust the address for the data segment. We want to adjust up to
  579. the same address within the page on the next page up.}
  580. add(' . = ALIGN (0x1000) - ((0x1000 - .) & (0x1000 - 1));');
  581. add(' .dynamic : { *(.dynamic) }');
  582. add(' .got : { *(.got .toc) }');
  583. add(' .got.plt : { *(.got.plt .toc.plt) }');
  584. add(' .data :');
  585. add(' {');
  586. add(' *(.data .data.* .gnu.linkonce.d.*)');
  587. add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  588. add(' KEEP (*(.gnu.linkonce.d.*personality*))');
  589. add(' }');
  590. add(' PROVIDE (_edata = .);');
  591. add(' PROVIDE (edata = .);');
  592. {$ifdef zsegment_threadvars}
  593. add(' _z = .;');
  594. add(' .threadvar 0 : AT (_z) { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
  595. add(' PROVIDE (_threadvar_size = SIZEOF(.threadvar));');
  596. add(' . = _z + SIZEOF (.threadvar);');
  597. {$else}
  598. add(' .threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
  599. {$endif}
  600. add(' __bss_start = .;');
  601. add(' .bss :');
  602. add(' {');
  603. add(' *(.dynbss)');
  604. add(' *(.bss .bss.* .gnu.linkonce.b.*)');
  605. add(' *(COMMON)');
  606. {Align here to ensure that the .bss section occupies space up to
  607. _end. Align after .bss to ensure correct alignment even if the
  608. .bss section disappears because there are no input sections.}
  609. add(' . = ALIGN(32 / 8);');
  610. add('}');
  611. add(' . = ALIGN(32 / 8);');
  612. add(' PROVIDE (_end = .);');
  613. add(' PROVIDE (end = .);');
  614. {Stabs debugging sections.}
  615. add(' .stab 0 : { *(.stab) }');
  616. add(' .stabstr 0 : { *(.stabstr) }');
  617. add(' /* DWARF debug sections.');
  618. add(' Symbols in the DWARF debugging sections are relative to the beginning');
  619. add(' of the section so we begin them at 0. */');
  620. add(' /* DWARF 1 */');
  621. add(' .debug 0 : { *(.debug) }');
  622. add(' .line 0 : { *(.line) }');
  623. add(' /* GNU DWARF 1 extensions */');
  624. add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
  625. add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
  626. add(' /* DWARF 1.1 and DWARF 2 */');
  627. add(' .debug_aranges 0 : { *(.debug_aranges) }');
  628. add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
  629. add(' /* DWARF 2 */');
  630. add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
  631. add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
  632. add(' .debug_line 0 : { *(.debug_line) }');
  633. add(' .debug_frame 0 : { *(.debug_frame) }');
  634. add(' .debug_str 0 : { *(.debug_str) }');
  635. add(' .debug_loc 0 : { *(.debug_loc) }');
  636. add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
  637. add(' /* SGI/MIPS DWARF 2 extensions */');
  638. add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
  639. add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
  640. add(' .debug_typenames 0 : { *(.debug_typenames) }');
  641. add(' .debug_varnames 0 : { *(.debug_varnames) }');
  642. add(' /DISCARD/ : { *(.note.GNU-stack) }');
  643. add('}');
  644. {$endif x86_64}
  645. {$ifdef ARM}
  646. if target_info.abi in [abi_eabi,abi_eabihf] then
  647. begin
  648. { from GNU ld (CodeSourcery Sourcery G++ Lite 2007q3-53) 2.18.50.20070820 }
  649. add('/* Script for -z combreloc: combine and sort reloc sections */');
  650. add('OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",');
  651. add(' "elf32-littlearm")');
  652. add('OUTPUT_ARCH(arm)');
  653. add('SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");');
  654. add('SECTIONS');
  655. add('{');
  656. add(' /* Read-only sections, merged into text segment: */');
  657. add(' PROVIDE (__executable_start = 0x8000); . = 0x8000 + SIZEOF_HEADERS;');
  658. add(' .interp : { *(.interp) }');
  659. add(' .note.gnu.build-id : { *(.note.gnu.build-id) }');
  660. add(' .hash : { *(.hash) }');
  661. add(' .gnu.hash : { *(.gnu.hash) }');
  662. add(' .dynsym : { *(.dynsym) }');
  663. add(' .dynstr : { *(.dynstr) }');
  664. add(' .gnu.version : { *(.gnu.version) }');
  665. add(' .gnu.version_d : { *(.gnu.version_d) }');
  666. add(' .gnu.version_r : { *(.gnu.version_r) }');
  667. add(' .rel.dyn :');
  668. add(' {');
  669. add(' *(.rel.init)');
  670. add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
  671. add(' *(.rel.fini)');
  672. add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
  673. add(' *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)');
  674. add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
  675. add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
  676. add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
  677. add(' *(.rel.ctors)');
  678. add(' *(.rel.dtors)');
  679. add(' *(.rel.got)');
  680. add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
  681. add(' }');
  682. add(' .rela.dyn :');
  683. add(' {');
  684. add(' *(.rela.init)');
  685. add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
  686. add(' *(.rela.fini)');
  687. add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
  688. add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
  689. add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
  690. add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
  691. add(' *(.rela.ctors)');
  692. add(' *(.rela.dtors)');
  693. add(' *(.rela.got)');
  694. add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
  695. add(' }');
  696. add(' .rel.plt : { *(.rel.plt) }');
  697. add(' .rela.plt : { *(.rela.plt) }');
  698. add(' .init :');
  699. add(' {');
  700. add(' KEEP (*(.init))');
  701. add(' } =0');
  702. add(' .plt : { *(.plt) }');
  703. add(' .text :');
  704. add(' {');
  705. add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
  706. add(' KEEP (*(.text.*personality*))');
  707. add(' /* .gnu.warning sections are handled specially by elf32.em. */');
  708. add(' *(.gnu.warning)');
  709. add(' *(.glue_7t) *(.glue_7) *(.vfp11_veneer)');
  710. add(' } =0');
  711. add(' .fini :');
  712. add(' {');
  713. add(' KEEP (*(.fini))');
  714. add(' } =0');
  715. add(' PROVIDE (__etext = .);');
  716. add(' PROVIDE (_etext = .);');
  717. add(' PROVIDE (etext = .);');
  718. add(' .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }');
  719. add(' .rodata1 : { *(.rodata1) }');
  720. add(' .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) }');
  721. add(' __exidx_start = .;');
  722. add(' .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }');
  723. add(' __exidx_end = .;');
  724. add(' .eh_frame_hdr : { *(.eh_frame_hdr) }');
  725. add(' .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }');
  726. add(' .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }');
  727. add(' /* Adjust the address for the data segment. We want to adjust up to');
  728. add(' the same address within the page on the next page up. */');
  729. add(' . = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1));');
  730. add(' /* Exception handling */');
  731. add(' .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }');
  732. add(' .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }');
  733. add(' /* Thread Local Storage sections */');
  734. add(' .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }');
  735. add(' .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }');
  736. add(' .preinit_array :');
  737. add(' {');
  738. add(' PROVIDE_HIDDEN (__preinit_array_start = .);');
  739. add(' KEEP (*(.preinit_array))');
  740. add(' PROVIDE_HIDDEN (__preinit_array_end = .);');
  741. add(' }');
  742. add(' .init_array :');
  743. add(' {');
  744. add(' PROVIDE_HIDDEN (__init_array_start = .);');
  745. add(' KEEP (*(SORT(.init_array.*)))');
  746. add(' KEEP (*(.init_array))');
  747. add(' PROVIDE_HIDDEN (__init_array_end = .);');
  748. add(' }');
  749. add(' .fini_array :');
  750. add(' {');
  751. add(' PROVIDE_HIDDEN (__fini_array_start = .);');
  752. add(' KEEP (*(.fini_array))');
  753. add(' KEEP (*(SORT(.fini_array.*)))');
  754. add(' PROVIDE_HIDDEN (__fini_array_end = .);');
  755. add(' }');
  756. add(' .ctors :');
  757. add(' {');
  758. add(' /* gcc uses crtbegin.o to find the start of');
  759. add(' the constructors, so we make sure it is');
  760. add(' first. Because this is a wildcard, it');
  761. add(' doesn''t matter if the user does not');
  762. add(' actually link against crtbegin.o; the');
  763. add(' linker won''t look for a file to match a');
  764. add(' wildcard. The wildcard also means that it');
  765. add(' doesn''t matter which directory crtbegin.o');
  766. add(' is in. */');
  767. add(' KEEP (*crtbegin.o(.ctors))');
  768. add(' KEEP (*crtbegin?.o(.ctors))');
  769. add(' /* We don''t want to include the .ctor section from');
  770. add(' the crtend.o file until after the sorted ctors.');
  771. add(' The .ctor section from the crtend file contains the');
  772. add(' end of ctors marker and it must be last */');
  773. add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))');
  774. add(' KEEP (*(SORT(.ctors.*)))');
  775. add(' KEEP (*(.ctors))');
  776. add(' }');
  777. add(' .dtors :');
  778. add(' {');
  779. add(' KEEP (*crtbegin.o(.dtors))');
  780. add(' KEEP (*crtbegin?.o(.dtors))');
  781. add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))');
  782. add(' KEEP (*(SORT(.dtors.*)))');
  783. add(' KEEP (*(.dtors))');
  784. add(' }');
  785. add(' .jcr : { KEEP (*(.jcr)) }');
  786. add(' .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }');
  787. add(' .dynamic : { *(.dynamic) }');
  788. add(' .got : { *(.got.plt) *(.got) }');
  789. add(' .data :');
  790. add(' {');
  791. add(' __data_start = . ;');
  792. add(' *(.data .data.* .gnu.linkonce.d.*)');
  793. { extra by FPC }
  794. add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  795. add(' KEEP (*(.gnu.linkonce.d.*personality*))');
  796. add(' SORT(CONSTRUCTORS)');
  797. add(' }');
  798. add(' .data1 : { *(.data1) }');
  799. add(' _edata = .; PROVIDE (edata = .);');
  800. add(' __bss_start = .;');
  801. add(' __bss_start__ = .;');
  802. add(' .bss :');
  803. add(' {');
  804. add(' *(.dynbss)');
  805. add(' *(.bss .bss.* .gnu.linkonce.b.*)');
  806. add(' *(COMMON)');
  807. add(' /* Align here to ensure that the .bss section occupies space up to');
  808. add(' _end. Align after .bss to ensure correct alignment even if the');
  809. add(' .bss section disappears because there are no input sections.');
  810. add(' FIXME: Why do we need it? When there is no .bss section, we don''t');
  811. add(' pad the .data section. */');
  812. add(' . = ALIGN(. != 0 ? 32 / 8 : 1);');
  813. add(' }');
  814. add(' _bss_end__ = . ; __bss_end__ = . ;');
  815. add(' . = ALIGN(32 / 8);');
  816. add(' . = ALIGN(32 / 8);');
  817. add(' __end__ = . ;');
  818. add(' _end = .; PROVIDE (end = .);');
  819. add(' /* Stabs debugging sections. */');
  820. add(' .stab 0 : { *(.stab) }');
  821. add(' .stabstr 0 : { *(.stabstr) }');
  822. add(' .stab.excl 0 : { *(.stab.excl) }');
  823. add(' .stab.exclstr 0 : { *(.stab.exclstr) }');
  824. add(' .stab.index 0 : { *(.stab.index) }');
  825. add(' .stab.indexstr 0 : { *(.stab.indexstr) }');
  826. add(' .comment 0 : { *(.comment) }');
  827. add(' /* DWARF debug sections.');
  828. add(' Symbols in the DWARF debugging sections are relative to the beginning');
  829. add(' of the section so we begin them at 0. */');
  830. add(' /* DWARF 1 */');
  831. add(' .debug 0 : { *(.debug) }');
  832. add(' .line 0 : { *(.line) }');
  833. add(' /* GNU DWARF 1 extensions */');
  834. add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
  835. add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
  836. add(' /* DWARF 1.1 and DWARF 2 */');
  837. add(' .debug_aranges 0 : { *(.debug_aranges) }');
  838. add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
  839. add(' /* DWARF 2 */');
  840. add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
  841. add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
  842. add(' .debug_line 0 : { *(.debug_line) }');
  843. add(' .debug_frame 0 : { *(.debug_frame) }');
  844. add(' .debug_str 0 : { *(.debug_str) }');
  845. add(' .debug_loc 0 : { *(.debug_loc) }');
  846. add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
  847. add(' /* SGI/MIPS DWARF 2 extensions */');
  848. add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
  849. add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
  850. add(' .debug_typenames 0 : { *(.debug_typenames) }');
  851. add(' .debug_varnames 0 : { *(.debug_varnames) }');
  852. add(' /* DWARF 3 */');
  853. add(' .debug_pubtypes 0 : { *(.debug_pubtypes) }');
  854. add(' .debug_ranges 0 : { *(.debug_ranges) }');
  855. add(' .stack 0x80000 :');
  856. add(' {');
  857. add(' _stack = .;');
  858. add(' *(.stack)');
  859. add(' }');
  860. add(' .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }');
  861. add(' .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }');
  862. add(' /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }');
  863. add('}');
  864. end
  865. else
  866. {$endif ARM}
  867. {$ifndef LINKERSCRIPT_INCLUDED}
  868. begin
  869. {Sections.}
  870. add('SECTIONS');
  871. add('{');
  872. {Read-only sections, merged into text segment:}
  873. add(' PROVIDE (__executable_start = 0x010000); . = 0x010000 + SIZEOF_HEADERS;');
  874. add(' .interp : { *(.interp) }');
  875. add(' .hash : { *(.hash) }');
  876. add(' .dynsym : { *(.dynsym) }');
  877. add(' .dynstr : { *(.dynstr) }');
  878. add(' .gnu.version : { *(.gnu.version) }');
  879. add(' .gnu.version_d : { *(.gnu.version_d) }');
  880. add(' .gnu.version_r : { *(.gnu.version_r) }');
  881. add(' .rel.dyn :');
  882. add(' {');
  883. add(' *(.rel.init)');
  884. add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
  885. add(' *(.rel.fini)');
  886. add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
  887. add(' *(.rel.data.rel.ro*)');
  888. add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
  889. add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
  890. add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
  891. add(' *(.rel.got)');
  892. add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
  893. add(' }');
  894. add(' .rela.dyn :');
  895. add(' {');
  896. add(' *(.rela.init)');
  897. add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
  898. add(' *(.rela.fini)');
  899. add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
  900. add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
  901. add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
  902. add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
  903. add(' *(.rela.got)');
  904. add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
  905. add(' }');
  906. add(' .rel.plt : { *(.rel.plt) }');
  907. add(' .rela.plt : { *(.rela.plt) }');
  908. add(' .init :');
  909. add(' {');
  910. add(' KEEP (*(.init))');
  911. add(' } =0x90909090');
  912. add(' .plt : { *(.plt) }');
  913. add(' .text :');
  914. add(' {');
  915. add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
  916. add(' KEEP (*(.text.*personality*))');
  917. {.gnu.warning sections are handled specially by elf32.em.}
  918. add(' *(.gnu.warning)');
  919. add(' } =0x90909090');
  920. add(' .fini :');
  921. add(' {');
  922. add(' KEEP (*(.fini))');
  923. add(' } =0x90909090');
  924. add(' PROVIDE (_etext = .);');
  925. add(' .rodata :');
  926. add(' {');
  927. add(' *(.rodata .rodata.* .gnu.linkonce.r.*)');
  928. add(' }');
  929. {Adjust the address for the data segment. We want to adjust up to
  930. the same address within the page on the next page up.}
  931. add(' . = ALIGN (0x1000) - ((0x1000 - .) & (0x1000 - 1));');
  932. add(' .dynamic : { *(.dynamic) }');
  933. add(' .got : { *(.got) }');
  934. add(' .got.plt : { *(.got.plt) }');
  935. add(' .data :');
  936. add(' {');
  937. add(' *(.data .data.* .gnu.linkonce.d.*)');
  938. add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  939. add(' KEEP (*(.gnu.linkonce.d.*personality*))');
  940. add(' }');
  941. add(' PROVIDE (_edata = .);');
  942. add(' PROVIDE (edata = .);');
  943. {$ifdef zsegment_threadvars}
  944. add(' _z = .;');
  945. add(' .threadvar 0 : AT (_z) { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
  946. add(' PROVIDE (_threadvar_size = SIZEOF(.threadvar));');
  947. add(' . = _z + SIZEOF (.threadvar);');
  948. {$else}
  949. add(' .threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
  950. {$endif}
  951. add(' __bss_start = .;');
  952. add(' .bss :');
  953. add(' {');
  954. add(' *(.dynbss)');
  955. add(' *(.bss .bss.* .gnu.linkonce.b.*)');
  956. add(' *(COMMON)');
  957. {Align here to ensure that the .bss section occupies space up to
  958. _end. Align after .bss to ensure correct alignment even if the
  959. .bss section disappears because there are no input sections.}
  960. add(' . = ALIGN(32 / 8);');
  961. add(' }');
  962. add(' . = ALIGN(32 / 8);');
  963. add(' PROVIDE (_end = .);');
  964. add(' PROVIDE (end = .);');
  965. {Stabs debugging sections.}
  966. add(' .stab 0 : { *(.stab) }');
  967. add(' .stabstr 0 : { *(.stabstr) }');
  968. add('}');
  969. end;
  970. {$endif LINKERSCRIPT_INCLUDED}
  971. { Write and Close response }
  972. writetodisk;
  973. Free;
  974. end;
  975. WriteResponseFile:=True;
  976. end;
  977. function TLinkerLinux.MakeExecutable:boolean;
  978. var
  979. i : longint;
  980. binstr,
  981. cmdstr : TCmdStr;
  982. success : boolean;
  983. DynLinkStr : string;
  984. GCSectionsStr,
  985. StaticStr,
  986. StripStr : string[40];
  987. begin
  988. if not(cs_link_nolink in current_settings.globalswitches) then
  989. Message1(exec_i_linking,current_module.exefilename);
  990. { Create some replacements }
  991. StaticStr:='';
  992. StripStr:='';
  993. GCSectionsStr:='';
  994. DynLinkStr:='';
  995. if (cs_link_staticflag in current_settings.globalswitches) then
  996. StaticStr:='-static';
  997. if (cs_link_strip in current_settings.globalswitches) and
  998. not(cs_link_separate_dbg_file in current_settings.globalswitches) then
  999. StripStr:='-s';
  1000. if (cs_link_map in current_settings.globalswitches) then
  1001. StripStr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
  1002. if (cs_link_smart in current_settings.globalswitches) and
  1003. create_smartlink_sections then
  1004. GCSectionsStr:='--gc-sections';
  1005. If (cs_profile in current_settings.moduleswitches) or
  1006. ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then
  1007. begin
  1008. DynLinkStr:='--dynamic-linker='+Info.DynamicLinker;
  1009. if cshared then
  1010. DynLinkStr:=DynLinkStr+' --shared ';
  1011. if rlinkpath<>'' then
  1012. DynLinkStr:=DynLinkStr+' --rpath-link '+rlinkpath;
  1013. End;
  1014. { Write used files and libraries }
  1015. WriteResponseFile(false);
  1016. { Call linker }
  1017. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  1018. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  1019. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  1020. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  1021. Replace(cmdstr,'$STATIC',StaticStr);
  1022. Replace(cmdstr,'$STRIP',StripStr);
  1023. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  1024. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  1025. { create dynamic symbol table? }
  1026. if HasExports then
  1027. cmdstr:=cmdstr+' -E';
  1028. success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
  1029. { Create external .dbg file with debuginfo }
  1030. if success and (cs_link_separate_dbg_file in current_settings.globalswitches) then
  1031. begin
  1032. for i:=1 to 3 do
  1033. begin
  1034. SplitBinCmd(Info.ExtDbgCmd[i],binstr,cmdstr);
  1035. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  1036. Replace(cmdstr,'$DBGFN',maybequoted(extractfilename(current_module.dbgfilename)));
  1037. Replace(cmdstr,'$DBG',maybequoted(current_module.dbgfilename));
  1038. success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
  1039. if not success then
  1040. break;
  1041. end;
  1042. end;
  1043. { Remove ReponseFile }
  1044. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  1045. DeleteFile(outputexedir+Info.ResName);
  1046. MakeExecutable:=success; { otherwise a recursive call to link method }
  1047. end;
  1048. Function TLinkerLinux.MakeSharedLibrary:boolean;
  1049. var
  1050. InitStr,
  1051. FiniStr,
  1052. SoNameStr : string[80];
  1053. binstr,
  1054. cmdstr : TCmdStr;
  1055. success : boolean;
  1056. begin
  1057. MakeSharedLibrary:=false;
  1058. if not(cs_link_nolink in current_settings.globalswitches) then
  1059. Message1(exec_i_linking,current_module.sharedlibfilename);
  1060. { Write used files and libraries }
  1061. WriteResponseFile(true);
  1062. { Create some replacements }
  1063. { note: linux does not use exportlib.initname/fininame due to the custom startup code }
  1064. InitStr:='-init FPC_SHARED_LIB_START';
  1065. FiniStr:='-fini FPC_LIB_EXIT';
  1066. SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
  1067. { Call linker }
  1068. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  1069. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  1070. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  1071. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  1072. Replace(cmdstr,'$INIT',InitStr);
  1073. Replace(cmdstr,'$FINI',FiniStr);
  1074. Replace(cmdstr,'$SONAME',SoNameStr);
  1075. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
  1076. { Strip the library ? }
  1077. if success and (cs_link_strip in current_settings.globalswitches) then
  1078. begin
  1079. { only remove non global symbols and debugging info for a library }
  1080. Info.DllCmd[2]:='strip --discard-all --strip-debug $EXE';
  1081. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  1082. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  1083. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
  1084. end;
  1085. { Remove ReponseFile }
  1086. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  1087. DeleteFile(outputexedir+Info.ResName);
  1088. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  1089. end;
  1090. {*****************************************************************************
  1091. TINTERNALLINKERLINUX
  1092. *****************************************************************************}
  1093. constructor TInternalLinkerLinux.Create;
  1094. begin
  1095. inherited Create;
  1096. SetupLibrarySearchPath;
  1097. SetupDynlinker(dynlinker,libctype);
  1098. CExeOutput:=ElfExeOutputClass;
  1099. CObjInput:=TElfObjInput;
  1100. end;
  1101. procedure TInternalLinkerLinux.InitSysInitUnitName;
  1102. begin
  1103. linklibc:=ModulesLinkToLibc;
  1104. reorder:=linklibc and ReOrderEntries;
  1105. sysinitunit:=defsinames[current_module.islibrary];
  1106. prtobj:=defprtnames[current_module.islibrary];
  1107. if cs_profile in current_settings.moduleswitches then
  1108. begin
  1109. prtobj:=gprtnames[libctype];
  1110. sysinitunit:=gsinames[libctype];
  1111. linklibc:=true;
  1112. end
  1113. else if linklibc then
  1114. begin
  1115. prtobj:=cprtnames[libctype];
  1116. sysinitunit:=csinames[libctype];
  1117. end;
  1118. end;
  1119. const
  1120. relsec_prefix:array[boolean] of TCmdStr = ('rel','rela');
  1121. procedure TInternalLinkerLinux.DefaultLinkScript;
  1122. var
  1123. s,s1,s2,relprefix:TCmdStr;
  1124. found1,found2:boolean;
  1125. linkToSharedLibs:boolean;
  1126. procedure AddLibraryStatement(const s:TCmdStr);
  1127. var
  1128. i:longint;
  1129. s1,s2:TCmdStr;
  1130. begin
  1131. i:=pos(target_info.sharedClibext+'.',s);
  1132. if (i>0) then
  1133. s1:=target_info.sharedClibprefix+S
  1134. else
  1135. s1:=target_info.sharedClibprefix+S+target_info.sharedClibext;
  1136. { TODO: to be compatible with ld search algorithm, each found file
  1137. must be tested for target compatibility, incompatible ones should be skipped. }
  1138. { TODO: shall we search library without suffix if one with suffix is not found? }
  1139. if (not(cs_link_staticflag in current_settings.globalswitches)) and
  1140. FindLibraryFile(s1,'','',s2) then
  1141. LinkScript.Concat('READSTATICLIBRARY '+maybequoted(s2))
  1142. { TODO: static libraries never have numeric suffix in their names }
  1143. else if FindLibraryFile(s,target_info.staticClibprefix,target_info.staticClibext,s2) then
  1144. LinkScript.Concat('READSTATICLIBRARY '+maybequoted(s2))
  1145. else
  1146. Comment(V_Error,'Import library not found for '+S);
  1147. end;
  1148. begin
  1149. if cs_profile in current_settings.moduleswitches then
  1150. begin
  1151. if not(libctype in [glibc2,glibc21]) then
  1152. AddSharedLibrary('gmon');
  1153. AddSharedLibrary('c');
  1154. end;
  1155. TElfExeOutput(exeoutput).interpreter:=stringdup(dynlinker);
  1156. { add objectfiles, start with prt0 always }
  1157. if not (target_info.system in systems_internal_sysinit) and (prtobj<>'') then
  1158. LinkScript.Concat('READOBJECT '+ maybequoted(FindObjectFile(prtobj,'',false)));
  1159. { try to add crti and crtbegin if linking to C }
  1160. if linklibc and (libctype<>uclibc) then
  1161. begin
  1162. { crti.o must come first }
  1163. if librarysearchpath.FindFile('crti.o',false,s) then
  1164. LinkScript.Concat('READOBJECT '+maybequoted(s));
  1165. { then the crtbegin* }
  1166. if cs_create_pic in current_settings.moduleswitches then
  1167. begin
  1168. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  1169. LinkScript.Concat('READOBJECT '+maybequoted(s));
  1170. end
  1171. else
  1172. if (cs_link_staticflag in current_settings.globalswitches) and
  1173. librarysearchpath.FindFile('crtbeginT.o',false,s) then
  1174. LinkScript.Concat('READOBJECT '+maybequoted(s))
  1175. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  1176. LinkScript.Concat('READOBJECT '+maybequoted(s));
  1177. end;
  1178. ScriptAddSourceStatements(false);
  1179. { we must reorder here because the result could empty sharedlibfiles }
  1180. if reorder then
  1181. ExpandAndApplyOrder(SharedLibFiles);
  1182. { See tw9089*.pp: if more than one pure-Pascal shared libs are loaded,
  1183. and none have rtld in their DT_NEEDED, then rtld cannot finalize correctly. }
  1184. if IsSharedLibrary then
  1185. LinkScript.Concat('READSTATICLIBRARY '+maybequoted(sysrootpath+dynlinker));
  1186. linkToSharedLibs:=(not SharedLibFiles.Empty);
  1187. { Symbols declared as "external 'libx.so'" are added to ImportLibraryList, library
  1188. prefix/extension *not* stripped. TImportLibLinux copies these to SharedLibFiles,
  1189. stripping prefixes and extensions.
  1190. However extension won't be stripped if library is specified with numeric suffix
  1191. (like "libpango-1.0.so.0")
  1192. Libraries specified with $LINKLIB directive are directly added to SharedLibFiles
  1193. and won't be present in ImportLibraryList. }
  1194. while not SharedLibFiles.Empty do
  1195. begin
  1196. S:=SharedLibFiles.GetFirst;
  1197. if (S<>'c') or reorder then
  1198. AddLibraryStatement(S);
  1199. end;
  1200. if (cs_link_staticflag in current_settings.globalswitches) or
  1201. (linklibc and not reorder) then
  1202. begin
  1203. LinkScript.Concat('GROUP');
  1204. if (cs_link_staticflag in current_settings.globalswitches) then
  1205. begin
  1206. AddLibraryStatement('gcc');
  1207. AddLibraryStatement('gcc_eh');
  1208. end;
  1209. if linklibc and not reorder then
  1210. AddLibraryStatement('c');
  1211. LinkScript.Concat('ENDGROUP');
  1212. end;
  1213. { objects which must be at the end }
  1214. if linklibc and (libctype<>uclibc) then
  1215. begin
  1216. if cs_create_pic in current_settings.moduleswitches then
  1217. found1:=librarysearchpath.FindFile('crtendS.o',false,s1)
  1218. else
  1219. found1:=librarysearchpath.FindFile('crtend.o',false,s1);
  1220. found2:=librarysearchpath.FindFile('crtn.o',false,s2);
  1221. if found1 then
  1222. LinkScript.Concat('READOBJECT '+maybequoted(s1));
  1223. if found2 then
  1224. LinkScript.Concat('READOBJECT '+maybequoted(s2));
  1225. end;
  1226. if (not IsSharedLibrary) then
  1227. if (linkToSharedLibs and not linklibc) then
  1228. LinkScript.Concat('ENTRYNAME _dynamic_start')
  1229. else
  1230. LinkScript.Concat('ENTRYNAME _start')
  1231. else
  1232. LinkScript.Concat('ISSHAREDLIBRARY');
  1233. relprefix:=relsec_prefix[ElfTarget.relocs_use_addend];
  1234. with LinkScript do
  1235. begin
  1236. Concat('HEADER');
  1237. Concat('EXESECTION .interp');
  1238. Concat(' OBJSECTION .interp');
  1239. Concat('ENDEXESECTION');
  1240. Concat('EXESECTION .note.ABI-tag');
  1241. Concat(' OBJSECTION .note.ABI-tag');
  1242. Concat('ENDEXESECTION');
  1243. Concat('EXESECTION .note.gnu.build-id');
  1244. Concat(' OBJSECTION .note.gnu.build-id');
  1245. Concat('ENDEXESECTION');
  1246. Concat('EXESECTION .hash');
  1247. Concat(' OBJSECTION .hash');
  1248. Concat('ENDEXESECTION');
  1249. Concat('EXESECTION .dynsym');
  1250. Concat(' OBJSECTION .dynsym');
  1251. Concat('ENDEXESECTION');
  1252. Concat('EXESECTION .dynstr');
  1253. Concat(' OBJSECTION .dynstr');
  1254. Concat('ENDEXESECTION');
  1255. Concat('EXESECTION .gnu.version');
  1256. Concat(' OBJSECTION .gnu.version');
  1257. Concat('ENDEXESECTION');
  1258. Concat('EXESECTION .gnu.version_d');
  1259. Concat(' OBJSECTION .gnu.version_d');
  1260. Concat('ENDEXESECTION');
  1261. Concat('EXESECTION .gnu.version_r');
  1262. Concat(' OBJSECTION .gnu.version_r');
  1263. Concat('ENDEXESECTION');
  1264. Concat('EXESECTION .'+relprefix+'.dyn');
  1265. Concat(' OBJSECTION .'+relprefix+'.dyn');
  1266. Concat('ENDEXESECTION');
  1267. Concat('EXESECTION .'+relprefix+'.plt');
  1268. Concat(' OBJSECTION .'+relprefix+'.plt');
  1269. Concat(' PROVIDE __'+relprefix+'_iplt_start');
  1270. Concat(' OBJSECTION .'+relprefix+'.iplt');
  1271. Concat(' PROVIDE __'+relprefix+'_iplt_end');
  1272. Concat('ENDEXESECTION');
  1273. Concat('EXESECTION .init');
  1274. Concat(' OBJSECTION .init');
  1275. Concat('ENDEXESECTION');
  1276. Concat('EXESECTION .plt');
  1277. Concat(' OBJSECTION .plt');
  1278. Concat('ENDEXESECTION');
  1279. Concat('EXESECTION .text');
  1280. Concat(' OBJSECTION .text*');
  1281. Concat('ENDEXESECTION');
  1282. Concat('EXESECTION .fini');
  1283. Concat(' OBJSECTION .fini');
  1284. Concat(' PROVIDE __etext');
  1285. Concat(' PROVIDE _etext');
  1286. Concat(' PROVIDE etext');
  1287. Concat('ENDEXESECTION');
  1288. Concat('EXESECTION .rodata');
  1289. Concat(' OBJSECTION .rodata*');
  1290. Concat('ENDEXESECTION');
  1291. {$ifdef arm}
  1292. Concat('EXESECTION .ARM.extab');
  1293. Concat(' OBJSECTION .ARM.extab*');
  1294. Concat('ENDEXESECTION');
  1295. Concat('EXESECTION .ARM.exidx');
  1296. Concat(' SYMBOL __exidx_start');
  1297. Concat(' OBJSECTION .ARM.exidx*');
  1298. Concat(' SYMBOL __exidx_end');
  1299. Concat('ENDEXESECTION');
  1300. {$endif}
  1301. Concat('EXESECTION .eh_frame');
  1302. Concat(' OBJSECTION .eh_frame');
  1303. Concat('ENDEXESECTION');
  1304. Concat('EXESECTION .gcc_except_table');
  1305. Concat(' OBJSECTION .gcc_except_table');
  1306. Concat(' OBJSECTION .gcc_except_table.*');
  1307. Concat('ENDEXESECTION');
  1308. Concat('EXESECTION .tdata');
  1309. Concat(' OBJSECTION .tdata');
  1310. Concat(' OBJSECTION .tdata.*');
  1311. Concat('ENDEXESECTION');
  1312. Concat('EXESECTION .tbss');
  1313. Concat(' OBJSECTION .tbss');
  1314. Concat(' OBJSECTION .tbss.*');
  1315. Concat('ENDEXESECTION');
  1316. Concat('EXESECTION .preinit_array');
  1317. Concat(' PROVIDE __preinit_array_start');
  1318. Concat(' OBJSECTION .preinit_array');
  1319. Concat(' PROVIDE __preinit_array_end');
  1320. Concat('ENDEXESECTION');
  1321. Concat('EXESECTION .init_array');
  1322. Concat(' PROVIDE __init_array_start');
  1323. { why the hell .ctors are both here and exesection .ctors below?? }
  1324. // KEEP ( *(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  1325. Concat(' OBJSECTION .init_array');
  1326. // KEEP ( *(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  1327. Concat('PROVIDE __init_array_end');
  1328. Concat('ENDEXESECTION');
  1329. Concat('EXESECTION .fini_array');
  1330. Concat(' PROVIDE __fini_array_start');
  1331. // KEEP ( *(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  1332. Concat(' OBJSECTION .fini_array');
  1333. // KEEP ( *(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  1334. Concat(' PROVIDE __fini_array_end');
  1335. Concat('ENDEXESECTION');
  1336. Concat('EXESECTION .ctors');
  1337. Concat(' OBJSECTION .ctors*');
  1338. Concat('ENDEXESECTION');
  1339. Concat('EXESECTION .dtors');
  1340. Concat(' OBJSECTION .dtors*');
  1341. Concat('ENDEXESECTION');
  1342. Concat('EXESECTION .jcr');
  1343. Concat(' OBJSECTION .jcr');
  1344. Concat('ENDEXESECTION');
  1345. Concat('EXESECTION .dynamic');
  1346. Concat(' OBJSECTION .dynamic');
  1347. Concat('ENDEXESECTION');
  1348. {$ifndef mips}
  1349. Concat('EXESECTION .got');
  1350. {$ifdef arm}
  1351. Concat(' OBJSECTION .got.plt');
  1352. {$endif arm}
  1353. Concat(' OBJSECTION .got');
  1354. Concat('ENDEXESECTION');
  1355. {$endif mips}
  1356. {$ifndef arm}
  1357. Concat('EXESECTION .got.plt');
  1358. Concat(' OBJSECTION .got.plt');
  1359. Concat('ENDEXESECTION');
  1360. {$endif arm}
  1361. Concat('EXESECTION .data');
  1362. Concat(' OBJSECTION .data*');
  1363. Concat(' OBJSECTION .fpc*');
  1364. Concat(' OBJSECTION fpc.resources');
  1365. Concat(' PROVIDE _edata');
  1366. Concat(' PROVIDE edata');
  1367. Concat('ENDEXESECTION');
  1368. {$ifdef mips}
  1369. Concat('EXESECTION .got');
  1370. Concat(' OBJSECTION .got');
  1371. Concat('ENDEXESECTION');
  1372. {$endif mips}
  1373. Concat('EXESECTION .bss');
  1374. Concat(' OBJSECTION .dynbss');
  1375. Concat(' OBJSECTION .bss*');
  1376. Concat(' OBJSECTION fpc.reshandles');
  1377. Concat(' PROVIDE end');
  1378. Concat(' SYMBOL _end');
  1379. Concat('ENDEXESECTION');
  1380. ScriptAddGenericSections('.debug_aranges,.debug_pubnames,.debug_info,'+
  1381. '.debug_abbrev,.debug_line,.debug_frame,.debug_str,.debug_loc,'+
  1382. '.debug_macinfo,.debug_weaknames,.debug_funcnames,.debug_typenames,.debug_varnames,.debug_ranges');
  1383. Concat('EXESECTION .stab');
  1384. Concat(' OBJSECTION .stab');
  1385. Concat('ENDEXESECTION');
  1386. Concat('EXESECTION .stabstr');
  1387. Concat(' OBJSECTION .stabstr');
  1388. Concat('ENDEXESECTION');
  1389. end;
  1390. end;
  1391. {*****************************************************************************
  1392. Initialize
  1393. *****************************************************************************}
  1394. initialization
  1395. RegisterLinker(ld_linux,TLinkerLinux);
  1396. RegisterLinker(ld_int_linux,TInternalLinkerLinux);
  1397. {$ifdef i386}
  1398. RegisterImport(system_i386_linux,timportliblinux);
  1399. RegisterExport(system_i386_linux,texportliblinux);
  1400. RegisterTarget(system_i386_linux_info);
  1401. {$endif i386}
  1402. {$ifdef m68k}
  1403. RegisterImport(system_m68k_linux,timportliblinux);
  1404. RegisterExport(system_m68k_linux,texportliblinux);
  1405. RegisterTarget(system_m68k_linux_info);
  1406. {$endif m68k}
  1407. {$ifdef powerpc}
  1408. RegisterImport(system_powerpc_linux,timportliblinux);
  1409. RegisterExport(system_powerpc_linux,texportliblinux);
  1410. RegisterTarget(system_powerpc_linux_info);
  1411. {$endif powerpc}
  1412. {$ifdef powerpc64}
  1413. RegisterImport(system_powerpc64_linux,timportliblinux);
  1414. RegisterExport(system_powerpc64_linux,texportliblinux);
  1415. RegisterTarget(system_powerpc64_linux_info);
  1416. {$endif powerpc64}
  1417. {$ifdef alpha}
  1418. RegisterImport(system_alpha_linux,timportliblinux);
  1419. RegisterExport(system_alpha_linux,texportliblinux);
  1420. RegisterTarget(system_alpha_linux_info);
  1421. {$endif alpha}
  1422. {$ifdef x86_64}
  1423. RegisterImport(system_x86_64_linux,timportliblinux);
  1424. RegisterExport(system_x86_64_linux,texportliblinux);
  1425. RegisterTarget(system_x86_64_linux_info);
  1426. {$endif x86_64}
  1427. {$ifdef SPARC}
  1428. RegisterImport(system_SPARC_linux,timportliblinux);
  1429. RegisterExport(system_SPARC_linux,texportliblinux);
  1430. RegisterTarget(system_SPARC_linux_info);
  1431. {$endif SPARC}
  1432. {$ifdef ARM}
  1433. RegisterImport(system_arm_linux,timportliblinux);
  1434. RegisterExport(system_arm_linux,texportliblinux);
  1435. RegisterTarget(system_arm_linux_info);
  1436. {$endif ARM}
  1437. {$ifdef MIPS}
  1438. {$ifdef MIPSEL}
  1439. RegisterImport(system_mipsel_linux,timportliblinux);
  1440. RegisterExport(system_mipsel_linux,texportliblinux);
  1441. RegisterTarget(system_mipsel_linux_info);
  1442. {$else MIPS}
  1443. RegisterImport(system_mipseb_linux,timportliblinux);
  1444. RegisterExport(system_mipseb_linux,texportliblinux);
  1445. RegisterTarget(system_mipseb_linux_info);
  1446. {$endif MIPSEL}
  1447. {$endif MIPS}
  1448. RegisterRes(res_elf_info,TWinLikeResourceFile);
  1449. end.