t_linux.pas 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Peter Vreman
  4. This unit implements support import,export,link routines
  5. for the (i386) Linux target
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit t_linux;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. import,export,link;
  24. type
  25. timportliblinux=class(timportlib)
  26. procedure preparelib(const s:string);override;
  27. procedure importprocedure(const func,module:string;index:longint;const name:string);override;
  28. procedure importvariable(const varname,module:string;const name:string);override;
  29. procedure generatelib;override;
  30. end;
  31. texportliblinux=class(texportlib)
  32. procedure preparelib(const s : string);override;
  33. procedure exportprocedure(hp : texported_item);override;
  34. procedure exportvar(hp : texported_item);override;
  35. procedure generatelib;override;
  36. end;
  37. tlinkerlinux=class(texternallinker)
  38. private
  39. Glibc2,
  40. Glibc21 : boolean;
  41. Function WriteResponseFile(isdll:boolean) : Boolean;
  42. public
  43. constructor Create;override;
  44. procedure SetDefaultInfo;override;
  45. function MakeExecutable:boolean;override;
  46. function MakeSharedLibrary:boolean;override;
  47. end;
  48. implementation
  49. uses
  50. cutils,cclasses,
  51. verbose,systems,globtype,globals,
  52. symconst,script,
  53. fmodule,symsym
  54. {$ifdef i386}
  55. ,aasmbase,aasmtai,aasmcpu,cpubase
  56. {$endif i386}
  57. ;
  58. {*****************************************************************************
  59. TIMPORTLIBLINUX
  60. *****************************************************************************}
  61. procedure timportliblinux.preparelib(const s : string);
  62. begin
  63. end;
  64. procedure timportliblinux.importprocedure(const func,module : string;index : longint;const name : string);
  65. begin
  66. { insert sharedlibrary }
  67. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  68. { do nothing with the procedure, only set the mangledname }
  69. if name<>'' then
  70. begin
  71. aktprocdef.setmangledname(name);
  72. aktprocdef.has_mangledname:=true;
  73. end
  74. else
  75. message(parser_e_empty_import_name);
  76. end;
  77. procedure timportliblinux.importvariable(const varname,module:string;const name:string);
  78. begin
  79. { insert sharedlibrary }
  80. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  81. { reset the mangledname and turn off the dll_var option }
  82. aktvarsym.set_mangledname(name);
  83. exclude(aktvarsym.varoptions,vo_is_dll_var);
  84. end;
  85. procedure timportliblinux.generatelib;
  86. begin
  87. end;
  88. {*****************************************************************************
  89. TEXPORTLIBLINUX
  90. *****************************************************************************}
  91. procedure texportliblinux.preparelib(const s:string);
  92. begin
  93. end;
  94. procedure texportliblinux.exportprocedure(hp : texported_item);
  95. var
  96. hp2 : texported_item;
  97. begin
  98. { first test the index value }
  99. if (hp.options and eo_index)<>0 then
  100. begin
  101. Message1(parser_e_no_export_with_index_for_target,'linux');
  102. exit;
  103. end;
  104. { now place in correct order }
  105. hp2:=texported_item(current_module._exports.first);
  106. while assigned(hp2) and
  107. (hp.name^>hp2.name^) do
  108. hp2:=texported_item(hp2.next);
  109. { insert hp there !! }
  110. if assigned(hp2) and (hp2.name^=hp.name^) then
  111. begin
  112. { this is not allowed !! }
  113. Message1(parser_e_export_name_double,hp.name^);
  114. exit;
  115. end;
  116. if hp2=texported_item(current_module._exports.first) then
  117. current_module._exports.concat(hp)
  118. else if assigned(hp2) then
  119. begin
  120. hp.next:=hp2;
  121. hp.previous:=hp2.previous;
  122. if assigned(hp2.previous) then
  123. hp2.previous.next:=hp;
  124. hp2.previous:=hp;
  125. end
  126. else
  127. current_module._exports.concat(hp);
  128. end;
  129. procedure texportliblinux.exportvar(hp : texported_item);
  130. begin
  131. hp.is_var:=true;
  132. exportprocedure(hp);
  133. end;
  134. procedure texportliblinux.generatelib;
  135. var
  136. hp2 : texported_item;
  137. begin
  138. hp2:=texported_item(current_module._exports.first);
  139. while assigned(hp2) do
  140. begin
  141. if (not hp2.is_var) and
  142. (hp2.sym.typ=procsym) then
  143. begin
  144. { the manglednames can already be the same when the procedure
  145. is declared with cdecl }
  146. if tprocsym(hp2.sym).defs^.def.mangledname<>hp2.name^ then
  147. begin
  148. {$ifdef i386}
  149. { place jump in codesegment }
  150. codesegment.concat(Tai_align.Create_op(4,$90));
  151. codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
  152. codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(tprocsym(hp2.sym).defs^.def.mangledname)));
  153. codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
  154. {$endif i386}
  155. end;
  156. end
  157. else
  158. Message1(parser_e_no_export_of_variables_for_target,'linux');
  159. hp2:=texported_item(hp2.next);
  160. end;
  161. end;
  162. {*****************************************************************************
  163. TLINKERLINUX
  164. *****************************************************************************}
  165. Constructor TLinkerLinux.Create;
  166. begin
  167. Inherited Create;
  168. LibrarySearchPath.AddPath('/lib;/usr/lib;/usr/X11R6/lib',true);
  169. end;
  170. procedure TLinkerLinux.SetDefaultInfo;
  171. {
  172. This will also detect which libc version will be used
  173. }
  174. begin
  175. Glibc2:=false;
  176. Glibc21:=false;
  177. with Info do
  178. begin
  179. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $STRIP -L. -o $EXE $RES';
  180. DllCmd[1]:='ld $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
  181. DllCmd[2]:='strip --strip-unneeded $EXE';
  182. { first try glibc2 }
  183. DynamicLinker:='/lib/ld-linux.so.2';
  184. if FileExists(DynamicLinker) then
  185. begin
  186. Glibc2:=true;
  187. { Check for 2.0 files, else use the glibc 2.1 stub }
  188. if FileExists('/lib/ld-2.0.*') then
  189. Glibc21:=false
  190. else
  191. Glibc21:=true;
  192. end
  193. else
  194. DynamicLinker:='/lib/ld-linux.so.1';
  195. end;
  196. end;
  197. Function TLinkerLinux.WriteResponseFile(isdll:boolean) : Boolean;
  198. Var
  199. linkres : TLinkRes;
  200. i : longint;
  201. cprtobj,
  202. gprtobj,
  203. prtobj : string[80];
  204. HPath : TStringListItem;
  205. s,s1,s2 : string;
  206. found1,
  207. found2,
  208. linkdynamic,
  209. linklibc : boolean;
  210. begin
  211. WriteResponseFile:=False;
  212. { set special options for some targets }
  213. linkdynamic:=not(SharedLibFiles.empty);
  214. linklibc:=(SharedLibFiles.Find('c')<>nil);
  215. if isdll then
  216. begin
  217. prtobj:='dllprt0';
  218. cprtobj:='dllprt0';
  219. gprtobj:='dllprt0';
  220. end
  221. else
  222. begin
  223. prtobj:='prt0';
  224. cprtobj:='cprt0';
  225. gprtobj:='gprt0';
  226. if glibc21 then
  227. begin
  228. cprtobj:='cprt21';
  229. gprtobj:='gprt21';
  230. end;
  231. end;
  232. if cs_profile in aktmoduleswitches then
  233. begin
  234. prtobj:=gprtobj;
  235. if not glibc2 then
  236. AddSharedLibrary('gmon');
  237. AddSharedLibrary('c');
  238. linklibc:=true;
  239. end
  240. else
  241. begin
  242. if linklibc then
  243. prtobj:=cprtobj;
  244. end;
  245. { Open link.res file }
  246. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
  247. { Write path to search libraries }
  248. HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
  249. while assigned(HPath) do
  250. begin
  251. LinkRes.Add('SEARCH_DIR('+HPath.Str+')');
  252. HPath:=TStringListItem(HPath.Next);
  253. end;
  254. HPath:=TStringListItem(LibrarySearchPath.First);
  255. while assigned(HPath) do
  256. begin
  257. LinkRes.Add('SEARCH_DIR('+HPath.Str+')');
  258. HPath:=TStringListItem(HPath.Next);
  259. end;
  260. LinkRes.Add('INPUT(');
  261. { add objectfiles, start with prt0 always }
  262. if prtobj<>'' then
  263. LinkRes.AddFileName(FindObjectFile(prtobj,''));
  264. { try to add crti and crtbegin if linking to C }
  265. if linklibc then
  266. begin
  267. if librarysearchpath.FindFile('crtbegin.o',s) then
  268. LinkRes.AddFileName(s);
  269. if librarysearchpath.FindFile('crti.o',s) then
  270. LinkRes.AddFileName(s);
  271. end;
  272. { main objectfiles }
  273. while not ObjectFiles.Empty do
  274. begin
  275. s:=ObjectFiles.GetFirst;
  276. if s<>'' then
  277. LinkRes.AddFileName(s);
  278. end;
  279. LinkRes.Add(')');
  280. { Write staticlibraries }
  281. if not StaticLibFiles.Empty then
  282. begin
  283. LinkRes.Add('GROUP(');
  284. While not StaticLibFiles.Empty do
  285. begin
  286. S:=StaticLibFiles.GetFirst;
  287. LinkRes.AddFileName(s)
  288. end;
  289. LinkRes.Add(')');
  290. end;
  291. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  292. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  293. if not SharedLibFiles.Empty then
  294. begin
  295. LinkRes.Add('INPUT(');
  296. While not SharedLibFiles.Empty do
  297. begin
  298. S:=SharedLibFiles.GetFirst;
  299. if s<>'c' then
  300. begin
  301. i:=Pos(target_info.sharedlibext,S);
  302. if i>0 then
  303. Delete(S,i,255);
  304. LinkRes.Add('-l'+s);
  305. end
  306. else
  307. begin
  308. linklibc:=true;
  309. linkdynamic:=false; { libc will include the ld-linux for us }
  310. end;
  311. end;
  312. { be sure that libc is the last lib }
  313. if linklibc then
  314. LinkRes.Add('-lc');
  315. { when we have -static for the linker the we also need libgcc }
  316. if (cs_link_staticflag in aktglobalswitches) then
  317. LinkRes.Add('-lgcc');
  318. if linkdynamic and (Info.DynamicLinker<>'') then
  319. LinkRes.AddFileName(Info.DynamicLinker);
  320. LinkRes.Add(')');
  321. end;
  322. { objects which must be at the end }
  323. if linklibc then
  324. begin
  325. found1:=librarysearchpath.FindFile('crtend.o',s1);
  326. found2:=librarysearchpath.FindFile('crtn.o',s2);
  327. if found1 or found2 then
  328. begin
  329. LinkRes.Add('INPUT(');
  330. if found1 then
  331. LinkRes.AddFileName(s1);
  332. if found2 then
  333. LinkRes.AddFileName(s2);
  334. LinkRes.Add(')');
  335. end;
  336. end;
  337. { Write and Close response }
  338. linkres.writetodisk;
  339. linkres.Free;
  340. WriteResponseFile:=True;
  341. end;
  342. function TLinkerLinux.MakeExecutable:boolean;
  343. var
  344. binstr,
  345. cmdstr : string;
  346. success : boolean;
  347. DynLinkStr : string[60];
  348. StaticStr,
  349. StripStr : string[40];
  350. begin
  351. if not(cs_link_extern in aktglobalswitches) then
  352. Message1(exec_i_linking,current_module.exefilename^);
  353. { Create some replacements }
  354. StaticStr:='';
  355. StripStr:='';
  356. DynLinkStr:='';
  357. if (cs_link_staticflag in aktglobalswitches) then
  358. StaticStr:='-static';
  359. if (cs_link_strip in aktglobalswitches) then
  360. StripStr:='-s';
  361. If (cs_profile in aktmoduleswitches) or
  362. ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then
  363. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  364. { Write used files and libraries }
  365. WriteResponseFile(false);
  366. { Call linker }
  367. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  368. Replace(cmdstr,'$EXE',current_module.exefilename^);
  369. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  370. Replace(cmdstr,'$RES',outputexedir+Info.ResName);
  371. Replace(cmdstr,'$STATIC',StaticStr);
  372. Replace(cmdstr,'$STRIP',StripStr);
  373. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  374. success:=DoExec(FindUtil(BinStr),CmdStr,true,false);
  375. { Remove ReponseFile }
  376. if (success) and not(cs_link_extern in aktglobalswitches) then
  377. RemoveFile(outputexedir+Info.ResName);
  378. MakeExecutable:=success; { otherwise a recursive call to link method }
  379. end;
  380. Function TLinkerLinux.MakeSharedLibrary:boolean;
  381. var
  382. InitStr,
  383. FiniStr,
  384. SoNameStr : string[80];
  385. binstr,
  386. cmdstr : string;
  387. success : boolean;
  388. begin
  389. MakeSharedLibrary:=false;
  390. if not(cs_link_extern in aktglobalswitches) then
  391. Message1(exec_i_linking,current_module.sharedlibfilename^);
  392. { Write used files and libraries }
  393. WriteResponseFile(true);
  394. { Create some replacements }
  395. InitStr:='-init FPC_LIB_START';
  396. FiniStr:='-fini FPC_LIB_EXIT';
  397. SoNameStr:='-soname '+SplitFileName(current_module.sharedlibfilename^);
  398. { Call linker }
  399. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  400. Replace(cmdstr,'$EXE',current_module.sharedlibfilename^);
  401. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  402. Replace(cmdstr,'$RES',outputexedir+Info.ResName);
  403. Replace(cmdstr,'$INIT',InitStr);
  404. Replace(cmdstr,'$FINI',FiniStr);
  405. Replace(cmdstr,'$SONAME',SoNameStr);
  406. success:=DoExec(FindUtil(binstr),cmdstr,true,false);
  407. { Strip the library ? }
  408. if success and (cs_link_strip in aktglobalswitches) then
  409. begin
  410. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  411. Replace(cmdstr,'$EXE',current_module.sharedlibfilename^);
  412. success:=DoExec(FindUtil(binstr),cmdstr,true,false);
  413. end;
  414. { Remove ReponseFile }
  415. if (success) and not(cs_link_extern in aktglobalswitches) then
  416. RemoveFile(outputexedir+Info.ResName);
  417. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  418. end;
  419. {*****************************************************************************
  420. Initialize
  421. *****************************************************************************}
  422. {$ifdef i386}
  423. const
  424. target_i386_linux_info : ttargetinfo =
  425. (
  426. target : target_i386_LINUX;
  427. name : 'Linux for i386';
  428. shortname : 'Linux';
  429. flags : [];
  430. cpu : cpu_i386;
  431. unit_env : 'LINUXUNITS';
  432. extradefines : 'UNIX';
  433. sourceext : '.pp';
  434. pasext : '.pas';
  435. exeext : '';
  436. defext : '.def';
  437. scriptext : '.sh';
  438. smartext : '.sl';
  439. unitext : '.ppu';
  440. unitlibext : '.ppl';
  441. asmext : '.s';
  442. objext : '.o';
  443. resext : '.res';
  444. resobjext : '.or';
  445. sharedlibext : '.so';
  446. staticlibext : '.a';
  447. staticlibprefix : 'libp';
  448. sharedlibprefix : 'lib';
  449. sharedClibext : '.so';
  450. staticClibext : '.a';
  451. staticClibprefix : 'lib';
  452. sharedClibprefix : 'lib';
  453. Cprefix : '';
  454. newline : #10;
  455. dirsep : '/';
  456. files_case_relevent : true;
  457. assem : as_i386_elf32;
  458. assemextern : as_i386_as;
  459. link : ld_i386_linux;
  460. linkextern : ld_i386_linux;
  461. ar : ar_gnu_ar;
  462. res : res_none;
  463. script : script_unix;
  464. endian : endian_little;
  465. alignment :
  466. (
  467. procalign : 4;
  468. loopalign : 4;
  469. jumpalign : 0;
  470. constalignmin : 0;
  471. constalignmax : 4;
  472. varalignmin : 0;
  473. varalignmax : 4;
  474. localalignmin : 0;
  475. localalignmax : 4;
  476. paraalign : 4;
  477. recordalignmin : 0;
  478. recordalignmax : 2;
  479. maxCrecordalign : 4
  480. );
  481. first_parm_offset : 8;
  482. heapsize : 256*1024;
  483. stacksize : 262144;
  484. DllScanSupported:false;
  485. use_function_relative_addresses : true
  486. );
  487. {$endif i386}
  488. {$ifdef m68k}
  489. const
  490. target_m68k_linux_info : ttargetinfo =
  491. (
  492. target : target_m68k_linux;
  493. name : 'Linux for m68k';
  494. shortname : 'linux';
  495. flags : [];
  496. cpu : cpu_m68k;
  497. short_name : 'LINUX';
  498. unit_env : 'LINUXUNITS';
  499. extradefines : 'UNIX';
  500. sourceext : '.pp';
  501. pasext : '.pas';
  502. exeext : '';
  503. defext : '';
  504. scriptext : '.sh';
  505. smartext : '.sl';
  506. unitext : '.ppu';
  507. unitlibext : '.ppl';
  508. asmext : '.s';
  509. objext : '.o';
  510. resext : '.res';
  511. resobjext : '.or';
  512. sharedlibext : '.so';
  513. staticlibext : '.a';
  514. staticlibprefix : 'libp';
  515. sharedlibprefix : 'lib';
  516. sharedClibext : '.so';
  517. staticClibext : '.a';
  518. staticClibprefix : 'lib';
  519. sharedClibprefix : 'lib';
  520. Cprefix : '';
  521. newline : #10;
  522. dirsep : '/';
  523. files_case_relevent : true;
  524. assem : as_m68k_as;
  525. assemextern : as_m68k_as;
  526. link : ld_m68k_linux;
  527. linkextern : ld_m68k_linux;
  528. ar : ar_m68k_ar;
  529. res : res_none;
  530. script : script_unix;
  531. endian : endian_big;
  532. alignment :
  533. (
  534. procalign : 4;
  535. loopalign : 4;
  536. jumpalign : 0;
  537. constalignmin : 0;
  538. constalignmax : 4;
  539. varalignmin : 0;
  540. varalignmax : 4;
  541. localalignmin : 0;
  542. localalignmax : 4;
  543. paraalign : 4;
  544. recordalignmin : 0;
  545. recordalignmax : 2;
  546. maxCrecordalign : 4
  547. );
  548. first_parm_offset : 8;
  549. heapsize : 128*1024;
  550. stacksize : 32*1024*1024;
  551. DllScanSupported:false;
  552. use_function_relative_addresses : true
  553. );
  554. {$endif m68k}
  555. {$ifdef powerpc}
  556. const
  557. target_powerpc_linux_info : ttargetinfo =
  558. (
  559. target : target_powerpc_LINUX;
  560. name : 'Linux for PowerPC';
  561. shortname : 'linuxppc';
  562. flags : [];
  563. cpu : cpu_powerpc;
  564. unit_env : '';
  565. extradefines : 'UNIX';
  566. sourceext : '.pp';
  567. pasext : '.pas';
  568. exeext : '';
  569. defext : '.def';
  570. scriptext : '.sh';
  571. smartext : '.sl';
  572. unitext : '.ppu';
  573. unitlibext : '.ppl';
  574. asmext : '.s';
  575. objext : '.o';
  576. resext : '.res';
  577. resobjext : '.or';
  578. sharedlibext : '.so';
  579. staticlibext : '.s';
  580. staticlibprefix : 'libp';
  581. sharedlibprefix : 'lib';
  582. sharedClibext : '.so';
  583. staticClibext : '.a';
  584. staticClibprefix : 'lib';
  585. sharedClibprefix : 'lib';
  586. Cprefix : '';
  587. newline : #10;
  588. dirsep : '/';
  589. files_case_relevent : true;
  590. assem : as_powerpc_as;
  591. assemextern : as_powerpc_as;
  592. link : ld_powerpc_linux;
  593. linkextern : ld_powerpc_linux;
  594. ar : ar_gnu_ar;
  595. res : res_none;
  596. script : script_unix;
  597. endian : endian_big;
  598. alignment :
  599. (
  600. procalign : 4;
  601. loopalign : 4;
  602. jumpalign : 0;
  603. constalignmin : 0;
  604. constalignmax : 4;
  605. varalignmin : 0;
  606. varalignmax : 4;
  607. localalignmin : 0;
  608. localalignmax : 4;
  609. paraalign : 4;
  610. recordalignmin : 0;
  611. recordalignmax : 2;
  612. maxCrecordalign : 4
  613. );
  614. first_parm_offset : 8;
  615. heapsize : 256*1024;
  616. stacksize : 32*1024*1024;
  617. DllScanSupported:false;
  618. use_function_relative_addresses : true
  619. );
  620. {$endif powerpc}
  621. {$ifdef alpha}
  622. const
  623. target_alpha_linux_info : ttargetinfo =
  624. (
  625. target : target_alpha_LINUX;
  626. name : 'Linux for Alpha';
  627. shortname : 'axplinux';
  628. flags : [];
  629. cpu : cpu_alpha;
  630. short_name : 'LINUX';
  631. unit_env : 'LINUXUNITS';
  632. extradefines : 'UNIX';
  633. sourceext : '.pp';
  634. pasext : '.pas';
  635. exeext : '';
  636. defext : '.def';
  637. scriptext : '.sh';
  638. smartext : '.sl';
  639. unitext : '.ppu';
  640. unitlibext : '.ppl';
  641. asmext : '.s';
  642. objext : '.o';
  643. resext : '.res';
  644. resobjext : '.or';
  645. sharedlibext : '.so';
  646. staticlibext : '.a';
  647. staticlibprefix : 'libp';
  648. sharedlibprefix : 'lib';
  649. sharedClibext : '.so';
  650. staticClibext : '.a';
  651. staticClibprefix : 'lib';
  652. sharedClibprefix : 'lib';
  653. Cprefix : '';
  654. newline : #10;
  655. dirsep : '/';
  656. files_case_relevent : true;
  657. assem : as_alpha_as;
  658. assemextern : as_alpha_as;
  659. link : ld_alpha_linux;
  660. linkextern : ld_alpha_linux;
  661. ar : ar_alpha_ar;
  662. res : res_none;
  663. script : script_unix;
  664. endian : endian_little;
  665. alignment :
  666. (
  667. procalign : 4;
  668. loopalign : 4;
  669. jumpalign : 0;
  670. constalignmin : 0;
  671. constalignmax : 4;
  672. varalignmin : 0;
  673. varalignmax : 4;
  674. localalignmin : 0;
  675. localalignmax : 4;
  676. paraalign : 4;
  677. recordalignmin : 0;
  678. recordalignmax : 2;
  679. maxCrecordalign : 4
  680. );
  681. first_parm_offset : 8;
  682. heapsize : 256*1024;
  683. stacksize : 32*1024*1024;
  684. DllScanSupported:false;
  685. use_function_relative_addresses : true
  686. );
  687. {$endif alpha}
  688. {$ifdef x86_64}
  689. const
  690. target_x86_64_linux_info : ttargetinfo =
  691. (
  692. target : target_i386_LINUX;
  693. name : 'Linux for x86-64';
  694. shortname : 'Linux64';
  695. flags : [];
  696. cpu : x86_64;
  697. unit_env : 'LINUXUNITS';
  698. extradefines : 'UNIX';
  699. sourceext : '.pp';
  700. pasext : '.pas';
  701. exeext : '';
  702. defext : '.def';
  703. scriptext : '.sh';
  704. smartext : '.sl';
  705. unitext : '.ppu';
  706. unitlibext : '.ppl';
  707. asmext : '.s';
  708. objext : '.o';
  709. resext : '.res';
  710. resobjext : '.or';
  711. sharedlibext : '.so';
  712. staticlibext : '.a';
  713. staticlibprefix : 'libp';
  714. sharedlibprefix : 'lib';
  715. sharedClibext : '.so';
  716. staticClibext : '.a';
  717. staticClibprefix : 'lib';
  718. sharedClibprefix : 'lib';
  719. Cprefix : '';
  720. newline : #10;
  721. dirsep : '/';
  722. files_case_relevent : true;
  723. assem : as_i386_elf32;
  724. assemextern : as_i386_as;
  725. link : ld_i386_linux;
  726. linkextern : ld_i386_linux;
  727. ar : ar_gnu_ar;
  728. res : res_none;
  729. script : script_unix;
  730. endian : endian_little;
  731. alignment :
  732. (
  733. procalign : 4;
  734. loopalign : 4;
  735. jumpalign : 0;
  736. constalignmin : 0;
  737. constalignmax : 1;
  738. varalignmin : 0;
  739. varalignmax : 1;
  740. localalignmin : 0;
  741. localalignmax : 1;
  742. paraalign : 4;
  743. recordalignmin : 0;
  744. recordalignmax : 2;
  745. maxCrecordalign : 4
  746. );
  747. size_of_pointer : 8;
  748. size_of_longint : 4;
  749. heapsize : 256*1024;
  750. maxheapsize : 65536*1024;
  751. stacksize : 16*1024;
  752. DllScanSupported:false;
  753. use_bound_instruction : false;
  754. use_function_relative_addresses : true
  755. );
  756. {$endif x86_64}
  757. {$IFDEF SPARC}
  758. CONST
  759. target_SPARC_linux_info : ttargetinfo =
  760. (
  761. target : target_SPARC_Linux;
  762. name : 'Linux for SPARC';
  763. shortname : 'Linux';
  764. flags : [];
  765. cpu : cpu_SPARC;
  766. unit_env : 'LINUXUNITS';
  767. extradefines : 'UNIX';
  768. sourceext : '.pp';
  769. pasext : '.pas';
  770. exeext : '';
  771. defext : '.def';
  772. scriptext : '.sh';
  773. smartext : '.sl';
  774. unitext : '.ppu';
  775. unitlibext : '.ppl';
  776. asmext : '.s';
  777. objext : '.o';
  778. resext : '.res';
  779. resobjext : '.or';
  780. sharedlibext : '.so';
  781. staticlibext : '.a';
  782. staticlibprefix : 'libp';
  783. sharedlibprefix : 'lib';
  784. sharedClibext : '.so';
  785. staticClibext : '.a';
  786. staticClibprefix : 'lib';
  787. sharedClibprefix : 'lib';
  788. Cprefix : '';
  789. newline : #10;
  790. dirsep : '/';
  791. files_case_relevent : true;
  792. assem : as_SPARC_elf32;
  793. assemextern : as_SPARC_as;
  794. link : ld_SPARC_linux;
  795. linkextern : ld_SPARC_linux;
  796. ar : ar_gnu_ar;
  797. res : res_none;
  798. script : script_unix;
  799. endian : endian_little;
  800. alignment :
  801. (
  802. procalign : 4;
  803. loopalign : 4;
  804. jumpalign : 0;
  805. constalignmin : 0;
  806. constalignmax : 4;
  807. varalignmin : 0;
  808. varalignmax : 4;
  809. localalignmin : 0;
  810. localalignmax : 4;
  811. paraalign : 4;
  812. recordalignmin : 0;
  813. recordalignmax : 2;
  814. maxCrecordalign : 4
  815. );
  816. first_parm_offset : 8;
  817. heapsize : 256*1024;
  818. stacksize : 262144;
  819. DllScanSupported:false;
  820. use_function_relative_addresses : true
  821. );
  822. {$ENDIF SPARC}
  823. initialization
  824. {$ifdef i386}
  825. RegisterLinker(ld_i386_linux,TLinkerLinux);
  826. RegisterImport(target_i386_linux,timportliblinux);
  827. RegisterExport(target_i386_linux,texportliblinux);
  828. RegisterTarget(target_i386_linux_info);
  829. {$endif i386}
  830. {$ifdef m68k}
  831. RegisterLinker(ld_m68k_linux,TLinkerLinux);
  832. RegisterImport(target_m68k_linux,timportliblinux);
  833. RegisterExport(target_m68k_linux,texportliblinux);
  834. RegisterTarget(target_m68k_linux_info);
  835. {$endif m68k}
  836. {$ifdef powerpc}
  837. RegisterLinker(ld_powerpc_linux,TLinkerLinux);
  838. RegisterImport(target_powerpc_linux,timportliblinux);
  839. RegisterExport(target_powerpc_linux,texportliblinux);
  840. RegisterTarget(target_powerpc_linux_info);
  841. {$endif powerpc}
  842. {$ifdef alpha}
  843. RegisterLinker(ld_alpha_linux,TLinkerLinux);
  844. RegisterImport(target_alpha_linux,timportliblinux);
  845. RegisterExport(target_alpha_linux,texportliblinux);
  846. RegisterTarget(target_alpha_linux_info);
  847. {$endif alpha}
  848. {$ifdef x86_64}
  849. RegisterLinker(ld_x86_64_linux,TLinkerLinux);
  850. RegisterImport(target_x86_64_linux,timportliblinux);
  851. RegisterExport(target_x86_64_linux,texportliblinux);
  852. RegisterTarget(target_x86_64_linux_info);
  853. {$endif x86_64}
  854. {$IFDEF SPARC}
  855. RegisterLinker(ld_SPARC_linux,TLinkerLinux);
  856. RegisterImport(target_SPARC_linux,timportliblinux);
  857. RegisterExport(target_SPARC_linux,texportliblinux);
  858. RegisterTarget(target_SPARC_linux_info);
  859. {$ENDIF SPARC}
  860. end.
  861. {
  862. $Log$
  863. Revision 1.28 2002-07-04 20:43:02 florian
  864. * first x86-64 patches
  865. Revision 1.27 2002/07/01 18:46:35 peter
  866. * internal linker
  867. * reorganized aasm layer
  868. Revision 1.26 2002/05/18 13:34:26 peter
  869. * readded missing revisions
  870. Revision 1.25 2002/05/16 19:46:53 carl
  871. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  872. + try to fix temp allocation (still in ifdef)
  873. + generic constructor calls
  874. + start of tassembler / tmodulebase class cleanup
  875. Revision 1.22 2002/05/06 19:46:36 carl
  876. + added more patches from Mazen for SPARC port
  877. Revision 1.21 2002/04/22 18:19:22 carl
  878. - remove use_bound_instruction field
  879. Revision 1.20 2002/04/20 21:43:18 carl
  880. * fix stack size for some targets
  881. + add offset to parameters from frame pointer info.
  882. - remove some unused stuff
  883. Revision 1.19 2002/04/19 15:46:05 peter
  884. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  885. in most cases and not written to the ppu
  886. * add mangeledname_prefix() routine to generate the prefix of
  887. manglednames depending on the current procedure, object and module
  888. * removed static procprefix since the mangledname is now build only
  889. on demand from tprocdef.mangledname
  890. Revision 1.18 2002/04/15 19:44:23 peter
  891. * fixed stackcheck that would be called recursively when a stack
  892. error was found
  893. * generic changeregsize(reg,size) for i386 register resizing
  894. * removed some more routines from cga unit
  895. * fixed returnvalue handling
  896. * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
  897. Revision 1.17 2002/04/15 19:16:57 carl
  898. - remove size_of_pointer field
  899. Revision 1.16 2002/01/29 21:27:34 peter
  900. * default alignment changed to 4 bytes for locals and static const,var
  901. Revision 1.15 2002/01/09 07:38:37 michael
  902. + Patch from Peter for library imports
  903. }