2
0

t_linux.pas 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560
  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. else
  448. if Pos('.',s)>0 then
  449. { enforce the filename }
  450. s:=':'+s;
  451. Add('-l'+s);
  452. end
  453. else
  454. begin
  455. linklibc:=true;
  456. end;
  457. end;
  458. Add(')');
  459. end
  460. else
  461. linklibc:=true;
  462. if (cs_link_staticflag in current_settings.globalswitches) or
  463. (linklibc and not reorder) then
  464. begin
  465. Add('GROUP(');
  466. { when we have -static for the linker the we also need libgcc }
  467. if (cs_link_staticflag in current_settings.globalswitches) then
  468. begin
  469. Add('-lgcc');
  470. if librarysearchpath.FindFile('libgcc_eh.a',false,s1) then
  471. Add('-lgcc_eh');
  472. end;
  473. { be sure that libc is the last lib }
  474. if linklibc and not reorder then
  475. Add('-lc');
  476. Add(')');
  477. end;
  478. end;
  479. { objects which must be at the end }
  480. if linklibc and (libctype<>uclibc) then
  481. begin
  482. if cs_create_pic in current_settings.moduleswitches then
  483. begin
  484. found1:=librarysearchpath.FindFile('crtendS.o',false,s1);
  485. if not(found1) then
  486. Message1(exec_w_init_file_not_found,'crtendS.o');
  487. end
  488. else
  489. begin
  490. found1:=librarysearchpath.FindFile('crtend.o',false,s1);
  491. if not(found1) then
  492. Message1(exec_w_init_file_not_found,'crtend.o');
  493. end;
  494. found2:=librarysearchpath.FindFile('crtn.o',false,s2);
  495. if not(found2) then
  496. Message1(exec_w_init_file_not_found,'crtn.o');
  497. if found1 or found2 then
  498. begin
  499. Add('INPUT(');
  500. if found1 then
  501. AddFileName(s1);
  502. if found2 then
  503. AddFileName(s2);
  504. Add(')');
  505. end;
  506. end;
  507. {Entry point. Only needed for executables, set on the linker command line for
  508. shared libraries. }
  509. if (not isdll) then
  510. if (linksToSharedLibFiles and not linklibc) then
  511. add('ENTRY(_dynamic_start)')
  512. else
  513. add('ENTRY(_start)');
  514. {$ifdef x86_64}
  515. {$define LINKERSCRIPT_INCLUDED}
  516. add('SECTIONS');
  517. add('{');
  518. {Read-only sections, merged into text segment:}
  519. if current_module.islibrary then
  520. add(' . = 0 + SIZEOF_HEADERS;')
  521. else
  522. add(' PROVIDE (__executable_start = 0x0400000); . = 0x0400000 + SIZEOF_HEADERS;');
  523. add(' . = 0 + SIZEOF_HEADERS;');
  524. add(' .interp : { *(.interp) }');
  525. add(' .hash : { *(.hash) }');
  526. add(' .dynsym : { *(.dynsym) }');
  527. add(' .dynstr : { *(.dynstr) }');
  528. add(' .gnu.version : { *(.gnu.version) }');
  529. add(' .gnu.version_d : { *(.gnu.version_d) }');
  530. add(' .gnu.version_r : { *(.gnu.version_r) }');
  531. add(' .rel.dyn :');
  532. add(' {');
  533. add(' *(.rel.init)');
  534. add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
  535. add(' *(.rel.fini)');
  536. add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
  537. add(' *(.rel.data.rel.ro*)');
  538. add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
  539. add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
  540. add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
  541. add(' *(.rel.got)');
  542. add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
  543. add(' }');
  544. add(' .rela.dyn :');
  545. add(' {');
  546. add(' *(.rela.init)');
  547. add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
  548. add(' *(.rela.fini)');
  549. add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
  550. add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
  551. add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
  552. add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
  553. add(' *(.rela.got)');
  554. add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
  555. add(' }');
  556. add(' .rel.plt : { *(.rel.plt) }');
  557. add(' .rela.plt : { *(.rela.plt) }');
  558. add(' .init :');
  559. add(' {');
  560. add(' KEEP (*(.init))');
  561. add(' } =0x90909090');
  562. add(' .plt : { *(.plt) }');
  563. add(' .text :');
  564. add(' {');
  565. add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
  566. add(' KEEP (*(.text.*personality*))');
  567. {.gnu.warning sections are handled specially by elf32.em.}
  568. add(' *(.gnu.warning)');
  569. add(' } =0x90909090');
  570. add(' .fini :');
  571. add(' {');
  572. add(' KEEP (*(.fini))');
  573. add(' } =0x90909090');
  574. add(' PROVIDE (_etext = .);');
  575. add(' .rodata :');
  576. add(' {');
  577. add(' *(.rodata .rodata.* .gnu.linkonce.r.*)');
  578. add(' }');
  579. {Adjust the address for the data segment. We want to adjust up to
  580. the same address within the page on the next page up.}
  581. add(' . = ALIGN (0x1000) - ((0x1000 - .) & (0x1000 - 1));');
  582. add(' .dynamic : { *(.dynamic) }');
  583. add(' .got : { *(.got .toc) }');
  584. add(' .got.plt : { *(.got.plt .toc.plt) }');
  585. add(' .data :');
  586. add(' {');
  587. add(' *(.data .data.* .gnu.linkonce.d.*)');
  588. add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  589. add(' KEEP (*(.gnu.linkonce.d.*personality*))');
  590. add(' }');
  591. add(' PROVIDE (_edata = .);');
  592. add(' PROVIDE (edata = .);');
  593. {$ifdef zsegment_threadvars}
  594. add(' _z = .;');
  595. add(' .threadvar 0 : AT (_z) { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
  596. add(' PROVIDE (_threadvar_size = SIZEOF(.threadvar));');
  597. add(' . = _z + SIZEOF (.threadvar);');
  598. {$else}
  599. add(' .threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
  600. {$endif}
  601. add(' __bss_start = .;');
  602. add(' .bss :');
  603. add(' {');
  604. add(' *(.dynbss)');
  605. add(' *(.bss .bss.* .gnu.linkonce.b.*)');
  606. add(' *(COMMON)');
  607. {Align here to ensure that the .bss section occupies space up to
  608. _end. Align after .bss to ensure correct alignment even if the
  609. .bss section disappears because there are no input sections.}
  610. add(' . = ALIGN(32 / 8);');
  611. add('}');
  612. add(' . = ALIGN(32 / 8);');
  613. add(' PROVIDE (_end = .);');
  614. add(' PROVIDE (end = .);');
  615. {Stabs debugging sections.}
  616. add(' .stab 0 : { *(.stab) }');
  617. add(' .stabstr 0 : { *(.stabstr) }');
  618. add(' /* DWARF debug sections.');
  619. add(' Symbols in the DWARF debugging sections are relative to the beginning');
  620. add(' of the section so we begin them at 0. */');
  621. add(' /* DWARF 1 */');
  622. add(' .debug 0 : { *(.debug) }');
  623. add(' .line 0 : { *(.line) }');
  624. add(' /* GNU DWARF 1 extensions */');
  625. add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
  626. add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
  627. add(' /* DWARF 1.1 and DWARF 2 */');
  628. add(' .debug_aranges 0 : { *(.debug_aranges) }');
  629. add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
  630. add(' /* DWARF 2 */');
  631. add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
  632. add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
  633. add(' .debug_line 0 : { *(.debug_line) }');
  634. add(' .debug_frame 0 : { *(.debug_frame) }');
  635. add(' .debug_str 0 : { *(.debug_str) }');
  636. add(' .debug_loc 0 : { *(.debug_loc) }');
  637. add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
  638. add(' /* SGI/MIPS DWARF 2 extensions */');
  639. add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
  640. add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
  641. add(' .debug_typenames 0 : { *(.debug_typenames) }');
  642. add(' .debug_varnames 0 : { *(.debug_varnames) }');
  643. add(' /DISCARD/ : { *(.note.GNU-stack) }');
  644. add('}');
  645. {$endif x86_64}
  646. {$ifdef ARM}
  647. if target_info.abi=abi_eabi then
  648. begin
  649. { from GNU ld (CodeSourcery Sourcery G++ Lite 2007q3-53) 2.18.50.20070820 }
  650. add('/* Script for -z combreloc: combine and sort reloc sections */');
  651. add('OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",');
  652. add(' "elf32-littlearm")');
  653. add('OUTPUT_ARCH(arm)');
  654. add('SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");');
  655. add('SECTIONS');
  656. add('{');
  657. add(' /* Read-only sections, merged into text segment: */');
  658. add(' PROVIDE (__executable_start = 0x8000); . = 0x8000 + SIZEOF_HEADERS;');
  659. add(' .interp : { *(.interp) }');
  660. add(' .note.gnu.build-id : { *(.note.gnu.build-id) }');
  661. add(' .hash : { *(.hash) }');
  662. add(' .gnu.hash : { *(.gnu.hash) }');
  663. add(' .dynsym : { *(.dynsym) }');
  664. add(' .dynstr : { *(.dynstr) }');
  665. add(' .gnu.version : { *(.gnu.version) }');
  666. add(' .gnu.version_d : { *(.gnu.version_d) }');
  667. add(' .gnu.version_r : { *(.gnu.version_r) }');
  668. add(' .rel.dyn :');
  669. add(' {');
  670. add(' *(.rel.init)');
  671. add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
  672. add(' *(.rel.fini)');
  673. add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
  674. add(' *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)');
  675. add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
  676. add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
  677. add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
  678. add(' *(.rel.ctors)');
  679. add(' *(.rel.dtors)');
  680. add(' *(.rel.got)');
  681. add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
  682. add(' }');
  683. add(' .rela.dyn :');
  684. add(' {');
  685. add(' *(.rela.init)');
  686. add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
  687. add(' *(.rela.fini)');
  688. add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
  689. add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
  690. add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
  691. add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
  692. add(' *(.rela.ctors)');
  693. add(' *(.rela.dtors)');
  694. add(' *(.rela.got)');
  695. add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
  696. add(' }');
  697. add(' .rel.plt : { *(.rel.plt) }');
  698. add(' .rela.plt : { *(.rela.plt) }');
  699. add(' .init :');
  700. add(' {');
  701. add(' KEEP (*(.init))');
  702. add(' } =0');
  703. add(' .plt : { *(.plt) }');
  704. add(' .text :');
  705. add(' {');
  706. add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
  707. add(' KEEP (*(.text.*personality*))');
  708. add(' /* .gnu.warning sections are handled specially by elf32.em. */');
  709. add(' *(.gnu.warning)');
  710. add(' *(.glue_7t) *(.glue_7) *(.vfp11_veneer)');
  711. add(' } =0');
  712. add(' .fini :');
  713. add(' {');
  714. add(' KEEP (*(.fini))');
  715. add(' } =0');
  716. add(' PROVIDE (__etext = .);');
  717. add(' PROVIDE (_etext = .);');
  718. add(' PROVIDE (etext = .);');
  719. add(' .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }');
  720. add(' .rodata1 : { *(.rodata1) }');
  721. add(' .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) }');
  722. add(' __exidx_start = .;');
  723. add(' .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }');
  724. add(' __exidx_end = .;');
  725. add(' .eh_frame_hdr : { *(.eh_frame_hdr) }');
  726. add(' .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }');
  727. add(' .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }');
  728. add(' /* Adjust the address for the data segment. We want to adjust up to');
  729. add(' the same address within the page on the next page up. */');
  730. add(' . = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1));');
  731. add(' /* Exception handling */');
  732. add(' .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }');
  733. add(' .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }');
  734. add(' /* Thread Local Storage sections */');
  735. add(' .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }');
  736. add(' .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }');
  737. add(' .preinit_array :');
  738. add(' {');
  739. add(' PROVIDE_HIDDEN (__preinit_array_start = .);');
  740. add(' KEEP (*(.preinit_array))');
  741. add(' PROVIDE_HIDDEN (__preinit_array_end = .);');
  742. add(' }');
  743. add(' .init_array :');
  744. add(' {');
  745. add(' PROVIDE_HIDDEN (__init_array_start = .);');
  746. add(' KEEP (*(SORT(.init_array.*)))');
  747. add(' KEEP (*(.init_array))');
  748. add(' PROVIDE_HIDDEN (__init_array_end = .);');
  749. add(' }');
  750. add(' .fini_array :');
  751. add(' {');
  752. add(' PROVIDE_HIDDEN (__fini_array_start = .);');
  753. add(' KEEP (*(.fini_array))');
  754. add(' KEEP (*(SORT(.fini_array.*)))');
  755. add(' PROVIDE_HIDDEN (__fini_array_end = .);');
  756. add(' }');
  757. add(' .ctors :');
  758. add(' {');
  759. add(' /* gcc uses crtbegin.o to find the start of');
  760. add(' the constructors, so we make sure it is');
  761. add(' first. Because this is a wildcard, it');
  762. add(' doesn''t matter if the user does not');
  763. add(' actually link against crtbegin.o; the');
  764. add(' linker won''t look for a file to match a');
  765. add(' wildcard. The wildcard also means that it');
  766. add(' doesn''t matter which directory crtbegin.o');
  767. add(' is in. */');
  768. add(' KEEP (*crtbegin.o(.ctors))');
  769. add(' KEEP (*crtbegin?.o(.ctors))');
  770. add(' /* We don''t want to include the .ctor section from');
  771. add(' the crtend.o file until after the sorted ctors.');
  772. add(' The .ctor section from the crtend file contains the');
  773. add(' end of ctors marker and it must be last */');
  774. add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))');
  775. add(' KEEP (*(SORT(.ctors.*)))');
  776. add(' KEEP (*(.ctors))');
  777. add(' }');
  778. add(' .dtors :');
  779. add(' {');
  780. add(' KEEP (*crtbegin.o(.dtors))');
  781. add(' KEEP (*crtbegin?.o(.dtors))');
  782. add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))');
  783. add(' KEEP (*(SORT(.dtors.*)))');
  784. add(' KEEP (*(.dtors))');
  785. add(' }');
  786. add(' .jcr : { KEEP (*(.jcr)) }');
  787. add(' .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }');
  788. add(' .dynamic : { *(.dynamic) }');
  789. add(' .got : { *(.got.plt) *(.got) }');
  790. add(' .data :');
  791. add(' {');
  792. add(' __data_start = . ;');
  793. add(' *(.data .data.* .gnu.linkonce.d.*)');
  794. { extra by FPC }
  795. add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  796. add(' KEEP (*(.gnu.linkonce.d.*personality*))');
  797. add(' SORT(CONSTRUCTORS)');
  798. add(' }');
  799. add(' .data1 : { *(.data1) }');
  800. add(' _edata = .; PROVIDE (edata = .);');
  801. add(' __bss_start = .;');
  802. add(' __bss_start__ = .;');
  803. add(' .bss :');
  804. add(' {');
  805. add(' *(.dynbss)');
  806. add(' *(.bss .bss.* .gnu.linkonce.b.*)');
  807. add(' *(COMMON)');
  808. add(' /* Align here to ensure that the .bss section occupies space up to');
  809. add(' _end. Align after .bss to ensure correct alignment even if the');
  810. add(' .bss section disappears because there are no input sections.');
  811. add(' FIXME: Why do we need it? When there is no .bss section, we don''t');
  812. add(' pad the .data section. */');
  813. add(' . = ALIGN(. != 0 ? 32 / 8 : 1);');
  814. add(' }');
  815. add(' _bss_end__ = . ; __bss_end__ = . ;');
  816. add(' . = ALIGN(32 / 8);');
  817. add(' . = ALIGN(32 / 8);');
  818. add(' __end__ = . ;');
  819. add(' _end = .; PROVIDE (end = .);');
  820. add(' /* Stabs debugging sections. */');
  821. add(' .stab 0 : { *(.stab) }');
  822. add(' .stabstr 0 : { *(.stabstr) }');
  823. add(' .stab.excl 0 : { *(.stab.excl) }');
  824. add(' .stab.exclstr 0 : { *(.stab.exclstr) }');
  825. add(' .stab.index 0 : { *(.stab.index) }');
  826. add(' .stab.indexstr 0 : { *(.stab.indexstr) }');
  827. add(' .comment 0 : { *(.comment) }');
  828. add(' /* DWARF debug sections.');
  829. add(' Symbols in the DWARF debugging sections are relative to the beginning');
  830. add(' of the section so we begin them at 0. */');
  831. add(' /* DWARF 1 */');
  832. add(' .debug 0 : { *(.debug) }');
  833. add(' .line 0 : { *(.line) }');
  834. add(' /* GNU DWARF 1 extensions */');
  835. add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
  836. add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
  837. add(' /* DWARF 1.1 and DWARF 2 */');
  838. add(' .debug_aranges 0 : { *(.debug_aranges) }');
  839. add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
  840. add(' /* DWARF 2 */');
  841. add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
  842. add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
  843. add(' .debug_line 0 : { *(.debug_line) }');
  844. add(' .debug_frame 0 : { *(.debug_frame) }');
  845. add(' .debug_str 0 : { *(.debug_str) }');
  846. add(' .debug_loc 0 : { *(.debug_loc) }');
  847. add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
  848. add(' /* SGI/MIPS DWARF 2 extensions */');
  849. add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
  850. add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
  851. add(' .debug_typenames 0 : { *(.debug_typenames) }');
  852. add(' .debug_varnames 0 : { *(.debug_varnames) }');
  853. add(' /* DWARF 3 */');
  854. add(' .debug_pubtypes 0 : { *(.debug_pubtypes) }');
  855. add(' .debug_ranges 0 : { *(.debug_ranges) }');
  856. add(' .stack 0x80000 :');
  857. add(' {');
  858. add(' _stack = .;');
  859. add(' *(.stack)');
  860. add(' }');
  861. add(' .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }');
  862. add(' .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }');
  863. add(' /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }');
  864. add('}');
  865. end
  866. else
  867. {$endif ARM}
  868. {$ifndef LINKERSCRIPT_INCLUDED}
  869. begin
  870. {Sections.}
  871. add('SECTIONS');
  872. add('{');
  873. {Read-only sections, merged into text segment:}
  874. add(' PROVIDE (__executable_start = 0x010000); . = 0x010000 + SIZEOF_HEADERS;');
  875. add(' .interp : { *(.interp) }');
  876. add(' .hash : { *(.hash) }');
  877. add(' .dynsym : { *(.dynsym) }');
  878. add(' .dynstr : { *(.dynstr) }');
  879. add(' .gnu.version : { *(.gnu.version) }');
  880. add(' .gnu.version_d : { *(.gnu.version_d) }');
  881. add(' .gnu.version_r : { *(.gnu.version_r) }');
  882. add(' .rel.dyn :');
  883. add(' {');
  884. add(' *(.rel.init)');
  885. add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
  886. add(' *(.rel.fini)');
  887. add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
  888. add(' *(.rel.data.rel.ro*)');
  889. add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
  890. add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
  891. add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
  892. add(' *(.rel.got)');
  893. add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
  894. add(' }');
  895. add(' .rela.dyn :');
  896. add(' {');
  897. add(' *(.rela.init)');
  898. add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
  899. add(' *(.rela.fini)');
  900. add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
  901. add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
  902. add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
  903. add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
  904. add(' *(.rela.got)');
  905. add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
  906. add(' }');
  907. add(' .rel.plt : { *(.rel.plt) }');
  908. add(' .rela.plt : { *(.rela.plt) }');
  909. add(' .init :');
  910. add(' {');
  911. add(' KEEP (*(.init))');
  912. add(' } =0x90909090');
  913. add(' .plt : { *(.plt) }');
  914. add(' .text :');
  915. add(' {');
  916. add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
  917. add(' KEEP (*(.text.*personality*))');
  918. {.gnu.warning sections are handled specially by elf32.em.}
  919. add(' *(.gnu.warning)');
  920. add(' } =0x90909090');
  921. add(' .fini :');
  922. add(' {');
  923. add(' KEEP (*(.fini))');
  924. add(' } =0x90909090');
  925. add(' PROVIDE (_etext = .);');
  926. add(' .rodata :');
  927. add(' {');
  928. add(' *(.rodata .rodata.* .gnu.linkonce.r.*)');
  929. add(' }');
  930. {Adjust the address for the data segment. We want to adjust up to
  931. the same address within the page on the next page up.}
  932. add(' . = ALIGN (0x1000) - ((0x1000 - .) & (0x1000 - 1));');
  933. add(' .dynamic : { *(.dynamic) }');
  934. add(' .got : { *(.got) }');
  935. add(' .got.plt : { *(.got.plt) }');
  936. add(' .data :');
  937. add(' {');
  938. add(' *(.data .data.* .gnu.linkonce.d.*)');
  939. add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  940. add(' KEEP (*(.gnu.linkonce.d.*personality*))');
  941. add(' }');
  942. add(' PROVIDE (_edata = .);');
  943. add(' PROVIDE (edata = .);');
  944. {$ifdef zsegment_threadvars}
  945. add(' _z = .;');
  946. add(' .threadvar 0 : AT (_z) { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
  947. add(' PROVIDE (_threadvar_size = SIZEOF(.threadvar));');
  948. add(' . = _z + SIZEOF (.threadvar);');
  949. {$else}
  950. add(' .threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
  951. {$endif}
  952. add(' __bss_start = .;');
  953. add(' .bss :');
  954. add(' {');
  955. add(' *(.dynbss)');
  956. add(' *(.bss .bss.* .gnu.linkonce.b.*)');
  957. add(' *(COMMON)');
  958. {Align here to ensure that the .bss section occupies space up to
  959. _end. Align after .bss to ensure correct alignment even if the
  960. .bss section disappears because there are no input sections.}
  961. add(' . = ALIGN(32 / 8);');
  962. add(' }');
  963. add(' . = ALIGN(32 / 8);');
  964. add(' PROVIDE (_end = .);');
  965. add(' PROVIDE (end = .);');
  966. {Stabs debugging sections.}
  967. add(' .stab 0 : { *(.stab) }');
  968. add(' .stabstr 0 : { *(.stabstr) }');
  969. add('}');
  970. end;
  971. {$endif LINKERSCRIPT_INCLUDED}
  972. { Write and Close response }
  973. writetodisk;
  974. Free;
  975. end;
  976. WriteResponseFile:=True;
  977. end;
  978. function TLinkerLinux.MakeExecutable:boolean;
  979. var
  980. i : longint;
  981. binstr,
  982. cmdstr : TCmdStr;
  983. success : boolean;
  984. DynLinkStr : string;
  985. GCSectionsStr,
  986. StaticStr,
  987. StripStr : string[40];
  988. begin
  989. if not(cs_link_nolink in current_settings.globalswitches) then
  990. Message1(exec_i_linking,current_module.exefilename);
  991. { Create some replacements }
  992. StaticStr:='';
  993. StripStr:='';
  994. GCSectionsStr:='';
  995. DynLinkStr:='';
  996. if (cs_link_staticflag in current_settings.globalswitches) then
  997. StaticStr:='-static';
  998. if (cs_link_strip in current_settings.globalswitches) and
  999. not(cs_link_separate_dbg_file in current_settings.globalswitches) then
  1000. StripStr:='-s';
  1001. if (cs_link_map in current_settings.globalswitches) then
  1002. StripStr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
  1003. if (cs_link_smart in current_settings.globalswitches) and
  1004. create_smartlink_sections then
  1005. GCSectionsStr:='--gc-sections';
  1006. If (cs_profile in current_settings.moduleswitches) or
  1007. ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then
  1008. begin
  1009. DynLinkStr:='--dynamic-linker='+Info.DynamicLinker;
  1010. if cshared then
  1011. DynLinkStr:=DynLinkStr+' --shared ';
  1012. if rlinkpath<>'' then
  1013. DynLinkStr:=DynLinkStr+' --rpath-link '+rlinkpath;
  1014. End;
  1015. { Write used files and libraries }
  1016. WriteResponseFile(false);
  1017. { Call linker }
  1018. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  1019. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  1020. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  1021. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  1022. Replace(cmdstr,'$STATIC',StaticStr);
  1023. Replace(cmdstr,'$STRIP',StripStr);
  1024. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  1025. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  1026. { create dynamic symbol table? }
  1027. if HasExports then
  1028. cmdstr:=cmdstr+' -E';
  1029. success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
  1030. { Create external .dbg file with debuginfo }
  1031. if success and (cs_link_separate_dbg_file in current_settings.globalswitches) then
  1032. begin
  1033. for i:=1 to 3 do
  1034. begin
  1035. SplitBinCmd(Info.ExtDbgCmd[i],binstr,cmdstr);
  1036. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
  1037. Replace(cmdstr,'$DBGFN',maybequoted(extractfilename(current_module.dbgfilename)));
  1038. Replace(cmdstr,'$DBG',maybequoted(current_module.dbgfilename));
  1039. success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
  1040. if not success then
  1041. break;
  1042. end;
  1043. end;
  1044. { Remove ReponseFile }
  1045. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  1046. DeleteFile(outputexedir+Info.ResName);
  1047. MakeExecutable:=success; { otherwise a recursive call to link method }
  1048. end;
  1049. Function TLinkerLinux.MakeSharedLibrary:boolean;
  1050. var
  1051. InitStr,
  1052. FiniStr,
  1053. SoNameStr : string[80];
  1054. binstr,
  1055. cmdstr : TCmdStr;
  1056. success : boolean;
  1057. begin
  1058. MakeSharedLibrary:=false;
  1059. if not(cs_link_nolink in current_settings.globalswitches) then
  1060. Message1(exec_i_linking,current_module.sharedlibfilename);
  1061. { Write used files and libraries }
  1062. WriteResponseFile(true);
  1063. { Create some replacements }
  1064. { note: linux does not use exportlib.initname/fininame due to the custom startup code }
  1065. InitStr:='-init FPC_SHARED_LIB_START';
  1066. FiniStr:='-fini FPC_LIB_EXIT';
  1067. SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
  1068. { Call linker }
  1069. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  1070. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  1071. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  1072. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  1073. Replace(cmdstr,'$INIT',InitStr);
  1074. Replace(cmdstr,'$FINI',FiniStr);
  1075. Replace(cmdstr,'$SONAME',SoNameStr);
  1076. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
  1077. { Strip the library ? }
  1078. if success and (cs_link_strip in current_settings.globalswitches) then
  1079. begin
  1080. { only remove non global symbols and debugging info for a library }
  1081. Info.DllCmd[2]:='strip --discard-all --strip-debug $EXE';
  1082. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  1083. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename));
  1084. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
  1085. end;
  1086. { Remove ReponseFile }
  1087. if (success) and not(cs_link_nolink in current_settings.globalswitches) then
  1088. DeleteFile(outputexedir+Info.ResName);
  1089. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  1090. end;
  1091. {*****************************************************************************
  1092. TINTERNALLINKERLINUX
  1093. *****************************************************************************}
  1094. constructor TInternalLinkerLinux.Create;
  1095. begin
  1096. inherited Create;
  1097. SetupLibrarySearchPath;
  1098. SetupDynlinker(dynlinker,libctype);
  1099. CExeOutput:=ElfExeOutputClass;
  1100. CObjInput:=TElfObjInput;
  1101. end;
  1102. procedure TInternalLinkerLinux.InitSysInitUnitName;
  1103. begin
  1104. linklibc:=ModulesLinkToLibc;
  1105. reorder:=linklibc and ReOrderEntries;
  1106. sysinitunit:=defsinames[current_module.islibrary];
  1107. prtobj:=defprtnames[current_module.islibrary];
  1108. if cs_profile in current_settings.moduleswitches then
  1109. begin
  1110. prtobj:=gprtnames[libctype];
  1111. sysinitunit:=gsinames[libctype];
  1112. linklibc:=true;
  1113. end
  1114. else if linklibc then
  1115. begin
  1116. prtobj:=cprtnames[libctype];
  1117. sysinitunit:=csinames[libctype];
  1118. end;
  1119. end;
  1120. const
  1121. relsec_prefix:array[boolean] of TCmdStr = ('rel','rela');
  1122. procedure TInternalLinkerLinux.DefaultLinkScript;
  1123. var
  1124. s,s1,s2,relprefix:TCmdStr;
  1125. found1,found2:boolean;
  1126. linkToSharedLibs:boolean;
  1127. procedure AddLibraryStatement(const s:TCmdStr);
  1128. var
  1129. i:longint;
  1130. s1,s2:TCmdStr;
  1131. begin
  1132. i:=pos(target_info.sharedClibext+'.',s);
  1133. if (i>0) then
  1134. s1:=target_info.sharedClibprefix+S
  1135. else
  1136. s1:=target_info.sharedClibprefix+S+target_info.sharedClibext;
  1137. { TODO: to be compatible with ld search algorithm, each found file
  1138. must be tested for target compatibility, incompatible ones should be skipped. }
  1139. { TODO: shall we search library without suffix if one with suffix is not found? }
  1140. if (not(cs_link_staticflag in current_settings.globalswitches)) and
  1141. FindLibraryFile(s1,'','',s2) then
  1142. LinkScript.Concat('READSTATICLIBRARY '+maybequoted(s2))
  1143. { TODO: static libraries never have numeric suffix in their names }
  1144. else if FindLibraryFile(s,target_info.staticClibprefix,target_info.staticClibext,s2) then
  1145. LinkScript.Concat('READSTATICLIBRARY '+maybequoted(s2))
  1146. else
  1147. Comment(V_Error,'Import library not found for '+S);
  1148. end;
  1149. begin
  1150. if cs_profile in current_settings.moduleswitches then
  1151. begin
  1152. if not(libctype in [glibc2,glibc21]) then
  1153. AddSharedLibrary('gmon');
  1154. AddSharedLibrary('c');
  1155. end;
  1156. TElfExeOutput(exeoutput).interpreter:=stringdup(dynlinker);
  1157. { add objectfiles, start with prt0 always }
  1158. if not (target_info.system in systems_internal_sysinit) and (prtobj<>'') then
  1159. LinkScript.Concat('READOBJECT '+ maybequoted(FindObjectFile(prtobj,'',false)));
  1160. { try to add crti and crtbegin if linking to C }
  1161. if linklibc and (libctype<>uclibc) then
  1162. begin
  1163. { crti.o must come first }
  1164. if librarysearchpath.FindFile('crti.o',false,s) then
  1165. LinkScript.Concat('READOBJECT '+maybequoted(s));
  1166. { then the crtbegin* }
  1167. if cs_create_pic in current_settings.moduleswitches then
  1168. begin
  1169. if librarysearchpath.FindFile('crtbeginS.o',false,s) then
  1170. LinkScript.Concat('READOBJECT '+maybequoted(s));
  1171. end
  1172. else
  1173. if (cs_link_staticflag in current_settings.globalswitches) and
  1174. librarysearchpath.FindFile('crtbeginT.o',false,s) then
  1175. LinkScript.Concat('READOBJECT '+maybequoted(s))
  1176. else if librarysearchpath.FindFile('crtbegin.o',false,s) then
  1177. LinkScript.Concat('READOBJECT '+maybequoted(s));
  1178. end;
  1179. ScriptAddSourceStatements(false);
  1180. { we must reorder here because the result could empty sharedlibfiles }
  1181. if reorder then
  1182. ExpandAndApplyOrder(SharedLibFiles);
  1183. { See tw9089*.pp: if more than one pure-Pascal shared libs are loaded,
  1184. and none have rtld in their DT_NEEDED, then rtld cannot finalize correctly. }
  1185. if IsSharedLibrary then
  1186. LinkScript.Concat('READSTATICLIBRARY '+maybequoted(sysrootpath+dynlinker));
  1187. linkToSharedLibs:=(not SharedLibFiles.Empty);
  1188. { Symbols declared as "external 'libx.so'" are added to ImportLibraryList, library
  1189. prefix/extension *not* stripped. TImportLibLinux copies these to SharedLibFiles,
  1190. stripping prefixes and extensions.
  1191. However extension won't be stripped if library is specified with numeric suffix
  1192. (like "libpango-1.0.so.0")
  1193. Libraries specified with $LINKLIB directive are directly added to SharedLibFiles
  1194. and won't be present in ImportLibraryList. }
  1195. while not SharedLibFiles.Empty do
  1196. begin
  1197. S:=SharedLibFiles.GetFirst;
  1198. if (S<>'c') or reorder then
  1199. AddLibraryStatement(S);
  1200. end;
  1201. if (cs_link_staticflag in current_settings.globalswitches) or
  1202. (linklibc and not reorder) then
  1203. begin
  1204. LinkScript.Concat('GROUP');
  1205. if (cs_link_staticflag in current_settings.globalswitches) then
  1206. begin
  1207. AddLibraryStatement('gcc');
  1208. AddLibraryStatement('gcc_eh');
  1209. end;
  1210. if linklibc and not reorder then
  1211. AddLibraryStatement('c');
  1212. LinkScript.Concat('ENDGROUP');
  1213. end;
  1214. { objects which must be at the end }
  1215. if linklibc and (libctype<>uclibc) then
  1216. begin
  1217. if cs_create_pic in current_settings.moduleswitches then
  1218. found1:=librarysearchpath.FindFile('crtendS.o',false,s1)
  1219. else
  1220. found1:=librarysearchpath.FindFile('crtend.o',false,s1);
  1221. found2:=librarysearchpath.FindFile('crtn.o',false,s2);
  1222. if found1 then
  1223. LinkScript.Concat('READOBJECT '+maybequoted(s1));
  1224. if found2 then
  1225. LinkScript.Concat('READOBJECT '+maybequoted(s2));
  1226. end;
  1227. if (not IsSharedLibrary) then
  1228. if (linkToSharedLibs and not linklibc) then
  1229. LinkScript.Concat('ENTRYNAME _dynamic_start')
  1230. else
  1231. LinkScript.Concat('ENTRYNAME _start')
  1232. else
  1233. LinkScript.Concat('ISSHAREDLIBRARY');
  1234. relprefix:=relsec_prefix[ElfTarget.relocs_use_addend];
  1235. with LinkScript do
  1236. begin
  1237. Concat('HEADER');
  1238. Concat('EXESECTION .interp');
  1239. Concat(' OBJSECTION .interp');
  1240. Concat('ENDEXESECTION');
  1241. Concat('EXESECTION .note.ABI-tag');
  1242. Concat(' OBJSECTION .note.ABI-tag');
  1243. Concat('ENDEXESECTION');
  1244. Concat('EXESECTION .note.gnu.build-id');
  1245. Concat(' OBJSECTION .note.gnu.build-id');
  1246. Concat('ENDEXESECTION');
  1247. Concat('EXESECTION .hash');
  1248. Concat(' OBJSECTION .hash');
  1249. Concat('ENDEXESECTION');
  1250. Concat('EXESECTION .dynsym');
  1251. Concat(' OBJSECTION .dynsym');
  1252. Concat('ENDEXESECTION');
  1253. Concat('EXESECTION .dynstr');
  1254. Concat(' OBJSECTION .dynstr');
  1255. Concat('ENDEXESECTION');
  1256. Concat('EXESECTION .gnu.version');
  1257. Concat(' OBJSECTION .gnu.version');
  1258. Concat('ENDEXESECTION');
  1259. Concat('EXESECTION .gnu.version_d');
  1260. Concat(' OBJSECTION .gnu.version_d');
  1261. Concat('ENDEXESECTION');
  1262. Concat('EXESECTION .gnu.version_r');
  1263. Concat(' OBJSECTION .gnu.version_r');
  1264. Concat('ENDEXESECTION');
  1265. Concat('EXESECTION .'+relprefix+'.dyn');
  1266. Concat(' OBJSECTION .'+relprefix+'.dyn');
  1267. Concat('ENDEXESECTION');
  1268. Concat('EXESECTION .'+relprefix+'.plt');
  1269. Concat(' OBJSECTION .'+relprefix+'.plt');
  1270. Concat(' PROVIDE __'+relprefix+'_iplt_start');
  1271. Concat(' OBJSECTION .'+relprefix+'.iplt');
  1272. Concat(' PROVIDE __'+relprefix+'_iplt_end');
  1273. Concat('ENDEXESECTION');
  1274. Concat('EXESECTION .init');
  1275. Concat(' OBJSECTION .init');
  1276. Concat('ENDEXESECTION');
  1277. Concat('EXESECTION .plt');
  1278. Concat(' OBJSECTION .plt');
  1279. Concat('ENDEXESECTION');
  1280. Concat('EXESECTION .text');
  1281. Concat(' OBJSECTION .text*');
  1282. Concat('ENDEXESECTION');
  1283. Concat('EXESECTION .fini');
  1284. Concat(' OBJSECTION .fini');
  1285. Concat(' PROVIDE __etext');
  1286. Concat(' PROVIDE _etext');
  1287. Concat(' PROVIDE etext');
  1288. Concat('ENDEXESECTION');
  1289. Concat('EXESECTION .rodata');
  1290. Concat(' OBJSECTION .rodata*');
  1291. Concat('ENDEXESECTION');
  1292. {$ifdef arm}
  1293. Concat('EXESECTION .ARM.extab');
  1294. Concat(' OBJSECTION .ARM.extab*');
  1295. Concat('ENDEXESECTION');
  1296. Concat('EXESECTION .ARM.exidx');
  1297. Concat(' SYMBOL __exidx_start');
  1298. Concat(' OBJSECTION .ARM.exidx*');
  1299. Concat(' SYMBOL __exidx_end');
  1300. Concat('ENDEXESECTION');
  1301. {$endif}
  1302. Concat('EXESECTION .eh_frame');
  1303. Concat(' OBJSECTION .eh_frame');
  1304. Concat('ENDEXESECTION');
  1305. Concat('EXESECTION .gcc_except_table');
  1306. Concat(' OBJSECTION .gcc_except_table');
  1307. Concat(' OBJSECTION .gcc_except_table.*');
  1308. Concat('ENDEXESECTION');
  1309. Concat('EXESECTION .tdata');
  1310. Concat(' OBJSECTION .tdata');
  1311. Concat(' OBJSECTION .tdata.*');
  1312. Concat('ENDEXESECTION');
  1313. Concat('EXESECTION .tbss');
  1314. Concat(' OBJSECTION .tbss');
  1315. Concat(' OBJSECTION .tbss.*');
  1316. Concat('ENDEXESECTION');
  1317. Concat('EXESECTION .preinit_array');
  1318. Concat(' PROVIDE __preinit_array_start');
  1319. Concat(' OBJSECTION .preinit_array');
  1320. Concat(' PROVIDE __preinit_array_end');
  1321. Concat('ENDEXESECTION');
  1322. Concat('EXESECTION .init_array');
  1323. Concat(' PROVIDE __init_array_start');
  1324. { why the hell .ctors are both here and exesection .ctors below?? }
  1325. // KEEP ( *(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  1326. Concat(' OBJSECTION .init_array');
  1327. // KEEP ( *(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  1328. Concat('PROVIDE __init_array_end');
  1329. Concat('ENDEXESECTION');
  1330. Concat('EXESECTION .fini_array');
  1331. Concat(' PROVIDE __fini_array_start');
  1332. // KEEP ( *(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  1333. Concat(' OBJSECTION .fini_array');
  1334. // KEEP ( *(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  1335. Concat(' PROVIDE __fini_array_end');
  1336. Concat('ENDEXESECTION');
  1337. Concat('EXESECTION .ctors');
  1338. Concat(' OBJSECTION .ctors*');
  1339. Concat('ENDEXESECTION');
  1340. Concat('EXESECTION .dtors');
  1341. Concat(' OBJSECTION .dtors*');
  1342. Concat('ENDEXESECTION');
  1343. Concat('EXESECTION .jcr');
  1344. Concat(' OBJSECTION .jcr');
  1345. Concat('ENDEXESECTION');
  1346. Concat('EXESECTION .dynamic');
  1347. Concat(' OBJSECTION .dynamic');
  1348. Concat('ENDEXESECTION');
  1349. {$ifndef mips}
  1350. Concat('EXESECTION .got');
  1351. {$ifdef arm}
  1352. Concat(' OBJSECTION .got.plt');
  1353. {$endif arm}
  1354. Concat(' OBJSECTION .got');
  1355. Concat('ENDEXESECTION');
  1356. {$endif mips}
  1357. {$ifndef arm}
  1358. Concat('EXESECTION .got.plt');
  1359. Concat(' OBJSECTION .got.plt');
  1360. Concat('ENDEXESECTION');
  1361. {$endif arm}
  1362. Concat('EXESECTION .data');
  1363. Concat(' OBJSECTION .data*');
  1364. Concat(' OBJSECTION .fpc*');
  1365. Concat(' OBJSECTION fpc.resources');
  1366. Concat(' PROVIDE _edata');
  1367. Concat(' PROVIDE edata');
  1368. Concat('ENDEXESECTION');
  1369. {$ifdef mips}
  1370. Concat('EXESECTION .got');
  1371. Concat(' OBJSECTION .got');
  1372. Concat('ENDEXESECTION');
  1373. {$endif mips}
  1374. Concat('EXESECTION .bss');
  1375. Concat(' OBJSECTION .dynbss');
  1376. Concat(' OBJSECTION .bss*');
  1377. Concat(' OBJSECTION fpc.reshandles');
  1378. Concat(' PROVIDE end');
  1379. Concat(' SYMBOL _end');
  1380. Concat('ENDEXESECTION');
  1381. ScriptAddGenericSections('.debug_aranges,.debug_pubnames,.debug_info,'+
  1382. '.debug_abbrev,.debug_line,.debug_frame,.debug_str,.debug_loc,'+
  1383. '.debug_macinfo,.debug_weaknames,.debug_funcnames,.debug_typenames,.debug_varnames,.debug_ranges');
  1384. Concat('EXESECTION .stab');
  1385. Concat(' OBJSECTION .stab');
  1386. Concat('ENDEXESECTION');
  1387. Concat('EXESECTION .stabstr');
  1388. Concat(' OBJSECTION .stabstr');
  1389. Concat('ENDEXESECTION');
  1390. end;
  1391. end;
  1392. {*****************************************************************************
  1393. Initialize
  1394. *****************************************************************************}
  1395. initialization
  1396. RegisterLinker(ld_linux,TLinkerLinux);
  1397. RegisterLinker(ld_int_linux,TInternalLinkerLinux);
  1398. {$ifdef i386}
  1399. RegisterImport(system_i386_linux,timportliblinux);
  1400. RegisterExport(system_i386_linux,texportliblinux);
  1401. RegisterTarget(system_i386_linux_info);
  1402. {$endif i386}
  1403. {$ifdef m68k}
  1404. RegisterImport(system_m68k_linux,timportliblinux);
  1405. RegisterExport(system_m68k_linux,texportliblinux);
  1406. RegisterTarget(system_m68k_linux_info);
  1407. {$endif m68k}
  1408. {$ifdef powerpc}
  1409. RegisterImport(system_powerpc_linux,timportliblinux);
  1410. RegisterExport(system_powerpc_linux,texportliblinux);
  1411. RegisterTarget(system_powerpc_linux_info);
  1412. {$endif powerpc}
  1413. {$ifdef powerpc64}
  1414. RegisterImport(system_powerpc64_linux,timportliblinux);
  1415. RegisterExport(system_powerpc64_linux,texportliblinux);
  1416. RegisterTarget(system_powerpc64_linux_info);
  1417. {$endif powerpc64}
  1418. {$ifdef alpha}
  1419. RegisterImport(system_alpha_linux,timportliblinux);
  1420. RegisterExport(system_alpha_linux,texportliblinux);
  1421. RegisterTarget(system_alpha_linux_info);
  1422. {$endif alpha}
  1423. {$ifdef x86_64}
  1424. RegisterImport(system_x86_64_linux,timportliblinux);
  1425. RegisterExport(system_x86_64_linux,texportliblinux);
  1426. RegisterTarget(system_x86_64_linux_info);
  1427. {$endif x86_64}
  1428. {$ifdef SPARC}
  1429. RegisterImport(system_SPARC_linux,timportliblinux);
  1430. RegisterExport(system_SPARC_linux,texportliblinux);
  1431. RegisterTarget(system_SPARC_linux_info);
  1432. {$endif SPARC}
  1433. {$ifdef ARM}
  1434. RegisterImport(system_arm_linux,timportliblinux);
  1435. RegisterExport(system_arm_linux,texportliblinux);
  1436. RegisterTarget(system_arm_linux_info);
  1437. {$endif ARM}
  1438. {$ifdef MIPS}
  1439. {$ifdef MIPSEL}
  1440. RegisterImport(system_mipsel_linux,timportliblinux);
  1441. RegisterExport(system_mipsel_linux,texportliblinux);
  1442. RegisterTarget(system_mipsel_linux_info);
  1443. {$else MIPS}
  1444. RegisterImport(system_mipseb_linux,timportliblinux);
  1445. RegisterExport(system_mipseb_linux,texportliblinux);
  1446. RegisterTarget(system_mipseb_linux_info);
  1447. {$endif MIPSEL}
  1448. {$endif MIPS}
  1449. RegisterRes(res_elf_info,TWinLikeResourceFile);
  1450. end.