t_linux.pas 28 KB

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