t_nwl.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. {
  2. $Id$
  3. Copyright (c) 1998-2004 by Peter Vreman
  4. This unit implements support import,export,link routines
  5. for the (i386) Netware libc 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. Currently generating NetWare-NLM's only work under Linux and win32.
  18. (see http://home.arcor.de/armin.diehl/fpcnw for binutils working
  19. with win32) while not included in fpc-releases.
  20. The following compiler-swiches are supported for NetWare:
  21. $DESCRIPTION : NLM-Description, will be displayed at load-time
  22. $M : For Stack-Size, Heap-Size will be ignored
  23. 32K is the accepted minimum
  24. $VERSION x.x.x : Sets Major, Minor and Revision
  25. $SCREENNAME : Sets the ScreenName
  26. $THREADNAME : Sets current threadname
  27. Additional parameters for the nlmvonv-inputfile can be passed with
  28. -k, i.e. -kREENTRANT will add the option REENTRANT to the nlmconv
  29. inputfile. A ; will be converted into a newline
  30. Exports will be handled like in win32:
  31. procedure bla; cdecl;
  32. begin
  33. end;
  34. exports foo name 'Bar';
  35. The path to the import-Files must be specified by the library-path.
  36. All external modules are defined as autoload. (Note: the import-files have
  37. to be in unix-format for exe2nlm)
  38. By default, the most import files are included in freepascal.
  39. e.g. function getgrnam(name:Pchar):Pgroup;cdecl;external 'libc' 'getgrnam';
  40. sets IMPORT @libc.imp and MODULE libc.
  41. To avoid setting the autoload, use ! in the name, e.g.
  42. procedure EnterDebugger;cdecl;external '!netware' name 'EnterDebugger';
  43. Function simply defined as external work without generating autoload and
  44. IMPORT but you will get a warning from nlmconv.
  45. If you dont have nlmconv, compile gnu-binutils with
  46. ./configure --enable-targets=i386-netware
  47. make all
  48. Debugging is possible with gdb and a converter from gdb to ndi available
  49. at http://home.arcor.de/armin.diehl/gdbnw
  50. A sample program:
  51. Program Hello;
  52. (*$DESCRIPTION HelloWorldNlm*)
  53. (*$VERSION 1.2.3*)
  54. (*$ScreenName Hello*)
  55. (*$M 60000,60000*)
  56. begin
  57. writeLn ('hello world');
  58. end.
  59. compile with:
  60. ppc386 -Tnetwlibc hello
  61. Libraries are supported but this needs at least netware 5.1 sp6,
  62. 6.0 sp3 or netware 6.5
  63. In case there is a xdc file with the same name as the nlm name,
  64. this file will be used for nlmconv. Otherwise a temp xdc will
  65. be created and used.
  66. ****************************************************************************
  67. }
  68. unit t_nwl;
  69. {$i fpcdefs.inc}
  70. interface
  71. implementation
  72. {$ifdef netwlibc}
  73. {$define netware}
  74. {$endif}
  75. uses
  76. cutils,
  77. verbose,systems,globtype,globals,
  78. symconst,script,
  79. fmodule,aasmbase,aasmtai,aasmcpu,cpubase,symsym,symdef,
  80. import,export,link,i_nwl
  81. {$ifdef netware} ,dos {$endif}
  82. ;
  83. type
  84. timportlibnetwlibc=class(timportlib)
  85. procedure preparelib(const s:string);override;
  86. procedure importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);override;
  87. procedure importvariable(vs:tglobalvarsym;const name,module:string);override;
  88. procedure generatelib;override;
  89. end;
  90. texportlibnetwlibc=class(texportlib)
  91. procedure preparelib(const s : string);override;
  92. procedure exportprocedure(hp : texported_item);override;
  93. procedure exportvar(hp : texported_item);override;
  94. procedure generatelib;override;
  95. end;
  96. tlinkernetwlibc=class(texternallinker)
  97. private
  98. NLMConvLinkFile: TLinkRes; {for second pass, fist pass is ld}
  99. Function WriteResponseFile(isdll:boolean) : Boolean;
  100. public
  101. constructor Create;override;
  102. procedure SetDefaultInfo;override;
  103. function MakeNetwareLoadableModule (isLib : boolean):boolean;
  104. function MakeExecutable:boolean;override;
  105. function MakeSharedLibrary:boolean;override;
  106. end;
  107. Const tmpLinkFileName = '~link~tmp.o';
  108. minStackSize = 32768;
  109. {*****************************************************************************
  110. TIMPORTLIBNETWARE
  111. *****************************************************************************}
  112. procedure timportlibnetwlibc.preparelib(const s : string);
  113. begin
  114. end;
  115. procedure timportlibnetwlibc.importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);
  116. begin
  117. { insert sharedlibrary }
  118. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  119. end;
  120. procedure timportlibnetwlibc.importvariable(vs:tglobalvarsym;const name,module:string);
  121. begin
  122. { insert sharedlibrary }
  123. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  124. { reset the mangledname and turn off the dll_var option }
  125. vs.set_mangledname(name);
  126. exclude(vs.varoptions,vo_is_dll_var);
  127. end;
  128. procedure timportlibnetwlibc.generatelib;
  129. begin
  130. end;
  131. {*****************************************************************************
  132. TEXPORTLIBNETWARE
  133. *****************************************************************************}
  134. procedure texportlibnetwlibc.preparelib(const s:string);
  135. begin
  136. end;
  137. procedure texportlibnetwlibc.exportprocedure(hp : texported_item);
  138. var
  139. hp2 : texported_item;
  140. begin
  141. { first test the index value }
  142. if (hp.options and eo_index)<>0 then
  143. begin
  144. Comment(V_Error,'can''t export with index under netware');
  145. exit;
  146. end;
  147. { use pascal name is none specified }
  148. if (hp.options and eo_name)=0 then
  149. begin
  150. hp.name:=stringdup(hp.sym.name);
  151. hp.options:=hp.options or eo_name;
  152. end;
  153. { now place in correct order }
  154. hp2:=texported_item(current_module._exports.first);
  155. while assigned(hp2) and
  156. (hp.name^>hp2.name^) do
  157. hp2:=texported_item(hp2.next);
  158. { insert hp there !! }
  159. if assigned(hp2) and (hp2.name^=hp.name^) then
  160. begin
  161. { this is not allowed !! }
  162. Message1(parser_e_export_name_double,hp.name^);
  163. exit;
  164. end;
  165. if hp2=texported_item(current_module._exports.first) then
  166. current_module._exports.insert(hp)
  167. else if assigned(hp2) then
  168. begin
  169. hp.next:=hp2;
  170. hp.previous:=hp2.previous;
  171. if assigned(hp2.previous) then
  172. hp2.previous.next:=hp;
  173. hp2.previous:=hp;
  174. end
  175. else
  176. current_module._exports.concat(hp);
  177. end;
  178. procedure texportlibnetwlibc.exportvar(hp : texported_item);
  179. begin
  180. hp.is_var:=true;
  181. exportprocedure(hp);
  182. end;
  183. procedure texportlibnetwlibc.generatelib;
  184. var
  185. hp2 : texported_item;
  186. begin
  187. hp2:=texported_item(current_module._exports.first);
  188. while assigned(hp2) do
  189. begin
  190. if (not hp2.is_var) and
  191. (hp2.sym.typ=procsym) then
  192. begin
  193. { the manglednames can already be the same when the procedure
  194. is declared with cdecl }
  195. if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
  196. begin
  197. {$ifdef i386}
  198. { place jump in codesegment }
  199. codesegment.concat(Tai_align.Create_op(4,$90));
  200. codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
  201. codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
  202. codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
  203. {$endif i386}
  204. end;
  205. end
  206. else
  207. //Comment(V_Error,'Exporting of variables is not supported under netware');
  208. Message1(parser_e_no_export_of_variables_for_target,'netware');
  209. hp2:=texported_item(hp2.next);
  210. end;
  211. end;
  212. {*****************************************************************************
  213. TLINKERNETWARE
  214. *****************************************************************************}
  215. Constructor TLinkerNetwlibc.Create;
  216. begin
  217. Inherited Create;
  218. end;
  219. procedure TLinkerNetwlibc.SetDefaultInfo;
  220. begin
  221. with Info do
  222. begin
  223. {$ifndef netware}
  224. ExeCmd[1]:= FindUtil(utilsprefix+'ld') + ' -Ur -T $RES $STRIP -o $TMPOBJ';
  225. ExeCmd[2]:= FindUtil(utilsprefix+'nlmconv') + ' -T$RES';
  226. {$else}
  227. {for running on netware we need absolute pathes since ld has another working directory}
  228. ExeCmd[1]:= FindUtil(utilsprefix+'ld') + ' -Ur -T '+FExpand(outputexedir+Info.ResName)+' $STRIP -o '+Fexpand(outputexedir+tmpLinkFileName);
  229. ExeCmd[2]:= FindUtil(utilsprefix+'nlmconv') + ' -T'+FExpand(outputexedir+'n'+Info.ResName);
  230. {$endif}
  231. end;
  232. end;
  233. Function TLinkerNetwlibc.WriteResponseFile(isdll:boolean) : Boolean;
  234. Var
  235. linkres : TLinkRes;
  236. i : longint;
  237. s,s2,s3 : string;
  238. ProgNam : string [80];
  239. NlmNam : string [80];
  240. hp2 : texported_item; { for exports }
  241. p : byte;
  242. begin
  243. WriteResponseFile:=False;
  244. ProgNam := current_module.exefilename^;
  245. i:=Pos(target_info.exeext,ProgNam);
  246. if i>0 then
  247. Delete(ProgNam,i,255);
  248. NlmNam := ProgNam + target_info.exeext;
  249. { Open link.res file }
  250. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName); {for ld}
  251. NLMConvLinkFile:=TLinkRes.Create(outputexedir+'n'+Info.ResName); {for nlmconv, written in CreateExeFile}
  252. p := Pos ('"', Description);
  253. while (p > 0) do
  254. begin
  255. delete (Description,p,1);
  256. p := Pos ('"', Description);
  257. end;
  258. if Description <> '' then
  259. NLMConvLinkFile.Add('DESCRIPTION "' + Description + '"');
  260. NLMConvLinkFile.Add('VERSION '+tostr(dllmajor)+','+tostr(dllminor)+','+tostr(dllrevision));
  261. p := Pos ('"', nwscreenname);
  262. while (p > 0) do
  263. begin
  264. delete (nwscreenname,p,1);
  265. p := Pos ('"', nwscreenname);
  266. end;
  267. p := Pos ('"', nwthreadname);
  268. while (p > 0) do
  269. begin
  270. delete (nwthreadname,p,1);
  271. p := Pos ('"', nwthreadname);
  272. end;
  273. p := Pos ('"', nwcopyright);
  274. while (p > 0) do
  275. begin
  276. delete (nwcopyright,p,1);
  277. p := Pos ('"', nwcopyright);
  278. end;
  279. if nwscreenname <> '' then
  280. NLMConvLinkFile.Add('SCREENNAME "' + nwscreenname + '"');
  281. if nwthreadname <> '' then
  282. NLMConvLinkFile.Add('THREADNAME "' + nwthreadname + '"');
  283. if nwcopyright <> '' then
  284. NLMConvLinkFile.Add('COPYRIGHT "' + nwcopyright + '"');
  285. if stacksize < minStackSize then stacksize := minStackSize;
  286. str (stacksize, s);
  287. NLMConvLinkFile.Add ('STACKSIZE '+s);
  288. {$ifndef netware}
  289. NLMConvLinkFile.Add ('INPUT '+outputexedir+tmpLinkFileName);
  290. {$else}
  291. NLMConvLinkFile.Add ('INPUT '+FExpand(outputexedir+tmpLinkFileName));
  292. {$endif}
  293. { add objectfiles, start with nwpre always }
  294. LinkRes.Add ('INPUT(');
  295. s2 := FindObjectFile('nwplibc','',false);
  296. if s2 = '' then
  297. s2 := FindObjectFile('libcpre.gcc','',false);
  298. Comment (V_Debug,'adding Object File '+s2);
  299. {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
  300. if isDll then {needed to provide main}
  301. s2 := FindObjectFile('nwl_dlle','',false)
  302. else
  303. s2 := FindObjectFile('nwl_main','',false);
  304. Comment (V_Debug,'adding Object File '+s2);
  305. {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
  306. { main objectfiles, add to linker input }
  307. while not ObjectFiles.Empty do
  308. begin
  309. s:=ObjectFiles.GetFirst;
  310. if s<>'' then
  311. begin
  312. s2 := FindObjectFile (s,'',false);
  313. Comment (V_Debug,'adding Object File '+s2);
  314. {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
  315. end;
  316. end;
  317. LinkRes.Add (')');
  318. { output file (nlm), add to nlmconv }
  319. {$ifndef netware}
  320. NLMConvLinkFile.Add ('OUTPUT ' + NlmNam);
  321. {$else}
  322. NLMConvLinkFile.Add ('OUTPUT ' + FExpand(NlmNam));
  323. {$endif}
  324. { start and stop-procedures }
  325. NLMConvLinkFile.Add ('START _LibCPrelude');
  326. NLMConvLinkFile.Add ('EXIT _LibCPostlude');
  327. NLMConvLinkFile.Add ('CHECK _LibCCheckUnload');
  328. NLMConvLinkFile.Add ('REENTRANT'); { needed by older libc versions }
  329. if not (cs_link_strip in aktglobalswitches) then
  330. begin
  331. NLMConvLinkFile.Add ('DEBUG');
  332. Comment(V_Debug,'DEBUG');
  333. end;
  334. { Write staticlibraries }
  335. if not StaticLibFiles.Empty then
  336. begin
  337. LinkRes.Add ('GROUP(');
  338. While not StaticLibFiles.Empty do
  339. begin
  340. S:=lower (StaticLibFiles.GetFirst);
  341. if s<>'' then
  342. begin
  343. {ad: that's a hack !
  344. whith -XX we get the .a files as static libs (in addition to the
  345. imported libraries}
  346. if (pos ('.a',s) <> 0) OR (pos ('.A', s) <> 0) then
  347. begin
  348. S2 := FindObjectFile(s,'',false);
  349. {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
  350. Comment(V_Debug,'adding Object File (StaticLibFiles) '+S2);
  351. end else
  352. begin
  353. i:=Pos(target_info.staticlibext,S);
  354. if i>0 then
  355. Delete(S,i,255);
  356. S := S + '.imp'; S2 := '';
  357. librarysearchpath.FindFile(S,S2);
  358. {$ifdef netware}
  359. Comment(V_Debug,'IMPORT @'+s2);
  360. s2 := FExpand (S2);
  361. {$endif}
  362. NLMConvLinkFile.Add('IMPORT @'+S2);
  363. Comment(V_Debug,'IMPORT @'+s2);
  364. end;
  365. end
  366. end;
  367. LinkRes.Add (')');
  368. end;
  369. if not SharedLibFiles.Empty then
  370. begin
  371. While not SharedLibFiles.Empty do
  372. begin
  373. {becuase of upper/lower case mix, we may get duplicate
  374. names but nlmconv ignores that.
  375. Here we are setting the import-files for nlmconv. I.e. for
  376. the module libc or libc.nlm we add IMPORT @libc.imp and also
  377. the module libc.nlm (autoload)
  378. If a lib name begins with !, only the IMPORT will be generated
  379. ? may it be better to set autoload's via StaticLibFiles ? }
  380. S:=lower (SharedLibFiles.GetFirst);
  381. if s<>'' then
  382. begin
  383. s2:=s;
  384. i:=Pos(target_info.sharedlibext,S);
  385. if i>0 then
  386. Delete(S,i,255);
  387. if s[1] = '!' then
  388. begin // special, with ! only the imp will be included but no module is autoloaded, needed i.e. for netware.imp inlcuded in libc ndk
  389. delete (s,1,1);
  390. S := S + '.imp';
  391. librarysearchpath.FindFile(S,S3);
  392. {$ifdef netware}
  393. Comment(V_Debug,'IMPORT @'+S3);
  394. S3 := FExpand (S3);
  395. {$endif}
  396. NLMConvLinkFile.Add('IMPORT @'+S3);
  397. Comment(V_Debug,'IMPORT @'+S3);
  398. end else
  399. begin
  400. S := S + '.imp';
  401. librarysearchpath.FindFile(S,S3);
  402. {$ifdef netware}
  403. Comment(V_Debug,'IMPORT @'+S3);
  404. S3 := FExpand (S3);
  405. {$endif}
  406. NLMConvLinkFile.Add('IMPORT @'+S3);
  407. NLMConvLinkFile.Add('MODULE '+s2);
  408. Comment(V_Debug,'MODULE '+S2);
  409. Comment(V_Debug,'IMPORT @'+S3);
  410. end;
  411. end
  412. end;
  413. end;
  414. { write exports }
  415. hp2:=texported_item(current_module._exports.first);
  416. while assigned(hp2) do
  417. begin
  418. if not hp2.is_var then
  419. begin
  420. { Export the Symbol }
  421. Comment(V_Debug,'EXPORT '+hp2.name^);
  422. NLMConvLinkFile.Add ('EXPORT '+hp2.name^);
  423. end
  424. else
  425. { really, i think it is possible }
  426. {Comment(V_Error,'Exporting of variables is not supported under netware');}
  427. Message1(parser_e_no_export_of_variables_for_target,'netware');
  428. hp2:=texported_item(hp2.next);
  429. end;
  430. { Write and Close response for ld, response for nlmconv is in NLMConvLinkFile(not written) }
  431. linkres.writetodisk;
  432. LinkRes.Free;
  433. { pass options from -k to nlmconv, ; is interpreted as newline }
  434. s := ParaLinkOptions;
  435. while(Length(s) > 0) and (s[1] = ' ') do
  436. delete (s,1,1);
  437. p := pos ('"',s);
  438. while p > 0 do
  439. begin
  440. delete (s,p,1);
  441. p := pos ('"',s);
  442. end;
  443. p := pos (';',s);
  444. while p > 0 do
  445. begin
  446. s2 := copy(s,1,p-1);
  447. comment (V_Debug,'adding "'+s2+'" to nlmvonv input');
  448. NLMConvLinkFile.Add(s2);
  449. delete (s,1,p);
  450. p := pos (';',s);
  451. end;
  452. if s <> '' then
  453. begin
  454. comment (V_Debug,'adding "'+s+'" to nlmvonv input');
  455. NLMConvLinkFile.Add(s);
  456. end;
  457. WriteResponseFile:=True;
  458. end;
  459. Const
  460. xdc : Array[0..127] of char = (
  461. 'B','A','G','F',#2,#0,#0,#0,#1,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,
  462. #0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#2,#0,#0,#0,#0,#0,#0,#0,#16,#0,#0,
  463. #0,#7,'M','P','K','_','B','a','g',#0,#0,#0,#0,#0,#0,#0,#0,#11,'M','T',
  464. ' ','S','a','f','e',' ','N','L','M',#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,
  465. #0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,
  466. #0,#0,#0,#0,#0,#0,#1,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0);
  467. function TLinkerNetwlibc.MakeNetwareLoadableModule (isLib : boolean):boolean;
  468. var
  469. binstr : String;
  470. cmdstr : TcmdStr;
  471. xdcname : string;
  472. success : boolean;
  473. StripStr : string[2];
  474. xdcpresent,usexdc : boolean;
  475. f : file;
  476. begin
  477. if not(cs_link_extern in aktglobalswitches) then
  478. Message1(exec_i_linking,current_module.exefilename^);
  479. { Create some replacements }
  480. StripStr:='';
  481. if (cs_link_strip in aktglobalswitches) then
  482. StripStr:='-s';
  483. { Write used files and libraries and create Headerfile for
  484. nlmconv in NLMConvLinkFile }
  485. WriteResponseFile(isLib);
  486. if isLib then
  487. NLMConvLinkFile.Add('FLAG_ON 1024'); {0x400 Specifies whether the NLM is a shared library.}
  488. { if we have a xdc file, dont touch it, otherwise create a new
  489. one and remove it after nlmconv }
  490. xdcname := ForceExtension(current_module.exefilename^,'.xdc');
  491. xdcpresent := FileExists (xdcname);
  492. if not xdcpresent then
  493. begin
  494. assign (f,xdcname);
  495. rewrite(f,1);
  496. if ioresult = 0 then
  497. begin
  498. blockwrite (f,xdc,sizeof(xdc));
  499. close(f);
  500. usexdc := (IOResult = 0);
  501. end else
  502. usexdc := false;
  503. end else
  504. usexdc := true;
  505. if usexdc then
  506. NLMConvLinkFile.Add('XDCDATA '+xdcname);
  507. { Call linker, this will generate a new object file that will be passed
  508. to nlmconv. Otherwise we could not create nlms without debug info }
  509. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  510. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename^));
  511. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  512. Replace(cmdstr,'$STRIP',StripStr);
  513. Replace(cmdstr,'$TMPOBJ',maybequoted(outputexedir+tmpLinkFileName));
  514. Comment (v_debug,'Executing '+BinStr+' '+cmdstr);
  515. success:=DoExec(FindUtil(BinStr),CmdStr,true,false);
  516. { Remove ReponseFile }
  517. if (success) and not(cs_link_extern in aktglobalswitches) then
  518. RemoveFile(outputexedir+Info.ResName);
  519. { Call nlmconv }
  520. if success then
  521. begin
  522. NLMConvLinkFile.writetodisk;
  523. NLMConvLinkFile.Free;
  524. SplitBinCmd(Info.ExeCmd[2],binstr,cmdstr);
  525. Replace(cmdstr,'$RES',maybequoted(outputexedir+'n'+Info.ResName));
  526. Comment (v_debug,'Executing '+BinStr+' '+cmdstr);
  527. success:=DoExec(FindUtil(BinStr),CmdStr,true,false);
  528. if (success) and not(cs_link_extern in aktglobalswitches) then
  529. begin
  530. RemoveFile(outputexedir+'n'+Info.ResName);
  531. RemoveFile(outputexedir+tmpLinkFileName);
  532. if not xdcpresent then
  533. if usexdc then
  534. RemoveFile (xdcname);
  535. end;
  536. end;
  537. MakeNetwareLoadableModule:=success; { otherwise a recursive call to link method }
  538. end;
  539. function TLinkerNetwlibc.MakeExecutable:boolean;
  540. begin
  541. MakeExecutable := MakeNetwareLoadableModule (false);
  542. end;
  543. function TLinkerNetwlibc.MakeSharedLibrary:boolean;
  544. begin
  545. MakeSharedLibrary := MakeNetwareLoadableModule (true);
  546. end;
  547. {*****************************************************************************
  548. Initialize
  549. *****************************************************************************}
  550. initialization
  551. RegisterExternalLinker(system_i386_netwlibc_info,TLinkerNetwlibc);
  552. RegisterImport(system_i386_netwlibc,TImportLibNetwlibc);
  553. RegisterExport(system_i386_netwlibc,TExportLibNetwlibc);
  554. RegisterTarget(system_i386_netwlibc_info);
  555. end.
  556. {
  557. $Log$
  558. Revision 1.12 2004-12-22 16:32:46 peter
  559. * maybequoted() added
  560. Revision 1.11 2004/11/25 18:46:11 armin
  561. * added utilsprefix for as,ld and nlmconv
  562. Revision 1.10 2004/11/19 16:30:24 peter
  563. * fixed setting of mangledname when importing
  564. Revision 1.9 2004/11/08 22:09:59 peter
  565. * tvarsym splitted
  566. Revision 1.8 2004/10/25 15:38:41 peter
  567. * heap and heapsize removed
  568. * checkpointer fixes
  569. Revision 1.7 2004/10/14 18:16:17 mazen
  570. * USE_SYSUTILS merged successfully : cycles with and without defines
  571. * Need to be optimized in performance
  572. Revision 1.6 2004/09/24 10:48:31 armin
  573. * added GROUP for .a files to linker script
  574. Revision 1.5 2004/09/22 15:25:14 mazen
  575. * Fix error committing : previous version must be in branch USE_SYSUTILS
  576. Revision 1.3 2004/09/19 18:10:32 armin
  577. * added library support
  578. Revision 1.2 2004/09/19 14:23:43 armin
  579. * support library flag
  580. * automaticly gernerate xdc data
  581. Revision 1.1 2004/09/04 21:18:47 armin
  582. * target netwlibc added (libc is preferred for newer netware versions)
  583. Revision 1.14 2004/08/30 11:17:34 armin
  584. * added support for libc
  585. Revision 1.13 2004/08/01 19:29:06 armin
  586. * changes to compile fpc on netware
  587. Revision 1.12 2004/07/30 16:00:19 armin
  588. * removed -m for nlmconv, it is only valid for ld
  589. Revision 1.11 2004/06/20 08:55:32 florian
  590. * logs truncated
  591. Revision 1.10 2004/03/02 00:36:33 olle
  592. * big transformation of Tai_[const_]Symbol.Create[data]name*
  593. }