t_linux.pas 57 KB

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