aasmbase.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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. relocations.free;
  361. end;
  362. function TAsmSection.write(var d;l:longint):longint;
  363. begin
  364. write:=datasize;
  365. if not assigned(Data) then
  366. Internalerror(3334441);
  367. Data.write(d,l);
  368. inc(datasize,l);
  369. end;
  370. function TAsmSection.writestr(const s:string):longint;
  371. begin
  372. writestr:=datasize;
  373. if not assigned(Data) then
  374. Internalerror(3334441);
  375. Data.write(s[1],length(s));
  376. inc(datasize,length(s));
  377. end;
  378. procedure TAsmSection.writealign(l:longint);
  379. var
  380. i : longint;
  381. empty : array[0..63] of char;
  382. begin
  383. { no alignment needed for 0 or 1 }
  384. if l<=1 then
  385. exit;
  386. i:=datasize mod l;
  387. if i>0 then
  388. begin
  389. if assigned(data) then
  390. begin
  391. fillchar(empty,sizeof(empty),0);
  392. Data.write(empty,l-i);
  393. end;
  394. inc(datasize,l-i);
  395. end;
  396. end;
  397. function TAsmSection.aligneddatasize:longint;
  398. begin
  399. aligneddatasize:=align(datasize,addralign);
  400. end;
  401. procedure TAsmSection.alignsection;
  402. begin
  403. writealign(addralign);
  404. end;
  405. procedure TAsmSection.alloc(l:longint);
  406. begin
  407. if assigned(Data) then
  408. Internalerror(3334442);
  409. inc(datasize,l);
  410. end;
  411. procedure TAsmSection.addsymreloc(ofs:longint;p:tasmsymbol;relative:TAsmRelocationType);
  412. var
  413. r : TAsmRelocation;
  414. begin
  415. r:=TAsmRelocation.Create;
  416. r.address:=ofs;
  417. r.orgsize:=0;
  418. r.symbol:=p;
  419. r.section:=sec_none;
  420. r.typ:=relative;
  421. relocations.concat(r);
  422. end;
  423. procedure TAsmSection.addsectionreloc(ofs:longint;sec:TSection;relative:TAsmRelocationType);
  424. var
  425. r : TAsmRelocation;
  426. begin
  427. r:=TAsmRelocation.Create;
  428. r.address:=ofs;
  429. r.symbol:=nil;
  430. r.orgsize:=0;
  431. r.section:=sec;
  432. r.typ:=relative;
  433. relocations.concat(r);
  434. end;
  435. {****************************************************************************
  436. TAsmObjectData
  437. ****************************************************************************}
  438. constructor TAsmObjectData.create(const n:string);
  439. begin
  440. inherited create;
  441. name:=n;
  442. { sections }
  443. FillChar(Sects,sizeof(Sects),0);
  444. { symbols }
  445. symbols:=tindexarray.create(symbolsgrow);
  446. symbols.noclear:=true;
  447. end;
  448. destructor TAsmObjectData.destroy;
  449. var
  450. sec : TSection;
  451. begin
  452. { free memory }
  453. for sec:=low(TSection) to high(TSection) do
  454. if assigned(sects[sec]) then
  455. sects[sec].free;
  456. symbols.free;
  457. end;
  458. procedure TAsmObjectData.createsection(sec:TSection);
  459. begin
  460. sects[sec]:=TAsmSection.create(target_asm.secnames[sec],1,(sec=sec_bss));
  461. end;
  462. function TAsmObjectData.sectionsize(s:TSection):longint;
  463. begin
  464. if assigned(sects[s]) then
  465. sectionsize:=sects[s].datasize
  466. else
  467. sectionsize:=0;
  468. end;
  469. function TAsmObjectData.currsectionsize:longint;
  470. begin
  471. if assigned(sects[currsec]) then
  472. currsectionsize:=sects[currsec].datasize
  473. else
  474. currsectionsize:=0;
  475. end;
  476. procedure TAsmObjectData.seTSectionsizes(var s:TAsmSectionSizes);
  477. begin
  478. end;
  479. procedure TAsmObjectData.defaulTSection(sec:TSection);
  480. begin
  481. currsec:=sec;
  482. end;
  483. procedure TAsmObjectData.writebytes(var data;len:longint);
  484. begin
  485. if not assigned(sects[currsec]) then
  486. createsection(currsec);
  487. sects[currsec].write(data,len);
  488. end;
  489. procedure TAsmObjectData.alloc(len:longint);
  490. begin
  491. if not assigned(sects[currsec]) then
  492. createsection(currsec);
  493. sects[currsec].alloc(len);
  494. end;
  495. procedure TAsmObjectData.allocalign(len:longint);
  496. var
  497. modulo : longint;
  498. begin
  499. if not assigned(sects[currsec]) then
  500. createsection(currsec);
  501. modulo:=sects[currsec].datasize mod len;
  502. if modulo > 0 then
  503. sects[currsec].alloc(len-modulo);
  504. end;
  505. procedure TAsmObjectData.fixuprelocs;
  506. begin
  507. { no relocation support by default }
  508. end;
  509. {*****************************************************************************
  510. AsmSymbolList helpers
  511. *****************************************************************************}
  512. function newasmsymbol(const s : string) : tasmsymbol;
  513. var
  514. hp : tasmsymbol;
  515. begin
  516. hp:=tasmsymbol(asmsymbollist.search(s));
  517. if not assigned(hp) then
  518. begin
  519. { Not found, insert it as an External }
  520. hp:=tasmsymbol.create(s,AB_EXTERNAL,AT_FUNCTION);
  521. asmsymbollist.insert(hp);
  522. end;
  523. newasmsymbol:=hp;
  524. end;
  525. function newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:Tasmsymtype) : tasmsymbol;
  526. var
  527. hp : tasmsymbol;
  528. begin
  529. hp:=tasmsymbol(asmsymbollist.search(s));
  530. if assigned(hp) then
  531. hp.defbind:=_bind
  532. else
  533. begin
  534. { Not found, insert it as an External }
  535. hp:=tasmsymbol.create(s,_bind,_typ);
  536. asmsymbollist.insert(hp);
  537. end;
  538. newasmsymboltype:=hp;
  539. end;
  540. function getasmsymbol(const s : string) : tasmsymbol;
  541. begin
  542. getasmsymbol:=tasmsymbol(asmsymbollist.search(s));
  543. end;
  544. { renames an asmsymbol }
  545. function renameasmsymbol(const sold, snew : string):tasmsymbol;
  546. begin
  547. renameasmsymbol:=tasmsymbol(asmsymbollist.rename(sold,snew));
  548. end;
  549. {*****************************************************************************
  550. Used AsmSymbolList
  551. *****************************************************************************}
  552. procedure CreateUsedAsmSymbolList;
  553. begin
  554. if assigned(usedasmsymbollist) then
  555. internalerror(78455782);
  556. usedasmsymbollist:=TSingleList.create;
  557. end;
  558. procedure DestroyUsedAsmSymbolList;
  559. begin
  560. usedasmsymbollist.destroy;
  561. usedasmsymbollist:=nil;
  562. end;
  563. procedure UsedAsmSymbolListInsert(p:tasmsymbol);
  564. begin
  565. if not p.inusedlist then
  566. usedasmsymbollist.insert(p);
  567. p.inusedlist:=true;
  568. end;
  569. procedure UsedAsmSymbolListReset;
  570. var
  571. hp : tasmsymbol;
  572. begin
  573. hp:=tasmsymbol(usedasmsymbollist.first);
  574. while assigned(hp) do
  575. begin
  576. with hp do
  577. begin
  578. reset;
  579. inusedlist:=false;
  580. end;
  581. hp:=tasmsymbol(hp.listnext);
  582. end;
  583. end;
  584. procedure UsedAsmSymbolListResetAltSym;
  585. var
  586. hp : tasmsymbol;
  587. begin
  588. hp:=tasmsymbol(usedasmsymbollist.first);
  589. while assigned(hp) do
  590. begin
  591. with hp do
  592. begin
  593. altsymbol:=nil;
  594. inusedlist:=false;
  595. end;
  596. hp:=tasmsymbol(hp.listnext);
  597. end;
  598. end;
  599. procedure UsedAsmSymbolListCheckUndefined;
  600. var
  601. hp : tasmsymbol;
  602. begin
  603. hp:=tasmsymbol(usedasmsymbollist.first);
  604. while assigned(hp) do
  605. begin
  606. with hp do
  607. begin
  608. if (refs>0) and
  609. (section=Sec_none) and
  610. not(currbind in [AB_EXTERNAL,AB_COMMON]) then
  611. Message1(asmw_e_undefined_label,name);
  612. end;
  613. hp:=tasmsymbol(hp.listnext);
  614. end;
  615. end;
  616. {*****************************************************************************
  617. Label Helpers
  618. *****************************************************************************}
  619. procedure getlabel(var l : tasmlabel);
  620. begin
  621. l:=tasmlabel.create;
  622. asmsymbollist.insert(l);
  623. end;
  624. procedure getdatalabel(var l : tasmlabel);
  625. begin
  626. l:=tasmlabel.createdata;
  627. asmsymbollist.insert(l);
  628. end;
  629. procedure getaddrlabel(var l : tasmlabel);
  630. begin
  631. l:=tasmlabel.createaddr;
  632. asmsymbollist.insert(l);
  633. end;
  634. procedure getlabelnr(var l : longint);
  635. begin
  636. l:=nextlabelnr;
  637. inc(nextlabelnr);
  638. end;
  639. end.
  640. {
  641. $Log$
  642. Revision 1.3 2002-07-10 07:24:40 jonas
  643. * memory leak fixes from Sergey Korshunoff
  644. Revision 1.2 2002/07/07 09:52:32 florian
  645. * powerpc target fixed, very simple units can be compiled
  646. * some basic stuff for better callparanode handling, far from being finished
  647. Revision 1.1 2002/07/01 18:46:20 peter
  648. * internal linker
  649. * reorganized aasm layer
  650. }