aasmbase.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements an abstract asmoutput class for all processor types
  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. {# @abstract(This unit implements an abstract asm output class for all processor types)
  19. This unit implements an abstract assembler output class for all processors, these
  20. are then overriden for each assembler writer to actually write the data in these
  21. classes to an assembler file.
  22. }
  23. unit aasmbase;
  24. {$i fpcdefs.inc}
  25. interface
  26. uses
  27. cutils,cclasses,
  28. globtype,globals,systems;
  29. { asm symbol functions }
  30. type
  31. TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
  32. TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION);
  33. TAsmRelocationType = (RELOC_ABSOLUTE,RELOC_RELATIVE,RELOC_RVA);
  34. TAsmSectionSizes = array[TSection] of longint;
  35. TAsmSymbol = class(TNamedIndexItem)
  36. defbind,
  37. currbind : TAsmsymbind;
  38. typ : TAsmsymtype;
  39. { the next fields are filled in the binary writer }
  40. section : TSection;
  41. address,
  42. size : longint;
  43. { this need to be incremented with every symbol loading into the
  44. paasmoutput, thus in loadsym/loadref/const_symbol (PFV) }
  45. refs : longint;
  46. {# Alternate symbol which can be used for 'renaming' needed for
  47. inlining }
  48. altsymbol : tasmsymbol;
  49. objectdata : pointer;
  50. {# TRUE if the symbol is local for a procedure/function }
  51. proclocal : boolean;
  52. {# Is the symbol in the used list }
  53. inusedlist : boolean;
  54. { assembler pass label is set, used for detecting multiple labels }
  55. pass : byte;
  56. constructor create(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
  57. procedure reset;
  58. function is_used:boolean;
  59. procedure setaddress(_pass:byte;sec:TSection;offset,len:longint);
  60. procedure GenerateAltSymbol;
  61. end;
  62. TAsmLabel = class(TAsmSymbol)
  63. { this is set by the tai_label.Init }
  64. is_set,
  65. { is the label only there for getting an address (e.g. for i/o }
  66. { checks -> true) or is it a jump target (false) }
  67. is_addr : boolean;
  68. labelnr : longint;
  69. constructor create;
  70. constructor createdata;
  71. constructor createaddr;
  72. function getname:string;override;
  73. end;
  74. TAsmRelocation = class(TLinkedListItem)
  75. address,
  76. orgsize : longint; { original size of the symbol to relocate, required for COFF }
  77. symbol : tasmsymbol;
  78. section : TSection; { only used if symbol=nil }
  79. typ : TAsmRelocationType;
  80. constructor CreateSymbol(Aaddress:longint;s:Tasmsymbol;Atyp:TAsmRelocationType);
  81. constructor CreateSymbolSize(Aaddress:longint;s:Tasmsymbol;Aorgsize:longint;Atyp:TAsmRelocationType);
  82. constructor CreateSection(Aaddress:longint;sec:TSection;Atyp:TAsmRelocationType);
  83. end;
  84. TAsmSection = class(TLinkedListItem)
  85. name : string[32];
  86. secsymidx : longint; { index for the section in symtab }
  87. addralign : longint; { alignment of the section }
  88. flags : cardinal; { section flags }
  89. { size of the data and in the file }
  90. dataalignbytes : longint;
  91. data : TDynamicArray;
  92. datasize : longint;
  93. datapos : longint;
  94. { size and position in memory, set by seTSectionsize }
  95. memsize,
  96. mempos : longint;
  97. { relocation }
  98. relocations : TLinkedList;
  99. constructor create(const Aname:string;Aalign:longint;alloconly:boolean);
  100. destructor destroy;override;
  101. function write(var d;l:longint):longint;
  102. function writestr(const s:string):longint;
  103. procedure writealign(l:longint);
  104. function aligneddatasize:longint;
  105. procedure alignsection;
  106. procedure alloc(l:longint);
  107. procedure addsymreloc(ofs:longint;p:tasmsymbol;relative:TAsmRelocationType);
  108. procedure addsectionreloc(ofs:longint;sec:TSection;relative:TAsmRelocationType);
  109. end;
  110. TAsmObjectData = class(TLinkedListItem)
  111. name : string[80];
  112. currsec : TSection;
  113. sects : array[TSection] of TAsmSection;
  114. symbols : tindexarray;
  115. constructor create(const n:string);
  116. destructor destroy;override;
  117. procedure createsection(sec:TSection);virtual;
  118. procedure defaulTSection(sec:TSection);
  119. function sectionsize(s:TSection):longint;
  120. function currsectionsize:longint;
  121. procedure seTSectionsizes(var s:TAsmSectionSizes);virtual;
  122. procedure alloc(len:longint);
  123. procedure allocalign(len:longint);
  124. procedure writebytes(var data;len:longint);
  125. procedure writereloc(data,len:longint;p:tasmsymbol;relative:TAsmRelocationType);virtual;abstract;
  126. procedure writesymbol(p:tasmsymbol);virtual;abstract;
  127. procedure writestabs(section:TSection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
  128. procedure writesymstabs(section:TSection;offset:longint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
  129. procedure fixuprelocs;virtual;
  130. end;
  131. TAsmObjectAlloc = class
  132. currsec : TSection;
  133. secsize : TAsmSectionSizes;
  134. constructor create;
  135. destructor destroy;override;
  136. procedure seTSection(sec:TSection);
  137. function sectionsize:longint;
  138. procedure sectionalloc(l:longint);
  139. procedure sectionalign(l:longint);
  140. procedure staballoc(p:pchar);
  141. procedure reseTSections;
  142. end;
  143. TAsmObjectDataclass = class of TAsmObjectAlloc;
  144. var
  145. { asm symbol list }
  146. asmsymbollist : tdictionary;
  147. usedasmsymbollist : tsinglelist;
  148. objectdata : TAsmObjectData;
  149. const
  150. nextaltnr : longint = 1;
  151. nextlabelnr : longint = 1;
  152. {# create a new assembler label }
  153. procedure getlabel(var l : tasmlabel);
  154. { make l as a new label and flag is_addr }
  155. procedure getaddrlabel(var l : tasmlabel);
  156. { make l as a new label and flag is_data }
  157. procedure getdatalabel(var l : tasmlabel);
  158. {# return a label number }
  159. procedure getlabelnr(var l : longint);
  160. function newasmsymbol(const s : string) : tasmsymbol;
  161. function newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:TAsmsymtype) : tasmsymbol;
  162. function getasmsymbol(const s : string) : tasmsymbol;
  163. function renameasmsymbol(const sold, snew : string):tasmsymbol;
  164. procedure CreateUsedAsmSymbolList;
  165. procedure DestroyUsedAsmSymbolList;
  166. procedure UsedAsmSymbolListInsert(p:tasmsymbol);
  167. procedure UsedAsmSymbolListReset;
  168. procedure UsedAsmSymbolListResetAltSym;
  169. procedure UsedAsmSymbolListCheckUndefined;
  170. implementation
  171. uses
  172. {$ifdef delphi}
  173. sysutils,
  174. {$else}
  175. strings,
  176. {$endif}
  177. fmodule,verbose;
  178. const
  179. symbolsgrow = 100;
  180. {*****************************************************************************
  181. TAsmSymbol
  182. *****************************************************************************}
  183. constructor tasmsymbol.create(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
  184. begin;
  185. inherited createname(s);
  186. reset;
  187. defbind:=_bind;
  188. typ:=_typ;
  189. inusedlist:=false;
  190. pass:=255;
  191. { mainly used to remove unused labels from the codesegment }
  192. refs:=0;
  193. end;
  194. procedure tasmsymbol.GenerateAltSymbol;
  195. begin
  196. if not assigned(altsymbol) then
  197. begin
  198. altsymbol:=tasmsymbol.create(name+'_'+tostr(nextaltnr),defbind,typ);
  199. { also copy the amount of references }
  200. altsymbol.refs:=refs;
  201. inc(nextaltnr);
  202. end;
  203. end;
  204. procedure tasmsymbol.reset;
  205. begin
  206. { reset section info }
  207. section:=sec_none;
  208. address:=0;
  209. size:=0;
  210. indexnr:=-1;
  211. pass:=255;
  212. currbind:=AB_EXTERNAL;
  213. proclocal:=false;
  214. end;
  215. function tasmsymbol.is_used:boolean;
  216. begin
  217. is_used:=(refs>0);
  218. end;
  219. procedure tasmsymbol.setaddress(_pass:byte;sec:TSection;offset,len:longint);
  220. begin
  221. if (_pass=pass) then
  222. begin
  223. Message1(asmw_e_duplicate_label,name);
  224. exit;
  225. end;
  226. pass:=_pass;
  227. section:=sec;
  228. address:=offset;
  229. size:=len;
  230. { when the bind was reset to External, set it back to the default
  231. bind it got when defined }
  232. if (currbind=AB_EXTERNAL) and (defbind<>AB_NONE) then
  233. currbind:=defbind;
  234. end;
  235. {*****************************************************************************
  236. TAsmLabel
  237. *****************************************************************************}
  238. constructor tasmlabel.create;
  239. begin;
  240. labelnr:=nextlabelnr;
  241. inc(nextlabelnr);
  242. inherited create(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_FUNCTION);
  243. proclocal:=true;
  244. is_set:=false;
  245. is_addr := false;
  246. end;
  247. constructor tasmlabel.createdata;
  248. begin;
  249. labelnr:=nextlabelnr;
  250. inc(nextlabelnr);
  251. if (cs_create_smart in aktmoduleswitches) or
  252. target_asm.labelprefix_only_inside_procedure then
  253. inherited create('_$'+current_module.modulename^+'$_L'+tostr(labelnr),AB_GLOBAL,AT_DATA)
  254. else
  255. inherited create(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_DATA);
  256. is_set:=false;
  257. is_addr := false;
  258. { write it always }
  259. refs:=1;
  260. end;
  261. constructor tasmlabel.createaddr;
  262. begin;
  263. create;
  264. is_addr := true;
  265. end;
  266. function tasmlabel.getname:string;
  267. begin
  268. getname:=inherited getname;
  269. inc(refs);
  270. end;
  271. {****************************************************************************
  272. TAsmObjectAlloc
  273. ****************************************************************************}
  274. constructor TAsmObjectAlloc.create;
  275. begin
  276. end;
  277. destructor TAsmObjectAlloc.destroy;
  278. begin
  279. end;
  280. procedure TAsmObjectAlloc.seTSection(sec:TSection);
  281. begin
  282. currsec:=sec;
  283. end;
  284. procedure TAsmObjectAlloc.reseTSections;
  285. begin
  286. FillChar(secsize,sizeof(secsize),0);
  287. end;
  288. procedure TAsmObjectAlloc.sectionalloc(l:longint);
  289. begin
  290. inc(secsize[currsec],l);
  291. end;
  292. procedure TAsmObjectAlloc.sectionalign(l:longint);
  293. begin
  294. if (secsize[currsec] mod l)<>0 then
  295. inc(secsize[currsec],l-(secsize[currsec] mod l));
  296. end;
  297. procedure TAsmObjectAlloc.staballoc(p:pchar);
  298. begin
  299. inc(secsize[sec_stab]);
  300. if assigned(p) and (p[0]<>#0) then
  301. inc(secsize[sec_stabstr],strlen(p)+1);
  302. end;
  303. function TAsmObjectAlloc.sectionsize:longint;
  304. begin
  305. sectionsize:=secsize[currsec];
  306. end;
  307. {****************************************************************************
  308. TAsmRelocation
  309. ****************************************************************************}
  310. constructor TAsmRelocation.CreateSymbol(Aaddress:longint;s:Tasmsymbol;Atyp:TAsmRelocationType);
  311. begin
  312. Address:=Aaddress;
  313. Symbol:=s;
  314. OrgSize:=0;
  315. Section:=Sec_none;
  316. Typ:=Atyp;
  317. end;
  318. constructor TAsmRelocation.CreateSymbolSize(Aaddress:longint;s:Tasmsymbol;Aorgsize:longint;Atyp:TAsmRelocationType);
  319. begin
  320. Address:=Aaddress;
  321. Symbol:=s;
  322. OrgSize:=Aorgsize;
  323. Section:=Sec_none;
  324. Typ:=Atyp;
  325. end;
  326. constructor TAsmRelocation.CreateSection(Aaddress:longint;sec:TSection;Atyp:TAsmRelocationType);
  327. begin
  328. Address:=Aaddress;
  329. Symbol:=nil;
  330. OrgSize:=0;
  331. Section:=sec;
  332. Typ:=Atyp;
  333. end;
  334. {****************************************************************************
  335. TAsmSection
  336. ****************************************************************************}
  337. constructor TAsmSection.create(const Aname:string;Aalign:longint;alloconly:boolean);
  338. begin
  339. inherited create;
  340. name:=Aname;
  341. secsymidx:=0;
  342. addralign:=Aalign;
  343. { data }
  344. datasize:=0;
  345. datapos:=0;
  346. if alloconly then
  347. data:=nil
  348. else
  349. Data:=TDynamicArray.Create(8192);
  350. { position }
  351. mempos:=0;
  352. memsize:=0;
  353. { relocation }
  354. relocations:=TLinkedList.Create;
  355. end;
  356. destructor TAsmSection.destroy;
  357. begin
  358. if assigned(Data) then
  359. Data.Free;
  360. end;
  361. function TAsmSection.write(var d;l:longint):longint;
  362. begin
  363. write:=datasize;
  364. if not assigned(Data) then
  365. Internalerror(3334441);
  366. Data.write(d,l);
  367. inc(datasize,l);
  368. end;
  369. function TAsmSection.writestr(const s:string):longint;
  370. begin
  371. writestr:=datasize;
  372. if not assigned(Data) then
  373. Internalerror(3334441);
  374. Data.write(s[1],length(s));
  375. inc(datasize,length(s));
  376. end;
  377. procedure TAsmSection.writealign(l:longint);
  378. var
  379. i : longint;
  380. empty : array[0..63] of char;
  381. begin
  382. { no alignment needed for 0 or 1 }
  383. if l<=1 then
  384. exit;
  385. i:=datasize mod l;
  386. if i>0 then
  387. begin
  388. if assigned(data) then
  389. begin
  390. fillchar(empty,sizeof(empty),0);
  391. Data.write(empty,l-i);
  392. end;
  393. inc(datasize,l-i);
  394. end;
  395. end;
  396. function TAsmSection.aligneddatasize:longint;
  397. begin
  398. aligneddatasize:=align(datasize,addralign);
  399. end;
  400. procedure TAsmSection.alignsection;
  401. begin
  402. writealign(addralign);
  403. end;
  404. procedure TAsmSection.alloc(l:longint);
  405. begin
  406. if assigned(Data) then
  407. Internalerror(3334442);
  408. inc(datasize,l);
  409. end;
  410. procedure TAsmSection.addsymreloc(ofs:longint;p:tasmsymbol;relative:TAsmRelocationType);
  411. var
  412. r : TAsmRelocation;
  413. begin
  414. r:=TAsmRelocation.Create;
  415. r.address:=ofs;
  416. r.orgsize:=0;
  417. r.symbol:=p;
  418. r.section:=sec_none;
  419. r.typ:=relative;
  420. relocations.concat(r);
  421. end;
  422. procedure TAsmSection.addsectionreloc(ofs:longint;sec:TSection;relative:TAsmRelocationType);
  423. var
  424. r : TAsmRelocation;
  425. begin
  426. r:=TAsmRelocation.Create;
  427. r.address:=ofs;
  428. r.symbol:=nil;
  429. r.orgsize:=0;
  430. r.section:=sec;
  431. r.typ:=relative;
  432. relocations.concat(r);
  433. end;
  434. {****************************************************************************
  435. TAsmObjectData
  436. ****************************************************************************}
  437. constructor TAsmObjectData.create(const n:string);
  438. begin
  439. inherited create;
  440. name:=n;
  441. { sections }
  442. FillChar(Sects,sizeof(Sects),0);
  443. { symbols }
  444. symbols:=tindexarray.create(symbolsgrow);
  445. symbols.noclear:=true;
  446. end;
  447. destructor TAsmObjectData.destroy;
  448. var
  449. sec : TSection;
  450. begin
  451. { free memory }
  452. for sec:=low(TSection) to high(TSection) do
  453. if assigned(sects[sec]) then
  454. sects[sec].free;
  455. symbols.free;
  456. end;
  457. procedure TAsmObjectData.createsection(sec:TSection);
  458. begin
  459. sects[sec]:=TAsmSection.create(target_asm.secnames[sec],1,(sec=sec_bss));
  460. end;
  461. function TAsmObjectData.sectionsize(s:TSection):longint;
  462. begin
  463. if assigned(sects[s]) then
  464. sectionsize:=sects[s].datasize
  465. else
  466. sectionsize:=0;
  467. end;
  468. function TAsmObjectData.currsectionsize:longint;
  469. begin
  470. if assigned(sects[currsec]) then
  471. currsectionsize:=sects[currsec].datasize
  472. else
  473. currsectionsize:=0;
  474. end;
  475. procedure TAsmObjectData.seTSectionsizes(var s:TAsmSectionSizes);
  476. begin
  477. end;
  478. procedure TAsmObjectData.defaulTSection(sec:TSection);
  479. begin
  480. currsec:=sec;
  481. end;
  482. procedure TAsmObjectData.writebytes(var data;len:longint);
  483. begin
  484. if not assigned(sects[currsec]) then
  485. createsection(currsec);
  486. sects[currsec].write(data,len);
  487. end;
  488. procedure TAsmObjectData.alloc(len:longint);
  489. begin
  490. if not assigned(sects[currsec]) then
  491. createsection(currsec);
  492. sects[currsec].alloc(len);
  493. end;
  494. procedure TAsmObjectData.allocalign(len:longint);
  495. var
  496. modulo : longint;
  497. begin
  498. if not assigned(sects[currsec]) then
  499. createsection(currsec);
  500. modulo:=sects[currsec].datasize mod len;
  501. if modulo > 0 then
  502. sects[currsec].alloc(len-modulo);
  503. end;
  504. procedure TAsmObjectData.fixuprelocs;
  505. begin
  506. { no relocation support by default }
  507. end;
  508. {*****************************************************************************
  509. AsmSymbolList helpers
  510. *****************************************************************************}
  511. function newasmsymbol(const s : string) : tasmsymbol;
  512. var
  513. hp : tasmsymbol;
  514. begin
  515. hp:=tasmsymbol(asmsymbollist.search(s));
  516. if not assigned(hp) then
  517. begin
  518. { Not found, insert it as an External }
  519. hp:=tasmsymbol.create(s,AB_EXTERNAL,AT_FUNCTION);
  520. asmsymbollist.insert(hp);
  521. end;
  522. newasmsymbol:=hp;
  523. end;
  524. function newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:Tasmsymtype) : tasmsymbol;
  525. var
  526. hp : tasmsymbol;
  527. begin
  528. hp:=tasmsymbol(asmsymbollist.search(s));
  529. if assigned(hp) then
  530. hp.defbind:=_bind
  531. else
  532. begin
  533. { Not found, insert it as an External }
  534. hp:=tasmsymbol.create(s,_bind,_typ);
  535. asmsymbollist.insert(hp);
  536. end;
  537. newasmsymboltype:=hp;
  538. end;
  539. function getasmsymbol(const s : string) : tasmsymbol;
  540. begin
  541. getasmsymbol:=tasmsymbol(asmsymbollist.search(s));
  542. end;
  543. { renames an asmsymbol }
  544. function renameasmsymbol(const sold, snew : string):tasmsymbol;
  545. begin
  546. renameasmsymbol:=tasmsymbol(asmsymbollist.rename(sold,snew));
  547. end;
  548. {*****************************************************************************
  549. Used AsmSymbolList
  550. *****************************************************************************}
  551. procedure CreateUsedAsmSymbolList;
  552. begin
  553. if assigned(usedasmsymbollist) then
  554. internalerror(78455782);
  555. usedasmsymbollist:=TSingleList.create;
  556. end;
  557. procedure DestroyUsedAsmSymbolList;
  558. begin
  559. usedasmsymbollist.destroy;
  560. usedasmsymbollist:=nil;
  561. end;
  562. procedure UsedAsmSymbolListInsert(p:tasmsymbol);
  563. begin
  564. if not p.inusedlist then
  565. usedasmsymbollist.insert(p);
  566. p.inusedlist:=true;
  567. end;
  568. procedure UsedAsmSymbolListReset;
  569. var
  570. hp : tasmsymbol;
  571. begin
  572. hp:=tasmsymbol(usedasmsymbollist.first);
  573. while assigned(hp) do
  574. begin
  575. with hp do
  576. begin
  577. reset;
  578. inusedlist:=false;
  579. end;
  580. hp:=tasmsymbol(hp.listnext);
  581. end;
  582. end;
  583. procedure UsedAsmSymbolListResetAltSym;
  584. var
  585. hp : tasmsymbol;
  586. begin
  587. hp:=tasmsymbol(usedasmsymbollist.first);
  588. while assigned(hp) do
  589. begin
  590. with hp do
  591. begin
  592. altsymbol:=nil;
  593. inusedlist:=false;
  594. end;
  595. hp:=tasmsymbol(hp.listnext);
  596. end;
  597. end;
  598. procedure UsedAsmSymbolListCheckUndefined;
  599. var
  600. hp : tasmsymbol;
  601. begin
  602. hp:=tasmsymbol(usedasmsymbollist.first);
  603. while assigned(hp) do
  604. begin
  605. with hp do
  606. begin
  607. if (refs>0) and
  608. (section=Sec_none) and
  609. not(currbind in [AB_EXTERNAL,AB_COMMON]) then
  610. Message1(asmw_e_undefined_label,name);
  611. end;
  612. hp:=tasmsymbol(hp.listnext);
  613. end;
  614. end;
  615. {*****************************************************************************
  616. Label Helpers
  617. *****************************************************************************}
  618. procedure getlabel(var l : tasmlabel);
  619. begin
  620. l:=tasmlabel.create;
  621. asmsymbollist.insert(l);
  622. end;
  623. procedure getdatalabel(var l : tasmlabel);
  624. begin
  625. l:=tasmlabel.createdata;
  626. asmsymbollist.insert(l);
  627. end;
  628. procedure getaddrlabel(var l : tasmlabel);
  629. begin
  630. l:=tasmlabel.createaddr;
  631. asmsymbollist.insert(l);
  632. end;
  633. procedure getlabelnr(var l : longint);
  634. begin
  635. l:=nextlabelnr;
  636. inc(nextlabelnr);
  637. end;
  638. end.
  639. {
  640. $Log$
  641. Revision 1.1 2002-07-01 18:46:20 peter
  642. * internal linker
  643. * reorganized aasm layer
  644. }