t_linux.pas 57 KB

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