2
0

aasmdata.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. {
  2. Copyright (c) 1998-2006 by Florian Klaempfl
  3. This unit implements an abstract asmoutput class for all processor types
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. { @abstract(This unit implements an abstract asm output class for all processor types)
  18. This unit implements an abstract assembler output class for all processors, these
  19. are then overridden for each assembler writer to actually write the data in these
  20. classes to an assembler file.
  21. }
  22. unit aasmdata;
  23. {$i fpcdefs.inc}
  24. interface
  25. uses
  26. cutils,cclasses,
  27. globtype,systems,
  28. cgbase,
  29. symtype,
  30. aasmbase;
  31. type
  32. { Type of AsmLists. The order is important for the layout of the
  33. information in the .o file. The stabs for the types must be defined
  34. before they can be referenced and therefor they need to be written
  35. first (PFV) }
  36. TAsmListType=(
  37. al_start,
  38. al_stabs,
  39. { pure assembler routines }
  40. al_pure_assembler,
  41. al_procedures,
  42. al_globals,
  43. al_const,
  44. al_typedconsts,
  45. al_rotypedconsts,
  46. al_threadvars,
  47. al_imports,
  48. al_exports,
  49. al_resources,
  50. al_rtti,
  51. { all symbols with indirect suffix }
  52. al_indirectglobals,
  53. al_dwarf_frame,
  54. al_dwarf_info,
  55. al_dwarf_abbrev,
  56. al_dwarf_line,
  57. al_dwarf_aranges,
  58. al_dwarf_ranges,
  59. al_picdata,
  60. al_indirectpicdata,
  61. al_resourcestrings,
  62. { Objective-C related sections }
  63. al_objc_data,
  64. { keep pool data separate, so we can generate new pool entries
  65. while emitting other data }
  66. al_objc_pools,
  67. al_end
  68. );
  69. { Type of constant 'pools'. Mostly for string types, but usable for
  70. floating point and large set constants, too. }
  71. TConstPoolType = (
  72. sp_invalid,
  73. sp_conststr,
  74. sp_shortstr,
  75. sp_longstr,
  76. sp_ansistr,
  77. sp_widestr,
  78. sp_unicodestr,
  79. sp_objcclassnamerefs,
  80. sp_varnamerefs,
  81. sp_objcclassnames,
  82. sp_objcvarnames,
  83. sp_objcvartypes,
  84. sp_objcprotocolrefs,
  85. sp_varsets,
  86. sp_floats,
  87. sp_guids,
  88. sp_paraloc
  89. );
  90. const
  91. AsmListTypeStr : array[TAsmListType] of string[24] =(
  92. 'al_begin',
  93. 'al_stabs',
  94. 'al_pure_assembler',
  95. 'al_procedures',
  96. 'al_globals',
  97. 'al_const',
  98. 'al_typedconsts',
  99. 'al_rotypedconsts',
  100. 'al_threadvars',
  101. 'al_imports',
  102. 'al_exports',
  103. 'al_resources',
  104. 'al_rtti',
  105. 'al_indirectglobals',
  106. 'al_dwarf_frame',
  107. 'al_dwarf_info',
  108. 'al_dwarf_abbrev',
  109. 'al_dwarf_line',
  110. 'al_dwarf_aranges',
  111. 'al_dwarf_ranges',
  112. 'al_picdata',
  113. 'al_indirectpicdata',
  114. 'al_resourcestrings',
  115. 'al_objc_data',
  116. 'al_objc_pools',
  117. 'al_end'
  118. );
  119. type
  120. TAsmList = class(tlinkedlist)
  121. section_count : longint;
  122. constructor create;
  123. function getlasttaifilepos : pfileposinfo;
  124. { inserts another List at the begin and make this List empty }
  125. procedure insertList(p : TLinkedList); override;
  126. { inserts another List before the provided item and make this List empty }
  127. procedure insertListBefore(Item:TLinkedListItem;p : TLinkedList); override;
  128. { inserts another List after the provided item and make this List empty }
  129. procedure insertListAfter(Item:TLinkedListItem;p : TLinkedList); override;
  130. { concats another List at the end and make this List empty }
  131. procedure concatList(p : TLinkedList); override;
  132. { concats another List at the start and makes a copy
  133. the list is ordered in reverse.
  134. }
  135. procedure insertListcopy(p : TLinkedList); override;
  136. { concats another List at the end and makes a copy }
  137. procedure concatListcopy(p : TLinkedList); override;
  138. { removes all items from the list, the items are not freed }
  139. procedure RemoveAll; override;
  140. end;
  141. TAsmCFI=class
  142. public
  143. constructor create;virtual;
  144. destructor destroy;override;
  145. procedure generate_code(list:TAsmList);virtual;
  146. procedure start_frame(list:TAsmList);virtual;
  147. procedure end_frame(list:TAsmList);virtual;
  148. procedure outmost_frame(list:TAsmList);virtual;
  149. procedure cfa_offset(list:TAsmList;reg:tregister;ofs:longint);virtual;
  150. procedure cfa_restore(list:TAsmList;reg:tregister);virtual;
  151. procedure cfa_def_cfa_register(list:TAsmList;reg:tregister);virtual;
  152. procedure cfa_def_cfa_offset(list:TAsmList;ofs:longint);virtual;
  153. function get_frame_start: TAsmLabel;virtual;
  154. function get_cfa_list : TAsmList;virtual;
  155. end;
  156. TAsmCFIClass=class of TAsmCFI;
  157. { TAsmData }
  158. TAsmData = class
  159. private
  160. { Symbols }
  161. FAsmSymbolDict : TFPHashObjectList;
  162. FAltSymbolList : TFPObjectList;
  163. FNextAltNr : longint;
  164. FNextLabelNr : array[TAsmLabeltype] of longint;
  165. { Call Frame Information for stack unwinding}
  166. FAsmCFI : TAsmCFI;
  167. FConstPools : array[TConstPoolType] of THashSet;
  168. function GetConstPools(APoolType: TConstPoolType): THashSet;
  169. protected
  170. function DefineAsmSymbolByClassBase(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef; out wasdefined: boolean) : TAsmSymbol;
  171. public
  172. name : pshortstring; { owned by tmodule }
  173. NextVTEntryNr : longint;
  174. { Assembler lists }
  175. AsmLists : array[TAsmListType] of TAsmList;
  176. CurrAsmList : TAsmList;
  177. WideInits : TLinkedList;
  178. ResStrInits : TLinkedList;
  179. constructor create(n: pshortstring);
  180. destructor destroy;override;
  181. { asmsymbol }
  182. function DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol; virtual;
  183. function DefineAsmSymbol(const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol;
  184. function DefineProcAsmSymbol(pd: tdef; const s: TSymStr; global: boolean): TAsmSymbol;
  185. function WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype) : TAsmSymbol;
  186. function RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean=false) : TAsmSymbol;
  187. function GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
  188. { create new assembler label }
  189. procedure getlabel(out l : TAsmLabel;alt:TAsmLabeltype);
  190. procedure getjumplabel(out l : TAsmLabel);
  191. procedure getglobaljumplabel(out l : TAsmLabel);
  192. procedure getaddrlabel(out l : TAsmLabel);
  193. { visible from outside current object }
  194. procedure getglobaldatalabel(out l : TAsmLabel);
  195. { visible only inside current object, but doesn't start with
  196. target_asm.label_prefix (treated the Darwin linker as the start of a
  197. dead-strippable data block) }
  198. procedure getstaticdatalabel(out l : TAsmLabel);
  199. { visible only inside the current object and does start with
  200. target_asm.label_prefix (not treated by the Darwin linker as the start
  201. of a dead-strippable data block, and references to such labels are
  202. also ignored to determine whether a data block should be live) }
  203. procedure getlocaldatalabel(out l : TAsmLabel);
  204. { generate an alternative (duplicate) symbol }
  205. procedure GenerateAltSymbol(p:TAsmSymbol);
  206. procedure ResetAltSymbols;
  207. property AsmSymbolDict:TFPHashObjectList read FAsmSymbolDict;
  208. property AsmCFI:TAsmCFI read FAsmCFI;
  209. { hash tables for reusing constant storage }
  210. property ConstPools[APoolType:TConstPoolType]: THashSet read GetConstPools;
  211. end;
  212. TAsmDataClass = class of TAsmData;
  213. TTCInitItem = class(TLinkedListItem)
  214. sym: tsym;
  215. offset: aint;
  216. datalabel: TAsmSymbol;
  217. datadef: TDef;
  218. constructor Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef);
  219. end;
  220. var
  221. casmdata: TAsmDataClass;
  222. var
  223. CAsmCFI : TAsmCFIClass;
  224. current_asmdata : TAsmData;
  225. implementation
  226. uses
  227. verbose,
  228. globals,
  229. symconst,
  230. aasmtai;
  231. {$ifdef MEMDEBUG}
  232. var
  233. memasmsymbols,
  234. memasmcfi,
  235. memasmlists : TMemDebug;
  236. {$endif MEMDEBUG}
  237. {*****************************************************************************
  238. TAsmCFI
  239. *****************************************************************************}
  240. constructor TAsmCFI.create;
  241. begin
  242. end;
  243. destructor TAsmCFI.destroy;
  244. begin
  245. end;
  246. procedure TAsmCFI.generate_code(list:TAsmList);
  247. begin
  248. end;
  249. procedure TAsmCFI.start_frame(list:TAsmList);
  250. begin
  251. end;
  252. procedure TAsmCFI.end_frame(list:TAsmList);
  253. begin
  254. end;
  255. procedure TAsmCFI.outmost_frame(list: TAsmList);
  256. begin
  257. end;
  258. procedure TAsmCFI.cfa_offset(list:TAsmList;reg:tregister;ofs:longint);
  259. begin
  260. end;
  261. procedure TAsmCFI.cfa_restore(list:TAsmList;reg:tregister);
  262. begin
  263. end;
  264. procedure TAsmCFI.cfa_def_cfa_register(list:TAsmList;reg:tregister);
  265. begin
  266. end;
  267. procedure TAsmCFI.cfa_def_cfa_offset(list:TAsmList;ofs:longint);
  268. begin
  269. end;
  270. function TAsmCFI.get_frame_start: TAsmLabel;
  271. begin
  272. Result:=nil;
  273. end;
  274. function TAsmCFI.get_cfa_list: TAsmList;
  275. begin
  276. Result:=nil;
  277. end;
  278. {*****************************************************************************
  279. TTCInitItem
  280. *****************************************************************************}
  281. constructor TTCInitItem.Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef);
  282. begin
  283. inherited Create;
  284. sym:=asym;
  285. offset:=aoffset;
  286. datalabel:=alabel;
  287. datadef:=alabeldef;
  288. end;
  289. {*****************************************************************************
  290. TAsmList
  291. *****************************************************************************}
  292. constructor TAsmList.create;
  293. begin
  294. inherited create;
  295. end;
  296. function TAsmList.getlasttaifilepos : pfileposinfo;
  297. var
  298. hp : tlinkedlistitem;
  299. begin
  300. getlasttaifilepos := nil;
  301. if assigned(last) then
  302. begin
  303. { find the last file information record }
  304. if not (tai(last).typ in SkipLineInfo) then
  305. getlasttaifilepos:=@tailineinfo(last).fileinfo
  306. else
  307. { go through list backwards to find the first entry
  308. with line information
  309. }
  310. begin
  311. hp:=tai(last);
  312. while assigned(hp) and (tai(hp).typ in SkipLineInfo) do
  313. hp:=hp.Previous;
  314. { found entry }
  315. if assigned(hp) then
  316. getlasttaifilepos:=@tailineinfo(hp).fileinfo
  317. end;
  318. end;
  319. end;
  320. procedure TAsmList.insertList(p : TLinkedList);
  321. begin
  322. inherited insertList(p);
  323. inc(section_count,TAsmList(p).section_count);
  324. TAsmList(p).section_count:=0;
  325. end;
  326. procedure TAsmList.insertListBefore(Item : TLinkedListItem; p : TLinkedList);
  327. begin
  328. inherited insertListBefore(Item,p);
  329. inc(section_count,TAsmList(p).section_count);
  330. TAsmList(p).section_count:=0;
  331. end;
  332. procedure TAsmList.insertListAfter(Item : TLinkedListItem; p : TLinkedList);
  333. begin
  334. inherited insertListAfter(Item,p);
  335. inc(section_count,TAsmList(p).section_count);
  336. TAsmList(p).section_count:=0;
  337. end;
  338. procedure TAsmList.concatList(p : TLinkedList);
  339. begin
  340. inherited concatList(p);
  341. inc(section_count,TAsmList(p).section_count);
  342. TAsmList(p).section_count:=0;
  343. end;
  344. procedure TAsmList.insertListcopy(p : TLinkedList);
  345. begin
  346. inherited insertListcopy(p);
  347. inc(section_count,TAsmList(p).section_count);
  348. end;
  349. procedure TAsmList.concatListcopy(p : TLinkedList);
  350. begin
  351. inherited concatListcopy(p);
  352. inc(section_count,TAsmList(p).section_count);
  353. end;
  354. procedure TAsmList.RemoveAll;
  355. begin
  356. inherited RemoveAll;
  357. section_count:=0;
  358. end;
  359. {****************************************************************************
  360. TAsmData
  361. ****************************************************************************}
  362. function TAsmData.GetConstPools(APoolType: TConstPoolType): THashSet;
  363. begin
  364. if FConstPools[APoolType] = nil then
  365. case APoolType of
  366. sp_ansistr: FConstPools[APoolType] := TTagHashSet.Create(64, True, False);
  367. else
  368. FConstPools[APoolType] := THashSet.Create(64, True, False);
  369. end;
  370. Result := FConstPools[APoolType];
  371. end;
  372. function TAsmData.DefineAsmSymbolByClassBase(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef; out wasdefined: boolean): TAsmSymbol;
  373. var
  374. hp : TAsmSymbol;
  375. namestr : TSymStr;
  376. begin
  377. { this difference is only necessary to determine whether we always need
  378. indirect references or not }
  379. if _typ in [AT_DATA_FORCEINDIRECT,AT_DATA_NOINDIRECT] then
  380. _typ:=AT_DATA;
  381. namestr:=s;
  382. if _bind in asmsymbindindirect then
  383. namestr:=namestr+suffix_indirect;
  384. hp:=TAsmSymbol(FAsmSymbolDict.Find(namestr));
  385. if assigned(hp) then
  386. begin
  387. { Redefine is allowed, but the types must be the same. The redefine
  388. is needed for Darwin where the labels are first allocated }
  389. wasdefined:=not(hp.bind in [AB_EXTERNAL,AB_WEAK_EXTERNAL]);
  390. if wasdefined then
  391. begin
  392. if (hp.bind<>_bind) and
  393. (hp.typ<>_typ) then
  394. internalerror(200603261);
  395. end;
  396. hp.typ:=_typ;
  397. { Changing bind from AB_GLOBAL to AB_LOCAL is wrong
  398. if bind is already AB_GLOBAL or AB_EXTERNAL,
  399. GOT might have been used, so change might be harmful. }
  400. if (_bind<>hp.bind) and (hp.getrefs>0) then
  401. begin
  402. {$ifdef extdebug}
  403. { the changes that matter must become internalerrors, the rest
  404. should be ignored; a used cannot change anything about this,
  405. so printing a warning/hint is not useful }
  406. if (_bind=AB_LOCAL) then
  407. Message3(asmw_w_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind])
  408. else
  409. Message3(asmw_h_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind]);
  410. {$endif extdebug}
  411. end;
  412. hp.bind:=_bind;
  413. end
  414. else
  415. begin
  416. wasdefined:=false;
  417. { Not found, insert it. }
  418. hp:=symclass.create(AsmSymbolDict,namestr,_bind,_typ);
  419. end;
  420. result:=hp;
  421. end;
  422. constructor TAsmData.create(n:pshortstring);
  423. var
  424. alt : TAsmLabelType;
  425. hal : TAsmListType;
  426. begin
  427. inherited create;
  428. name:=n;
  429. { symbols }
  430. FAsmSymbolDict:=TFPHashObjectList.create(true);
  431. FAltSymbolList:=TFPObjectList.Create(false);
  432. { labels }
  433. FNextAltNr:=1;
  434. for alt:=low(TAsmLabelType) to high(TAsmLabelType) do
  435. FNextLabelNr[alt]:=1;
  436. { AsmLists }
  437. CurrAsmList:=TAsmList.create;
  438. for hal:=low(TAsmListType) to high(TAsmListType) do
  439. AsmLists[hal]:=TAsmList.create;
  440. WideInits :=TAsmList.create;
  441. ResStrInits:=TAsmList.create;
  442. { CFI }
  443. FAsmCFI:=CAsmCFI.Create;
  444. end;
  445. destructor TAsmData.destroy;
  446. var
  447. hal : TAsmListType;
  448. hp : TConstPoolType;
  449. begin
  450. { Symbols }
  451. {$ifdef MEMDEBUG}
  452. memasmsymbols.start;
  453. {$endif}
  454. FAltSymbolList.free;
  455. FAsmSymbolDict.free;
  456. {$ifdef MEMDEBUG}
  457. memasmsymbols.stop;
  458. {$endif}
  459. { CFI }
  460. {$ifdef MEMDEBUG}
  461. memasmcfi.start;
  462. {$endif}
  463. FAsmCFI.free;
  464. {$ifdef MEMDEBUG}
  465. memasmcfi.stop;
  466. {$endif}
  467. { Lists }
  468. {$ifdef MEMDEBUG}
  469. memasmlists.start;
  470. {$endif}
  471. ResStrInits.free;
  472. WideInits.free;
  473. for hal:=low(TAsmListType) to high(TAsmListType) do
  474. AsmLists[hal].free;
  475. CurrAsmList.free;
  476. {$ifdef MEMDEBUG}
  477. memasmlists.stop;
  478. {$endif}
  479. for hp := low(TConstPoolType) to high(TConstPoolType) do
  480. FConstPools[hp].Free;
  481. end;
  482. function TAsmData.DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
  483. var
  484. wasdefined: boolean;
  485. begin
  486. result:=DefineAsmSymbolByClassBase(symclass,s,_bind,_typ,def,wasdefined);
  487. end;
  488. function TAsmData.DefineAsmSymbol(const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
  489. begin
  490. result:=DefineAsmSymbolByClass(TAsmSymbol,s,_bind,_typ,def);
  491. end;
  492. function TAsmData.DefineProcAsmSymbol(pd: tdef; const s: TSymStr; global: boolean): TAsmSymbol;
  493. begin
  494. { The condition to use global or local symbol must match
  495. the code written in hlcg.gen_proc_symbol to
  496. avoid change from AB_LOCAL to AB_GLOBAL, which generates
  497. erroneous code (at least for targets using GOT) }
  498. if global or
  499. (cs_profile in current_settings.moduleswitches) then
  500. result:=DefineAsmSymbol(s,AB_GLOBAL,AT_FUNCTION,pd)
  501. else if tf_supports_hidden_symbols in target_info.flags then
  502. result:=DefineAsmSymbol(s,AB_PRIVATE_EXTERN,AT_FUNCTION,pd)
  503. else
  504. result:=DefineAsmSymbol(s,AB_LOCAL,AT_FUNCTION,pd);
  505. end;
  506. function TAsmData.RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean) : TAsmSymbol;
  507. var
  508. namestr : TSymStr;
  509. bind : tasmsymbind;
  510. begin
  511. namestr:=s;
  512. if indirect then
  513. begin
  514. namestr:=namestr+suffix_indirect;
  515. bind:=AB_EXTERNAL_INDIRECT;
  516. end
  517. else
  518. begin
  519. bind:=AB_EXTERNAL;
  520. end;
  521. result:=TAsmSymbol(FAsmSymbolDict.Find(namestr));
  522. if not assigned(result) then
  523. result:=TAsmSymbol.create(AsmSymbolDict,namestr,bind,_typ)
  524. { one normal reference removes the "weak" character of a symbol }
  525. else if (result.bind=AB_WEAK_EXTERNAL) then
  526. result.bind:=bind;
  527. end;
  528. function TAsmData.WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype) : TAsmSymbol;
  529. begin
  530. result:=TAsmSymbol(FAsmSymbolDict.Find(s));
  531. if not assigned(result) then
  532. result:=TAsmSymbol.create(AsmSymbolDict,s,AB_WEAK_EXTERNAL,_typ);
  533. end;
  534. function TAsmData.GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
  535. begin
  536. result:=TAsmSymbol(FAsmSymbolDict.Find(s));
  537. end;
  538. procedure TAsmData.GenerateAltSymbol(p:TAsmSymbol);
  539. begin
  540. if not assigned(p.altsymbol) then
  541. begin
  542. p.altsymbol:=p.getaltcopy(AsmSymbolDict,FNextAltNr);
  543. FAltSymbolList.Add(p);
  544. end;
  545. end;
  546. procedure TAsmData.ResetAltSymbols;
  547. var
  548. i : longint;
  549. begin
  550. for i:=0 to FAltSymbolList.Count-1 do
  551. TAsmSymbol(FAltSymbolList[i]).altsymbol:=nil;
  552. FAltSymbolList.Clear;
  553. end;
  554. procedure TAsmData.getlabel(out l : TAsmLabel;alt:TAsmLabeltype);
  555. begin
  556. if (target_info.system in (systems_linux + systems_bsd + systems_android)) and
  557. { the next condition was
  558. (cs_create_smart in current_settings.moduleswitches) and
  559. but if we create_smartlink_sections, this is useless }
  560. (create_smartlink_library) and
  561. (alt = alt_dbgline) then
  562. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt],alt)
  563. else
  564. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt],alt);
  565. inc(FNextLabelNr[alt]);
  566. end;
  567. procedure TAsmData.getjumplabel(out l : TAsmLabel);
  568. begin
  569. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_jump],alt_jump);
  570. inc(FNextLabelNr[alt_jump]);
  571. end;
  572. procedure TAsmData.getglobaljumplabel(out l : TAsmLabel);
  573. begin
  574. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt_jump],alt_jump);
  575. inc(FNextLabelNr[alt_jump]);
  576. end;
  577. procedure TAsmData.getglobaldatalabel(out l : TAsmLabel);
  578. begin
  579. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt_data],alt_data);
  580. inc(FNextLabelNr[alt_data]);
  581. end;
  582. procedure TAsmData.getstaticdatalabel(out l : TAsmLabel);
  583. begin
  584. l:=TAsmLabel.createstatic(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);
  585. inc(FNextLabelNr[alt_data]);
  586. end;
  587. procedure TAsmData.getlocaldatalabel(out l: TAsmLabel);
  588. begin
  589. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);
  590. inc(FNextLabelNr[alt_data]);
  591. end;
  592. procedure TAsmData.getaddrlabel(out l : TAsmLabel);
  593. begin
  594. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_addr],alt_addr);
  595. inc(FNextLabelNr[alt_addr]);
  596. end;
  597. initialization
  598. {$ifdef MEMDEBUG}
  599. memasmsymbols:=TMemDebug.create('AsmSymbols');
  600. memasmsymbols.stop;
  601. memasmcfi:=TMemDebug.create('AsmCFI');
  602. memasmcfi.stop;
  603. memasmlists:=TMemDebug.create('AsmLists');
  604. memasmlists.stop;
  605. {$endif MEMDEBUG}
  606. if not(assigned(CAsmCFI)) then
  607. CAsmCFI:=TAsmCFI;
  608. finalization
  609. {$ifdef MEMDEBUG}
  610. memasmsymbols.free;
  611. memasmcfi.free;
  612. memasmlists.free;
  613. {$endif MEMDEBUG}
  614. end.