t_linux.pas 59 KB

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