t_linux.pas 57 KB

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