2
0

ogrel.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. {
  2. Copyright (c) 2020 by Nikolay Nikolov
  3. Contains the ASCII relocatable object file format (*.rel) reader and writer
  4. This is the object format used on the Z80 platforms.
  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 ogrel;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cclasses,globtype,
  24. { target }
  25. systems,
  26. { assembler }
  27. cpuinfo,cpubase,aasmbase,assemble,link,
  28. { output }
  29. ogbase,
  30. owbase;
  31. type
  32. TRelRelocationFlag=(
  33. rrfByte, { bit 0 }
  34. rrfSymbol, { bit 1 }
  35. rrfPcRelative, { bit 2 }
  36. rrfTwoByteObjectFormatForByteData, { bit 3 }
  37. rrfUnsignedByteData, { bit 4 }
  38. rrfPage0Reference, { bit 5 }
  39. rrfPageNNNReference, { bit 6 }
  40. rrfMSBWith2ByteMode, { bit 7 }
  41. rrfThreeByteObjectFormatForByteData, { bit 8 }
  42. rrfRealMSBForThreeByteMode, { bit 9 }
  43. rrfReserved10, { bit 10 }
  44. rrfReserved11); { bit 11 }
  45. TRelRelocationFlags=set of TRelRelocationFlag;
  46. { TRelRelocation }
  47. TRelRelocation = class(TObjRelocation)
  48. private
  49. function GetSecOrSymIdx: longint;
  50. public
  51. RelFlags: TRelRelocationFlags;
  52. HiByte: Byte;
  53. constructor CreateSymbol(ADataOffset:TObjSectionOfs;s:TObjSymbol;Atyp:TObjRelocationType);
  54. constructor CreateSection(ADataOffset:TObjSectionOfs;aobjsec:TObjSection;Atyp:TObjRelocationType);
  55. function EncodeFlags: string;
  56. property SecOrSymIdx: longint read GetSecOrSymIdx;
  57. end;
  58. { TRelObjData }
  59. TRelObjData = class(TObjData)
  60. public
  61. function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
  62. function sectiontype2align(atype:TAsmSectiontype):longint;override;
  63. procedure writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
  64. end;
  65. { TRelObjOutput }
  66. TRelObjOutput = class(tObjOutput)
  67. private
  68. procedure writeString(const S: ansistring);
  69. procedure writeLine(const S: ansistring);
  70. procedure WriteAreaContentAndRelocations(sec: TObjSection);
  71. protected
  72. function writeData(Data:TObjData):boolean;override;
  73. public
  74. constructor create(AWriter:TObjectWriter);override;
  75. end;
  76. { TRelAssembler }
  77. TRelAssembler = class(tinternalassembler)
  78. constructor create(info: pasminfo; smart:boolean);override;
  79. end;
  80. { TRelObjInput }
  81. TRelObjInput = class(TObjInput)
  82. public
  83. function ReadObjData(AReader:TObjectreader;out Data:TObjData):boolean;override;
  84. class function CanReadObjData(AReader:TObjectreader):boolean;override;
  85. end;
  86. { TIntelHexExeOutput }
  87. TIntelHexExeOutput = class(TExeOutput)
  88. protected
  89. function writeData:boolean;override;
  90. procedure DoRelocationFixup(objsec:TObjSection);override;
  91. end;
  92. implementation
  93. uses
  94. SysUtils,
  95. cutils,verbose,globals,
  96. fmodule,aasmtai,aasmdata,
  97. ogmap,owar,
  98. version
  99. ;
  100. function tohex(q: qword): string;
  101. begin
  102. result:=HexStr(q,16);
  103. while (Length(result)>1) and (result[1]='0') do
  104. delete(result,1,1);
  105. end;
  106. {*****************************************************************************
  107. TRelRelocation
  108. *****************************************************************************}
  109. function TRelRelocation.GetSecOrSymIdx: longint;
  110. begin
  111. if assigned(symbol) then
  112. result:=symbol.symidx
  113. else if assigned(objsection) then
  114. result:=objsection.SecSymIdx
  115. else
  116. internalerror(2020050502);
  117. end;
  118. constructor TRelRelocation.CreateSymbol(ADataOffset: TObjSectionOfs; s: TObjSymbol; Atyp: TObjRelocationType);
  119. begin
  120. inherited;
  121. case Atyp of
  122. RELOC_ABSOLUTE_HI8:
  123. begin
  124. size:=1;
  125. RelFlags:=[rrfSymbol,rrfByte,rrfTwoByteObjectFormatForByteData,rrfMSBWith2ByteMode];
  126. end;
  127. RELOC_ABSOLUTE_LO8:
  128. begin
  129. size:=1;
  130. RelFlags:=[rrfSymbol,rrfByte,rrfTwoByteObjectFormatForByteData];
  131. end;
  132. RELOC_ABSOLUTE:
  133. begin
  134. size:=2;
  135. RelFlags:=[rrfSymbol];
  136. end;
  137. else
  138. internalerror(2020050601);
  139. end;
  140. end;
  141. constructor TRelRelocation.CreateSection(ADataOffset: TObjSectionOfs; aobjsec: TObjSection; Atyp: TObjRelocationType);
  142. begin
  143. inherited;
  144. case Atyp of
  145. RELOC_ABSOLUTE_HI8:
  146. begin
  147. size:=1;
  148. RelFlags:=[rrfByte,rrfTwoByteObjectFormatForByteData,rrfMSBWith2ByteMode];
  149. end;
  150. RELOC_ABSOLUTE_LO8:
  151. begin
  152. size:=1;
  153. RelFlags:=[rrfByte,rrfTwoByteObjectFormatForByteData];
  154. end;
  155. RELOC_ABSOLUTE:
  156. begin
  157. size:=2;
  158. RelFlags:=[];
  159. end;
  160. else
  161. internalerror(2020050601);
  162. end;
  163. end;
  164. function TRelRelocation.EncodeFlags: string;
  165. var
  166. FlagsWord: Word;
  167. begin
  168. FlagsWord:=0;
  169. if rrfByte in RelFlags then
  170. Inc(FlagsWord,1);
  171. if rrfSymbol in RelFlags then
  172. Inc(FlagsWord,2);
  173. if rrfPcRelative in RelFlags then
  174. Inc(FlagsWord,4);
  175. if rrfTwoByteObjectFormatForByteData in RelFlags then
  176. Inc(FlagsWord,8);
  177. if rrfUnsignedByteData in RelFlags then
  178. Inc(FlagsWord,16);
  179. if rrfPage0Reference in RelFlags then
  180. Inc(FlagsWord,32);
  181. if rrfPageNNNReference in RelFlags then
  182. Inc(FlagsWord,64);
  183. if rrfMSBWith2ByteMode in RelFlags then
  184. Inc(FlagsWord,128);
  185. if rrfThreeByteObjectFormatForByteData in RelFlags then
  186. Inc(FlagsWord,256);
  187. if rrfRealMSBForThreeByteMode in RelFlags then
  188. Inc(FlagsWord,512);
  189. if rrfReserved10 in RelFlags then
  190. Inc(FlagsWord,1024);
  191. if rrfReserved11 in RelFlags then
  192. Inc(FlagsWord,2048);
  193. if (FlagsWord<=255) and ((FlagsWord and $F0)<>$F0) then
  194. Result:=HexStr(FlagsWord,2)
  195. else
  196. Result:=HexStr($F0 or Byte(FlagsWord shr 8),2)+' '+HexStr(Byte(FlagsWord),2);
  197. end;
  198. {*****************************************************************************
  199. TRelObjData
  200. *****************************************************************************}
  201. function TRelObjData.sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string;
  202. const
  203. secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
  204. '_CODE',
  205. '_DATA',
  206. '_DATA',
  207. '.rodata',
  208. '.bss',
  209. '.threadvar',
  210. '.pdata',
  211. '', { stubs }
  212. '__DATA,__nl_symbol_ptr',
  213. '__DATA,__la_symbol_ptr',
  214. '__DATA,__mod_init_func',
  215. '__DATA,__mod_term_func',
  216. '.stab',
  217. '.stabstr',
  218. '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
  219. '.eh_frame',
  220. '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
  221. '.fpc',
  222. '.toc',
  223. '.init',
  224. '.fini',
  225. '.objc_class',
  226. '.objc_meta_class',
  227. '.objc_cat_cls_meth',
  228. '.objc_cat_inst_meth',
  229. '.objc_protocol',
  230. '.objc_string_object',
  231. '.objc_cls_meth',
  232. '.objc_inst_meth',
  233. '.objc_cls_refs',
  234. '.objc_message_refs',
  235. '.objc_symbols',
  236. '.objc_category',
  237. '.objc_class_vars',
  238. '.objc_instance_vars',
  239. '.objc_module_info',
  240. '.objc_class_names',
  241. '.objc_meth_var_types',
  242. '.objc_meth_var_names',
  243. '.objc_selector_strs',
  244. '.objc_protocol_ext',
  245. '.objc_class_ext',
  246. '.objc_property',
  247. '.objc_image_info',
  248. '.objc_cstring_object',
  249. '.objc_sel_fixup',
  250. '__DATA,__objc_data',
  251. '__DATA,__objc_const',
  252. '.objc_superrefs',
  253. '__DATA, __datacoal_nt,coalesced',
  254. '.objc_classlist',
  255. '.objc_nlclasslist',
  256. '.objc_catlist',
  257. '.obcj_nlcatlist',
  258. '.objc_protolist',
  259. '.stack',
  260. '.heap',
  261. '.gcc_except_table',
  262. '.ARM.attributes'
  263. );
  264. begin
  265. result:=secnames[atype];
  266. end;
  267. function TRelObjData.sectiontype2align(atype:TAsmSectiontype):longint;
  268. begin
  269. result:=1;
  270. end;
  271. procedure TRelObjData.writeReloc(Data: TRelocDataInt; len: aword; p: TObjSymbol; Reloctype: TObjRelocationType);
  272. var
  273. bytes: array [0..1] of Byte;
  274. symaddr: QWord;
  275. objreloc: TRelRelocation;
  276. begin
  277. if CurrObjSec=nil then
  278. internalerror(200403072);
  279. objreloc:=nil;
  280. if assigned(p) then
  281. begin
  282. { real address of the symbol }
  283. symaddr:=p.address;
  284. if p.bind=AB_EXTERNAL then
  285. begin
  286. objreloc:=TRelRelocation.CreateSymbol(CurrObjSec.Size,p,Reloctype);
  287. if Reloctype in [RELOC_ABSOLUTE_HI8,RELOC_ABSOLUTE_LO8] then
  288. objreloc.HiByte:=Byte(Data shr 8);
  289. CurrObjSec.ObjRelocations.Add(objreloc);
  290. end
  291. { relative relocations within the same section can be calculated directly,
  292. without the need to emit a relocation entry }
  293. else if (p.objsection=CurrObjSec) and
  294. (p.bind<>AB_COMMON) and
  295. (Reloctype=RELOC_RELATIVE) then
  296. begin
  297. data:=data+symaddr-len-CurrObjSec.Size;
  298. end
  299. else
  300. begin
  301. objreloc:=TRelRelocation.CreateSection(CurrObjSec.Size,p.objsection,Reloctype);
  302. inc(data,symaddr);
  303. if Reloctype in [RELOC_ABSOLUTE_HI8,RELOC_ABSOLUTE_LO8] then
  304. objreloc.HiByte:=Byte(Data shr 8);
  305. CurrObjSec.ObjRelocations.Add(objreloc);
  306. end;
  307. end;
  308. case len of
  309. 2:
  310. begin
  311. bytes[0]:=Byte(Data);
  312. bytes[1]:=Byte(Data shr 8);
  313. writebytes(bytes,2);
  314. end;
  315. 1:
  316. begin
  317. bytes[0]:=Byte(Data);
  318. writebytes(bytes,1);
  319. end;
  320. else
  321. internalerror(2020050423);
  322. end;
  323. end;
  324. {*****************************************************************************
  325. TRelObjOutput
  326. *****************************************************************************}
  327. procedure TRelObjOutput.writeString(const S: ansistring);
  328. begin
  329. FWriter.write(S[1],Length(S));
  330. end;
  331. procedure TRelObjOutput.writeLine(const S: ansistring);
  332. begin
  333. writeString(S+#10)
  334. end;
  335. procedure TRelObjOutput.WriteAreaContentAndRelocations(sec: TObjSection);
  336. const
  337. MaxChunkSize={14}7;
  338. var
  339. ChunkStart,ChunkLen, i: LongWord;
  340. ChunkFixupStart,ChunkFixupEnd, j, st_ofs: Integer;
  341. st,sr: ansistring;
  342. buf: array [0..MaxChunkSize-1] of Byte;
  343. reloc: TRelRelocation;
  344. begin
  345. if (oso_data in sec.SecOptions) and (sec.Data=nil) then
  346. internalerror(200403073);
  347. if assigned(sec.data) then
  348. sec.data.seek(0);
  349. ChunkFixupStart:=0;
  350. ChunkFixupEnd:=-1;
  351. ChunkStart:=0;
  352. ChunkLen:=Min(MaxChunkSize, sec.size-ChunkStart);
  353. while ChunkLen>0 do
  354. begin
  355. { find last fixup in the chunk }
  356. while (ChunkFixupEnd<(sec.ObjRelocations.Count-1)) and
  357. (TRelRelocation(sec.ObjRelocations[ChunkFixupEnd+1]).DataOffset<(ChunkStart+ChunkLen)) do
  358. inc(ChunkFixupEnd);
  359. { check if last chunk is crossing the chunk boundary, and trim ChunkLen if necessary }
  360. if (ChunkFixupEnd>=ChunkFixupStart) and
  361. ((TRelRelocation(sec.ObjRelocations[ChunkFixupEnd]).DataOffset+
  362. TRelRelocation(sec.ObjRelocations[ChunkFixupEnd]).size)>(ChunkStart+ChunkLen)) then
  363. begin
  364. ChunkLen:=TRelRelocation(sec.ObjRelocations[ChunkFixupEnd]).DataOffset-ChunkStart;
  365. Dec(ChunkFixupEnd);
  366. end;
  367. if ChunkLen>SizeOf(buf) then
  368. internalerror(2020050501);
  369. st:='T '+HexStr(Byte(ChunkStart),2)+' '+HexStr(Byte(ChunkStart shr 8),2);
  370. sr:='R 00 00 '+HexStr(Byte(sec.SecSymIdx),2)+' '+HexStr(Byte(sec.SecSymIdx shr 8),2);
  371. if assigned(sec.Data) then
  372. sec.Data.read(buf,ChunkLen)
  373. else
  374. FillChar(buf,ChunkLen,0);
  375. st_ofs:=1;
  376. { relocations present in the current chunk? }
  377. if ChunkFixupEnd>=ChunkFixupStart then
  378. begin
  379. j:=ChunkFixupStart;
  380. reloc:=TRelRelocation(sec.ObjRelocations[j]);
  381. end
  382. else
  383. begin
  384. j:=-1;
  385. reloc:=nil;
  386. end;
  387. for i:=0 to ChunkLen-1 do
  388. begin
  389. st:=st+' '+HexStr(buf[i],2);
  390. Inc(st_ofs);
  391. if assigned(reloc) then
  392. begin
  393. { advance to the current relocation }
  394. while (reloc.DataOffset<(ChunkStart+i)) and (j<ChunkFixupEnd) do
  395. begin
  396. Inc(j);
  397. reloc:=TRelRelocation(sec.ObjRelocations[j]);
  398. end;
  399. { is there a relocation at the current position? }
  400. if reloc.DataOffset=(ChunkStart+i) then
  401. begin
  402. sr:=sr+' '+reloc.EncodeFlags+' '+HexStr(st_ofs,2)+' '+HexStr(Byte(reloc.SecOrSymIdx),2)+' '+HexStr(Byte(reloc.SecOrSymIdx shr 8),2);
  403. if reloc.typ in [RELOC_ABSOLUTE_HI8,RELOC_ABSOLUTE_LO8] then
  404. begin
  405. st:=st+' '+HexStr(reloc.HiByte,2);
  406. Inc(st_ofs);
  407. end;
  408. end;
  409. end;
  410. end;
  411. writeLine(st);
  412. writeLine(sr);
  413. { prepare next chunk }
  414. Inc(ChunkStart, ChunkLen);
  415. ChunkLen:=Min(MaxChunkSize, sec.size-ChunkStart);
  416. ChunkFixupStart:=ChunkFixupEnd+1;
  417. end;
  418. end;
  419. function TRelObjOutput.writeData(Data: TObjData): boolean;
  420. var
  421. global_symbols_count: Integer = 0;
  422. secidx, idx, i, j: Integer;
  423. objsym: TObjSymbol;
  424. objsec: TObjSection;
  425. begin
  426. global_symbols_count:=0;
  427. for i:=0 to Data.ObjSymbolList.Count-1 do
  428. begin
  429. objsym:=TObjSymbol(Data.ObjSymbolList[i]);
  430. if objsym.bind in [AB_EXTERNAL,AB_GLOBAL] then
  431. Inc(global_symbols_count);
  432. end;
  433. writeLine('XL2');
  434. writeLine('H '+tohex(data.ObjSectionList.Count)+' areas '+tohex(global_symbols_count)+' global symbols');
  435. idx:=0;
  436. for i:=0 to Data.ObjSymbolList.Count-1 do
  437. begin
  438. objsym:=TObjSymbol(Data.ObjSymbolList[i]);
  439. if objsym.bind=AB_EXTERNAL then
  440. begin
  441. writeLine('S '+ApplyAsmSymbolRestrictions(objsym.Name)+' Ref0000');
  442. objsym.symidx:=idx;
  443. Inc(idx);
  444. end;
  445. end;
  446. secidx:=0;
  447. for i:=0 to Data.ObjSectionList.Count-1 do
  448. begin
  449. objsec:=TObjSection(Data.ObjSectionList[i]);
  450. writeLine('A '+objsec.Name+' size '+tohex(objsec.Size)+' flags 0 addr 0');
  451. objsec.SecSymIdx:=secidx;
  452. Inc(secidx);
  453. for j:=0 to Data.ObjSymbolList.Count-1 do
  454. begin
  455. objsym:=TObjSymbol(Data.ObjSymbolList[j]);
  456. if (objsym.bind=AB_GLOBAL) and (objsym.objsection=objsec) then
  457. begin
  458. writeLine('S '+ApplyAsmSymbolRestrictions(objsym.Name)+' Def'+HexStr(objsym.offset,4));
  459. objsym.symidx:=idx;
  460. Inc(idx);
  461. end;
  462. end;
  463. end;
  464. for i:=0 to Data.ObjSectionList.Count-1 do
  465. begin
  466. objsec:=TObjSection(Data.ObjSectionList[i]);
  467. WriteAreaContentAndRelocations(objsec);
  468. end;
  469. result:=true;
  470. end;
  471. constructor TRelObjOutput.create(AWriter: TObjectWriter);
  472. begin
  473. inherited;
  474. cobjdata:=TRelObjData;
  475. end;
  476. {*****************************************************************************
  477. TRelAssembler
  478. *****************************************************************************}
  479. constructor TRelAssembler.create(info: pasminfo; smart: boolean);
  480. begin
  481. inherited;
  482. CObjOutput:=TRelObjOutput;
  483. CInternalAr:=tarobjectwriter;
  484. end;
  485. {*****************************************************************************
  486. TRelObjInput
  487. *****************************************************************************}
  488. function TRelObjInput.ReadObjData(AReader: TObjectreader; out Data: TObjData): boolean;
  489. begin
  490. result:=false;
  491. end;
  492. class function TRelObjInput.CanReadObjData(AReader: TObjectreader): boolean;
  493. const
  494. MaxBufSize=512;
  495. var
  496. Buf: array [0..MaxBufSize-1] of Char;
  497. BufSize: Integer = 0;
  498. BufPos: Integer = 0;
  499. function FillBuf: boolean;
  500. begin
  501. BufPos:=0;
  502. BufSize:=min(AReader.size-AReader.Pos,MaxBufSize);
  503. if BufSize>0 then
  504. result:=AReader.read(Buf,BufSize)
  505. else
  506. result:=true;
  507. end;
  508. function AtEndOfBuf: boolean;
  509. begin
  510. result:=BufPos=BufSize;
  511. end;
  512. function AtEoF: boolean;
  513. begin
  514. result:=AtEndOfBuf and (AReader.Pos=AReader.size);
  515. end;
  516. function ReadChar(out c: char): boolean;
  517. begin
  518. c:=#0;
  519. if AtEndOfBuf then
  520. begin
  521. result:=FillBuf;
  522. if not result then
  523. exit;
  524. end;
  525. if not AtEndOfBuf then
  526. begin
  527. c:=Buf[BufPos];
  528. Inc(BufPos);
  529. result:=true;
  530. end
  531. else
  532. result:=false;
  533. end;
  534. function PeekChar(out c: char): boolean;
  535. begin
  536. c:=#0;
  537. if AtEndOfBuf then
  538. begin
  539. result:=FillBuf;
  540. if not result then
  541. exit;
  542. end;
  543. if not AtEndOfBuf then
  544. begin
  545. c:=Buf[BufPos];
  546. result:=true;
  547. end
  548. else
  549. result:=false;
  550. end;
  551. function ReadLine(out s: string): boolean;
  552. var
  553. c: Char;
  554. begin
  555. s:='';
  556. if AtEoF then
  557. begin
  558. result:=false;
  559. exit;
  560. end;
  561. repeat
  562. if not AtEoF then
  563. begin
  564. if not ReadChar(c) then
  565. begin
  566. result:=false;
  567. exit;
  568. end;
  569. if not (c in [#13,#10]) then
  570. s:=s+c;
  571. end;
  572. until (c in [#13,#10]) or AtEoF;
  573. if (c=#13) and not AtEoF then
  574. begin
  575. if not PeekChar(c) then
  576. begin
  577. result:=false;
  578. exit;
  579. end;
  580. if c=#10 then
  581. begin
  582. if not ReadChar(c) then
  583. begin
  584. result:=false;
  585. exit;
  586. end;
  587. end;
  588. end;
  589. result:=true;
  590. end;
  591. var
  592. s: string;
  593. begin
  594. result:=false;
  595. while not AtEoF do
  596. begin
  597. if not ReadLine(s) then
  598. exit;
  599. s:=Trim(s);
  600. if s<>'' then
  601. begin
  602. result:=s='XL2';
  603. exit;
  604. end;
  605. end;
  606. end;
  607. {*****************************************************************************
  608. TIntelHexExeOutput
  609. *****************************************************************************}
  610. function TIntelHexExeOutput.writeData: boolean;
  611. begin
  612. result:=false;
  613. end;
  614. procedure TIntelHexExeOutput.DoRelocationFixup(objsec: TObjSection);
  615. begin
  616. end;
  617. {*****************************************************************************
  618. Initialize
  619. *****************************************************************************}
  620. const
  621. as_z80_rel_info : tasminfo =
  622. (
  623. id : as_z80_rel;
  624. idtxt : 'REL';
  625. asmbin : '';
  626. asmcmd : '';
  627. supported_targets : [system_z80_embedded,system_z80_zxspectrum];
  628. flags : [af_outputbinary,af_smartlink_sections];
  629. labelprefix : '..@';
  630. labelmaxlen : 79;
  631. comment : '; ';
  632. dollarsign: '$';
  633. );
  634. initialization
  635. RegisterAssembler(as_z80_rel_info,TRelAssembler);
  636. end.