2
0

aggas.pas 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949
  1. {
  2. Copyright (c) 1998-2006 by the Free Pascal team
  3. This unit implements the generic part of the GNU assembler
  4. (v2.8 or later) writer
  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. { Base unit for writing GNU assembler output.
  19. }
  20. unit aggas;
  21. {$i fpcdefs.inc}
  22. interface
  23. uses
  24. globtype,globals,
  25. aasmbase,aasmtai,aasmdata,
  26. assemble;
  27. type
  28. TCPUInstrWriter = class;
  29. {# This is a derived class which is used to write
  30. GAS styled assembler.
  31. }
  32. { TGNUAssembler }
  33. TGNUAssembler=class(texternalassembler)
  34. protected
  35. function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;virtual;
  36. function sectionattrs_coff(atype:TAsmSectiontype):string;virtual;
  37. function sectionalignment_aix(atype:TAsmSectiontype;secalign: byte):string;
  38. procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:byte);
  39. procedure WriteExtraHeader;virtual;
  40. procedure WriteExtraFooter;virtual;
  41. procedure WriteInstruction(hp: tai);
  42. procedure WriteWeakSymbolDef(s: tasmsymbol); virtual;
  43. procedure WriteAixStringConst(hp: tai_string);
  44. procedure WriteAixIntConst(hp: tai_const);
  45. procedure WriteUnalignedIntConst(hp: tai_const);
  46. procedure WriteDirectiveName(dir: TAsmDirective); virtual;
  47. public
  48. function MakeCmdLine: TCmdStr; override;
  49. procedure WriteTree(p:TAsmList);override;
  50. procedure WriteAsmList;override;
  51. destructor destroy; override;
  52. private
  53. setcount: longint;
  54. procedure WriteDecodedSleb128(a: int64);
  55. procedure WriteDecodedUleb128(a: qword);
  56. function NextSetLabel: string;
  57. protected
  58. InstrWriter: TCPUInstrWriter;
  59. end;
  60. {# This is the base class for writing instructions.
  61. The WriteInstruction() method must be overridden
  62. to write a single instruction to the assembler
  63. file.
  64. }
  65. TCPUInstrWriter = class
  66. constructor create(_owner: TGNUAssembler);
  67. procedure WriteInstruction(hp : tai); virtual; abstract;
  68. protected
  69. owner: TGNUAssembler;
  70. end;
  71. { TAppleGNUAssembler }
  72. TAppleGNUAssembler=class(TGNUAssembler)
  73. protected
  74. function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
  75. procedure WriteWeakSymbolDef(s: tasmsymbol); override;
  76. end;
  77. TAoutGNUAssembler=class(TGNUAssembler)
  78. function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
  79. end;
  80. implementation
  81. uses
  82. SysUtils,
  83. cutils,cfileutl,systems,
  84. fmodule,verbose,
  85. {$ifdef TEST_WIN64_SEH}
  86. itcpugas,
  87. {$endif TEST_WIN64_SEH}
  88. cpubase;
  89. const
  90. line_length = 70;
  91. var
  92. symendcount : longint;
  93. type
  94. {$ifdef cpuextended}
  95. t80bitarray = array[0..9] of byte;
  96. {$endif cpuextended}
  97. t64bitarray = array[0..7] of byte;
  98. t32bitarray = array[0..3] of byte;
  99. {****************************************************************************}
  100. { Support routines }
  101. {****************************************************************************}
  102. function single2str(d : single) : string;
  103. var
  104. hs : string;
  105. begin
  106. str(d,hs);
  107. { replace space with + }
  108. if hs[1]=' ' then
  109. hs[1]:='+';
  110. single2str:='0d'+hs
  111. end;
  112. function double2str(d : double) : string;
  113. var
  114. hs : string;
  115. begin
  116. str(d,hs);
  117. { replace space with + }
  118. if hs[1]=' ' then
  119. hs[1]:='+';
  120. double2str:='0d'+hs
  121. end;
  122. function extended2str(e : extended) : string;
  123. var
  124. hs : string;
  125. begin
  126. str(e,hs);
  127. { replace space with + }
  128. if hs[1]=' ' then
  129. hs[1]:='+';
  130. extended2str:='0d'+hs
  131. end;
  132. { convert floating point values }
  133. { to correct endian }
  134. procedure swap64bitarray(var t: t64bitarray);
  135. var
  136. b: byte;
  137. begin
  138. b:= t[7];
  139. t[7] := t[0];
  140. t[0] := b;
  141. b := t[6];
  142. t[6] := t[1];
  143. t[1] := b;
  144. b:= t[5];
  145. t[5] := t[2];
  146. t[2] := b;
  147. b:= t[4];
  148. t[4] := t[3];
  149. t[3] := b;
  150. end;
  151. procedure swap32bitarray(var t: t32bitarray);
  152. var
  153. b: byte;
  154. begin
  155. b:= t[1];
  156. t[1]:= t[2];
  157. t[2]:= b;
  158. b:= t[0];
  159. t[0]:= t[3];
  160. t[3]:= b;
  161. end;
  162. const
  163. ait_const2str : array[aitconst_128bit..aitconst_64bit_unaligned] of string[20]=(
  164. #9'.fixme128'#9,#9'.quad'#9,#9'.long'#9,#9'.short'#9,#9'.byte'#9,
  165. #9'.sleb128'#9,#9'.uleb128'#9,
  166. #9'.rva'#9,#9'.secrel32'#9,#9'.quad'#9,#9'.long'#9,#9'.short'#9,
  167. #9'.short'#9,#9'.long'#9,#9'.quad'#9
  168. );
  169. ait_unaligned_consts = [aitconst_16bit_unaligned..aitconst_64bit_unaligned];
  170. { Sparc type of unaligned pseudo-instructions }
  171. use_ua_sparc_systems = [system_sparc_linux];
  172. ait_ua_sparc_const2str : array[aitconst_16bit_unaligned..aitconst_64bit_unaligned]
  173. of string[20]=(
  174. #9'.uahalf'#9,#9'.uaword'#9,#9'.uaxword'#9
  175. );
  176. { Alpha type of unaligned pseudo-instructions }
  177. use_ua_alpha_systems = [system_alpha_linux];
  178. ait_ua_alpha_const2str : array[aitconst_16bit_unaligned..aitconst_64bit_unaligned]
  179. of string[20]=(
  180. #9'.uword'#9,#9'.ulong'#9,#9'.uquad'#9
  181. );
  182. { Generic unaligned pseudo-instructions, seems ELF specific }
  183. use_ua_elf_systems = [system_mipsel_linux,system_mipseb_linux];
  184. ait_ua_elf_const2str : array[aitconst_16bit_unaligned..aitconst_64bit_unaligned]
  185. of string[20]=(
  186. #9'.2byte'#9,#9'.4byte'#9,#9'.8byte'#9
  187. );
  188. {****************************************************************************}
  189. { GNU Assembler writer }
  190. {****************************************************************************}
  191. destructor TGNUAssembler.Destroy;
  192. begin
  193. InstrWriter.free;
  194. inherited destroy;
  195. end;
  196. function TGNUAssembler.MakeCmdLine: TCmdStr;
  197. begin
  198. result := inherited MakeCmdLine;
  199. // MWE: disabled again. It generates dwarf info for the generated .s
  200. // files as well. This conflicts with the info we generate
  201. // if target_dbg.id = dbg_dwarf then
  202. // result := result + ' --gdwarf-2';
  203. end;
  204. function TGNUAssembler.NextSetLabel: string;
  205. begin
  206. inc(setcount);
  207. result := target_asm.labelprefix+'$set$'+tostr(setcount);
  208. end;
  209. function is_smart_section(atype:TAsmSectiontype):boolean;
  210. begin
  211. { For bss we need to set some flags that are target dependent,
  212. it is easier to disable it for smartlinking. It doesn't take up
  213. filespace }
  214. result:=not(target_info.system in systems_darwin) and
  215. create_smartlink_sections and
  216. (atype<>sec_toc) and
  217. (atype<>sec_user) and
  218. { on embedded systems every byte counts, so smartlink bss too }
  219. ((atype<>sec_bss) or (target_info.system in systems_embedded));
  220. end;
  221. function TGNUAssembler.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
  222. const
  223. secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
  224. '.text',
  225. '.data',
  226. { why doesn't .rodata work? (FK) }
  227. { sometimes we have to create a data.rel.ro instead of .rodata, e.g. for }
  228. { vtables (and anything else containing relocations), otherwise those are }
  229. { not relocated properly on e.g. linux/ppc64. g++ generates there for a }
  230. { vtable for a class called Window: }
  231. { .section .data.rel.ro._ZTV6Window,"awG",@progbits,_ZTV6Window,comdat }
  232. { TODO: .data.ro not yet working}
  233. {$if defined(arm) or defined(powerpc)}
  234. '.rodata',
  235. {$else arm}
  236. '.data',
  237. {$endif arm}
  238. {$if defined(m68k)} { Amiga/m68k GNU AS doesn't seem to like .rodata (KB) }
  239. '.data',
  240. {$else}
  241. '.rodata',
  242. {$endif}
  243. '.bss',
  244. '.threadvar',
  245. '.pdata',
  246. '', { stubs }
  247. '__DATA,__nl_symbol_ptr',
  248. '__DATA,__la_symbol_ptr',
  249. '__DATA,__mod_init_func',
  250. '__DATA,__mod_term_func',
  251. '.stab',
  252. '.stabstr',
  253. '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
  254. '.eh_frame',
  255. '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
  256. '.fpc',
  257. '.toc',
  258. '.init',
  259. '.fini',
  260. '.objc_class',
  261. '.objc_meta_class',
  262. '.objc_cat_cls_meth',
  263. '.objc_cat_inst_meth',
  264. '.objc_protocol',
  265. '.objc_string_object',
  266. '.objc_cls_meth',
  267. '.objc_inst_meth',
  268. '.objc_cls_refs',
  269. '.objc_message_refs',
  270. '.objc_symbols',
  271. '.objc_category',
  272. '.objc_class_vars',
  273. '.objc_instance_vars',
  274. '.objc_module_info',
  275. '.objc_class_names',
  276. '.objc_meth_var_types',
  277. '.objc_meth_var_names',
  278. '.objc_selector_strs',
  279. '.objc_protocol_ext',
  280. '.objc_class_ext',
  281. '.objc_property',
  282. '.objc_image_info',
  283. '.objc_cstring_object',
  284. '.objc_sel_fixup',
  285. '__DATA,__objc_data',
  286. '__DATA,__objc_const',
  287. '.objc_superrefs',
  288. '__DATA, __datacoal_nt,coalesced',
  289. '.objc_classlist',
  290. '.objc_nlclasslist',
  291. '.objc_catlist',
  292. '.obcj_nlcatlist',
  293. '.objc_protolist'
  294. );
  295. secnames_pic : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
  296. '.text',
  297. '.data.rel',
  298. '.data.rel',
  299. '.data.rel',
  300. '.bss',
  301. '.threadvar',
  302. '.pdata',
  303. '', { stubs }
  304. '__DATA,__nl_symbol_ptr',
  305. '__DATA,__la_symbol_ptr',
  306. '__DATA,__mod_init_func',
  307. '__DATA,__mod_term_func',
  308. '.stab',
  309. '.stabstr',
  310. '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
  311. '.eh_frame',
  312. '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
  313. '.fpc',
  314. '.toc',
  315. '.init',
  316. '.fini',
  317. '.objc_class',
  318. '.objc_meta_class',
  319. '.objc_cat_cls_meth',
  320. '.objc_cat_inst_meth',
  321. '.objc_protocol',
  322. '.objc_string_object',
  323. '.objc_cls_meth',
  324. '.objc_inst_meth',
  325. '.objc_cls_refs',
  326. '.objc_message_refs',
  327. '.objc_symbols',
  328. '.objc_category',
  329. '.objc_class_vars',
  330. '.objc_instance_vars',
  331. '.objc_module_info',
  332. '.objc_class_names',
  333. '.objc_meth_var_types',
  334. '.objc_meth_var_names',
  335. '.objc_selector_strs',
  336. '.objc_protocol_ext',
  337. '.objc_class_ext',
  338. '.objc_property',
  339. '.objc_image_info',
  340. '.objc_cstring_object',
  341. '.objc_sel_fixup',
  342. '__DATA, __objc_data',
  343. '__DATA, __objc_const',
  344. '.objc_superrefs',
  345. '__DATA, __datacoal_nt,coalesced',
  346. '.objc_classlist',
  347. '.objc_nlclasslist',
  348. '.objc_catlist',
  349. '.obcj_nlcatlist',
  350. '.objc_protolist'
  351. );
  352. var
  353. sep : string[3];
  354. secname : string;
  355. begin
  356. if (cs_create_pic in current_settings.moduleswitches) and
  357. not(target_info.system in systems_darwin) then
  358. secname:=secnames_pic[atype]
  359. else
  360. secname:=secnames[atype];
  361. {$ifdef m68k}
  362. { old Amiga GNU AS doesn't support .section .fpc }
  363. if (atype=sec_fpc) and (target_info.system = system_m68k_amiga) then
  364. secname:=secnames[sec_data];
  365. {$endif}
  366. if (atype=sec_fpc) and (Copy(aname,1,3)='res') then
  367. begin
  368. result:=secname+'.'+aname;
  369. exit;
  370. end;
  371. if (atype=sec_threadvar) and
  372. (target_info.system in (systems_windows+systems_wince)) then
  373. secname:='.tls';
  374. { go32v2 stub only loads .text and .data sections, and allocates space for .bss.
  375. Thus, data which normally goes into .rodata and .rodata_norel sections must
  376. end up in .data section }
  377. if (atype in [sec_rodata,sec_rodata_norel]) and
  378. (target_info.system=system_i386_go32v2) then
  379. secname:='.data';
  380. { section type user gives the user full controll on the section name }
  381. if atype=sec_user then
  382. secname:=aname;
  383. if is_smart_section(atype) and (aname<>'') then
  384. begin
  385. case aorder of
  386. secorder_begin :
  387. sep:='.b_';
  388. secorder_end :
  389. sep:='.z_';
  390. else
  391. sep:='.n_';
  392. end;
  393. result:=secname+sep+aname
  394. end
  395. else
  396. result:=secname;
  397. end;
  398. function TGNUAssembler.sectionattrs_coff(atype:TAsmSectiontype):string;
  399. begin
  400. case atype of
  401. sec_code, sec_init, sec_fini, sec_stub:
  402. result:='x';
  403. { TODO: must be individual for each section }
  404. sec_user:
  405. result:='d';
  406. sec_data, sec_data_lazy, sec_data_nonlazy, sec_fpc,
  407. sec_idata2, sec_idata4, sec_idata5, sec_idata6, sec_idata7:
  408. result:='d';
  409. { TODO: these need a fix to become read-only }
  410. sec_rodata, sec_rodata_norel:
  411. result:='d';
  412. sec_bss:
  413. result:='b';
  414. { TODO: Somewhat questionable. FPC does not allow initialized threadvars,
  415. so no sense to mark it as containing data. But Windows allows it to
  416. contain data, and Linux even has .tdata and .tbss }
  417. sec_threadvar:
  418. result:='b';
  419. sec_pdata, sec_edata, sec_eh_frame, sec_toc:
  420. result:='r';
  421. sec_stab,sec_stabstr,
  422. sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev:
  423. result:='n';
  424. else
  425. result:=''; { defaults to data+load }
  426. end;
  427. end;
  428. function TGNUAssembler.sectionalignment_aix(atype:TAsmSectiontype;secalign: byte): string;
  429. var
  430. l: longint;
  431. begin
  432. if (secalign=0) or
  433. not(atype in [sec_code,sec_bss,sec_rodata_norel,sec_rodata,sec_data]) then
  434. begin
  435. result:='';
  436. exit;
  437. end;
  438. if not ispowerof2(secalign,l) then
  439. internalerror(2012022201);
  440. result:=tostr(l);
  441. end;
  442. procedure TGNUAssembler.WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:byte);
  443. var
  444. s : string;
  445. begin
  446. AsmLn;
  447. case target_info.system of
  448. system_i386_OS2,
  449. system_i386_EMX,
  450. system_m68k_amiga: ; { amiga has old GNU AS (2.14), which blews up from .section (KB) }
  451. system_powerpc_darwin,
  452. system_i386_darwin,
  453. system_i386_iphonesim,
  454. system_powerpc64_darwin,
  455. system_x86_64_darwin,
  456. system_arm_darwin,
  457. system_powerpc_aix,
  458. system_powerpc64_aix:
  459. begin
  460. if (atype in [sec_stub,sec_objc_data,sec_objc_const,sec_data_coalesced]) then
  461. AsmWrite('.section ');
  462. end
  463. else
  464. AsmWrite('.section ');
  465. end;
  466. s:=sectionname(atype,aname,aorder);
  467. AsmWrite(s);
  468. case atype of
  469. sec_fpc :
  470. if aname = 'resptrs' then
  471. AsmWrite(', "a", @progbits');
  472. sec_stub :
  473. begin
  474. case target_info.system of
  475. { there are processor-independent shortcuts available }
  476. { for this, namely .symbol_stub and .picsymbol_stub, but }
  477. { they don't work and gcc doesn't use them either... }
  478. system_powerpc_darwin,
  479. system_powerpc64_darwin:
  480. if (cs_create_pic in current_settings.moduleswitches) then
  481. AsmWriteln('__TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32')
  482. else
  483. AsmWriteln('__TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16');
  484. system_i386_darwin,
  485. system_i386_iphonesim:
  486. AsmWriteln('__IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5');
  487. system_arm_darwin:
  488. if (cs_create_pic in current_settings.moduleswitches) then
  489. AsmWriteln('__TEXT,__picsymbolstub4,symbol_stubs,none,16')
  490. else
  491. AsmWriteln('__TEXT,__symbol_stub4,symbol_stubs,none,12')
  492. { darwin/x86-64 uses RIP-based GOT addressing, no symbol stubs }
  493. else
  494. internalerror(2006031101);
  495. end;
  496. end;
  497. else
  498. { GNU AS won't recognize '.text.n_something' section name as belonging
  499. to '.text' and assigns default attributes to it, which is not
  500. always correct. We have to fix it.
  501. TODO: This likely applies to all systems which smartlink without
  502. creating libraries }
  503. if (target_info.system in [system_i386_win32,system_x86_64_win64]) and
  504. is_smart_section(atype) and (aname<>'') then
  505. begin
  506. s:=sectionattrs_coff(atype);
  507. if (s<>'') then
  508. AsmWrite(',"'+s+'"');
  509. end
  510. else if target_info.system in systems_aix then
  511. begin
  512. s:=sectionalignment_aix(atype,secalign);
  513. if s<>'' then
  514. AsmWrite(','+s);
  515. end;
  516. end;
  517. AsmLn;
  518. LastSecType:=atype;
  519. end;
  520. procedure TGNUAssembler.WriteDecodedUleb128(a: qword);
  521. var
  522. i,len : longint;
  523. buf : array[0..63] of byte;
  524. begin
  525. len:=EncodeUleb128(a,buf);
  526. for i:=0 to len-1 do
  527. begin
  528. if (i > 0) then
  529. AsmWrite(',');
  530. AsmWrite(tostr(buf[i]));
  531. end;
  532. end;
  533. procedure TGNUAssembler.WriteDecodedSleb128(a: int64);
  534. var
  535. i,len : longint;
  536. buf : array[0..255] of byte;
  537. begin
  538. len:=EncodeSleb128(a,buf);
  539. for i:=0 to len-1 do
  540. begin
  541. if (i > 0) then
  542. AsmWrite(',');
  543. AsmWrite(tostr(buf[i]));
  544. end;
  545. end;
  546. procedure TGNUAssembler.WriteTree(p:TAsmList);
  547. function needsObject(hp : tai_symbol) : boolean;
  548. begin
  549. needsObject :=
  550. (
  551. assigned(hp.next) and
  552. (tai(hp.next).typ in [ait_const,ait_datablock,
  553. ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit])
  554. ) or
  555. (hp.sym.typ=AT_DATA);
  556. end;
  557. procedure doalign(alignment: byte; use_op: boolean; fillop: byte; out last_align: longint);
  558. var
  559. i: longint;
  560. begin
  561. last_align:=alignment;
  562. if alignment>1 then
  563. begin
  564. if not(target_info.system in (systems_darwin+systems_aix)) then
  565. begin
  566. AsmWrite(#9'.balign '+tostr(alignment));
  567. if use_op then
  568. AsmWrite(','+tostr(fillop))
  569. {$ifdef x86}
  570. { force NOP as alignment op code }
  571. else if LastSecType=sec_code then
  572. AsmWrite(',0x90');
  573. {$endif x86}
  574. end
  575. else
  576. begin
  577. { darwin and aix as only support .align }
  578. if not ispowerof2(alignment,i) then
  579. internalerror(2003010305);
  580. AsmWrite(#9'.align '+tostr(i));
  581. last_align:=i;
  582. end;
  583. AsmLn;
  584. end;
  585. end;
  586. var
  587. ch : char;
  588. hp : tai;
  589. constdef : taiconst_type;
  590. s,t : string;
  591. i,pos,l : longint;
  592. InlineLevel : cardinal;
  593. last_align : longint;
  594. co : comp;
  595. sin : single;
  596. d : double;
  597. {$ifdef cpuextended}
  598. e : extended;
  599. {$endif cpuextended}
  600. do_line : boolean;
  601. sepChar : char;
  602. replaceforbidden: boolean;
  603. begin
  604. if not assigned(p) then
  605. exit;
  606. replaceforbidden:=target_asm.dollarsign<>'$';
  607. last_align := 2;
  608. InlineLevel:=0;
  609. { lineinfo is only needed for al_procedures (PFV) }
  610. do_line:=(cs_asm_source in current_settings.globalswitches) or
  611. ((cs_lineinfo in current_settings.moduleswitches)
  612. and (p=current_asmdata.asmlists[al_procedures]));
  613. hp:=tai(p.first);
  614. while assigned(hp) do
  615. begin
  616. prefetch(pointer(hp.next)^);
  617. if not(hp.typ in SkipLineInfo) then
  618. begin
  619. current_filepos:=tailineinfo(hp).fileinfo;
  620. { no line info for inlined code }
  621. if do_line and (inlinelevel=0) then
  622. WriteSourceLine(hp as tailineinfo);
  623. end;
  624. case hp.typ of
  625. ait_comment :
  626. Begin
  627. AsmWrite(target_asm.comment);
  628. AsmWritePChar(tai_comment(hp).str);
  629. AsmLn;
  630. End;
  631. ait_regalloc :
  632. begin
  633. if (cs_asm_regalloc in current_settings.globalswitches) then
  634. begin
  635. AsmWrite(#9+target_asm.comment+'Register ');
  636. repeat
  637. AsmWrite(std_regname(Tai_regalloc(hp).reg));
  638. if (hp.next=nil) or
  639. (tai(hp.next).typ<>ait_regalloc) or
  640. (tai_regalloc(hp.next).ratype<>tai_regalloc(hp).ratype) then
  641. break;
  642. hp:=tai(hp.next);
  643. AsmWrite(',');
  644. until false;
  645. AsmWrite(' ');
  646. AsmWriteLn(regallocstr[tai_regalloc(hp).ratype]);
  647. end;
  648. end;
  649. ait_tempalloc :
  650. begin
  651. if (cs_asm_tempalloc in current_settings.globalswitches) then
  652. WriteTempalloc(tai_tempalloc(hp));
  653. end;
  654. ait_align :
  655. begin
  656. doalign(tai_align_abstract(hp).aligntype,tai_align_abstract(hp).use_op,tai_align_abstract(hp).fillop,last_align);
  657. end;
  658. ait_section :
  659. begin
  660. if tai_section(hp).sectype<>sec_none then
  661. if replaceforbidden then
  662. WriteSection(tai_section(hp).sectype,ReplaceForbiddenAsmSymbolChars(tai_section(hp).name^),tai_section(hp).secorder,tai_section(hp).secalign)
  663. else
  664. WriteSection(tai_section(hp).sectype,tai_section(hp).name^,tai_section(hp).secorder,tai_section(hp).secalign)
  665. else
  666. begin
  667. {$ifdef EXTDEBUG}
  668. AsmWrite(target_asm.comment);
  669. AsmWriteln(' sec_none');
  670. {$endif EXTDEBUG}
  671. end;
  672. end;
  673. ait_datablock :
  674. begin
  675. if (target_info.system in systems_darwin) then
  676. begin
  677. { On Mac OS X you can't have common symbols in a shared library
  678. since those are in the TEXT section and the text section is
  679. read-only in shared libraries (so it can be shared among different
  680. processes). The alternate code creates some kind of common symbols
  681. in the data segment.
  682. }
  683. if tai_datablock(hp).is_global then
  684. begin
  685. asmwrite('.globl ');
  686. asmwriteln(tai_datablock(hp).sym.name);
  687. asmwriteln('.data');
  688. asmwrite('.zerofill __DATA, __common, ');
  689. asmwrite(tai_datablock(hp).sym.name);
  690. asmwriteln(', '+tostr(tai_datablock(hp).size)+','+tostr(last_align));
  691. if not(LastSecType in [sec_data,sec_none]) then
  692. writesection(LastSecType,'',secorder_default,1 shl last_align);
  693. end
  694. else
  695. begin
  696. asmwrite(#9'.lcomm'#9);
  697. asmwrite(tai_datablock(hp).sym.name);
  698. asmwrite(','+tostr(tai_datablock(hp).size));
  699. asmwrite(','+tostr(last_align));
  700. asmln;
  701. end;
  702. end
  703. else if target_info.system in systems_aix then
  704. begin
  705. if tai_datablock(hp).is_global then
  706. begin
  707. asmwrite(#9'.globl ');
  708. asmwriteln(ReplaceForbiddenAsmSymbolChars(tai_datablock(hp).sym.name));
  709. asmwrite(ReplaceForbiddenAsmSymbolChars(tai_datablock(hp).sym.name));
  710. asmwriteln(':');
  711. asmwrite(#9'.space ');
  712. asmwriteln(tostr(tai_datablock(hp).size));
  713. if not(LastSecType in [sec_data,sec_none]) then
  714. writesection(LastSecType,'',secorder_default,1 shl last_align);
  715. end
  716. else
  717. begin
  718. asmwrite(#9'.lcomm ');
  719. asmwrite(ReplaceForbiddenAsmSymbolChars(tai_datablock(hp).sym.name));
  720. asmwrite(',');
  721. asmwrite(tostr(tai_datablock(hp).size)+',');
  722. asmwrite('_data.bss_');
  723. end;
  724. end
  725. else
  726. begin
  727. {$ifdef USE_COMM_IN_BSS}
  728. if writingpackages then
  729. begin
  730. { The .comm is required for COMMON symbols. These are used
  731. in the shared library loading. All the symbols declared in
  732. the .so file need to resolve to the data allocated in the main
  733. program (PFV) }
  734. if tai_datablock(hp).is_global then
  735. begin
  736. asmwrite(#9'.comm'#9);
  737. if replaceforbidden then
  738. asmwrite(ReplaceForbiddenAsmSymbolChars(tai_datablock(hp).sym.name))
  739. else
  740. asmwrite(tai_datablock(hp).sym.name);
  741. asmwrite(','+tostr(tai_datablock(hp).size));
  742. asmwrite(','+tostr(last_align));
  743. asmln;
  744. end
  745. else
  746. begin
  747. asmwrite(#9'.lcomm'#9);
  748. if replaceforbidden then
  749. asmwrite(ReplaceForbiddenAsmSymbolChars(tai_datablock(hp).sym.name));
  750. else
  751. asmwrite(tai_datablock(hp).sym.name);
  752. asmwrite(','+tostr(tai_datablock(hp).size));
  753. asmwrite(','+tostr(last_align));
  754. asmln;
  755. end
  756. end
  757. else
  758. {$endif USE_COMM_IN_BSS}
  759. begin
  760. if Tai_datablock(hp).is_global then
  761. begin
  762. asmwrite(#9'.globl ');
  763. if replaceforbidden then
  764. asmwriteln(ReplaceForbiddenAsmSymbolChars(Tai_datablock(hp).sym.name))
  765. else
  766. asmwriteln(Tai_datablock(hp).sym.name);
  767. end;
  768. if (target_info.system <> system_arm_linux) then
  769. sepChar := '@'
  770. else
  771. sepChar := '%';
  772. if replaceforbidden then
  773. begin
  774. if (tf_needs_symbol_type in target_info.flags) then
  775. asmwriteln(#9'.type '+ReplaceForbiddenAsmSymbolChars(Tai_datablock(hp).sym.name)+','+sepChar+'object');
  776. if (tf_needs_symbol_size in target_info.flags) and (tai_datablock(hp).size > 0) then
  777. asmwriteln(#9'.size '+ReplaceForbiddenAsmSymbolChars(Tai_datablock(hp).sym.name)+','+tostr(Tai_datablock(hp).size));
  778. asmwrite(ReplaceForbiddenAsmSymbolChars(Tai_datablock(hp).sym.name))
  779. end
  780. else
  781. begin
  782. if (tf_needs_symbol_type in target_info.flags) then
  783. asmwriteln(#9'.type '+Tai_datablock(hp).sym.name+','+sepChar+'object');
  784. if (tf_needs_symbol_size in target_info.flags) and (tai_datablock(hp).size > 0) then
  785. asmwriteln(#9'.size '+Tai_datablock(hp).sym.name+','+tostr(Tai_datablock(hp).size));
  786. asmwrite(Tai_datablock(hp).sym.name);
  787. end;
  788. asmwriteln(':');
  789. asmwriteln(#9'.zero '+tostr(Tai_datablock(hp).size));
  790. end;
  791. end;
  792. end;
  793. ait_const:
  794. begin
  795. constdef:=tai_const(hp).consttype;
  796. case constdef of
  797. {$ifndef cpu64bitaddr}
  798. aitconst_128bit :
  799. begin
  800. internalerror(200404291);
  801. end;
  802. aitconst_64bit :
  803. begin
  804. if assigned(tai_const(hp).sym) then
  805. internalerror(200404292);
  806. if not(target_info.system in systems_aix) then
  807. begin
  808. AsmWrite(ait_const2str[aitconst_32bit]);
  809. if target_info.endian = endian_little then
  810. begin
  811. AsmWrite(tostr(longint(lo(tai_const(hp).value))));
  812. AsmWrite(',');
  813. AsmWrite(tostr(longint(hi(tai_const(hp).value))));
  814. end
  815. else
  816. begin
  817. AsmWrite(tostr(longint(hi(tai_const(hp).value))));
  818. AsmWrite(',');
  819. AsmWrite(tostr(longint(lo(tai_const(hp).value))));
  820. end;
  821. end
  822. else
  823. WriteAixIntConst(tai_const(hp));
  824. AsmLn;
  825. end;
  826. {$endif cpu64bitaddr}
  827. aitconst_uleb128bit,
  828. aitconst_sleb128bit,
  829. {$ifdef cpu64bitaddr}
  830. aitconst_128bit,
  831. aitconst_64bit,
  832. {$endif cpu64bitaddr}
  833. aitconst_32bit,
  834. aitconst_16bit,
  835. aitconst_8bit,
  836. aitconst_rva_symbol,
  837. aitconst_secrel32_symbol,
  838. aitconst_darwin_dwarf_delta32,
  839. aitconst_darwin_dwarf_delta64,
  840. aitconst_half16bit,
  841. aitconst_16bit_unaligned,
  842. aitconst_32bit_unaligned,
  843. aitconst_64bit_unaligned:
  844. begin
  845. { the AIX assembler (and for compatibility, the GNU
  846. assembler when targeting AIX) automatically aligns
  847. .short/.long/.llong to a multiple of 2/4/8 bytes. We
  848. don't want that, since this may be data inside a packed
  849. record -> use .vbyte instead (byte stream of fixed
  850. length) }
  851. if (target_info.system in systems_aix) and
  852. (constdef in [aitconst_128bit,aitconst_64bit,aitconst_32bit,aitconst_16bit]) and
  853. not assigned(tai_const(hp).sym) then
  854. begin
  855. WriteAixIntConst(tai_const(hp));
  856. end
  857. else if (target_info.system in systems_darwin) and
  858. (constdef in [aitconst_uleb128bit,aitconst_sleb128bit]) then
  859. begin
  860. AsmWrite(ait_const2str[aitconst_8bit]);
  861. case tai_const(hp).consttype of
  862. aitconst_uleb128bit:
  863. WriteDecodedUleb128(qword(tai_const(hp).value));
  864. aitconst_sleb128bit:
  865. WriteDecodedSleb128(int64(tai_const(hp).value));
  866. end
  867. end
  868. else
  869. begin
  870. if (constdef in ait_unaligned_consts) and
  871. (target_info.system in use_ua_sparc_systems) then
  872. AsmWrite(ait_ua_sparc_const2str[constdef])
  873. else if (constdef in ait_unaligned_consts) and
  874. (target_info.system in use_ua_alpha_systems) then
  875. AsmWrite(ait_ua_alpha_const2str[constdef])
  876. else if (constdef in ait_unaligned_consts) and
  877. (target_info.system in use_ua_elf_systems) then
  878. AsmWrite(ait_ua_elf_const2str[constdef])
  879. else if not(target_info.system in systems_aix) or
  880. (constdef<>aitconst_64bit) then
  881. AsmWrite(ait_const2str[constdef])
  882. else
  883. { can't use .llong, because that forces 8 byte
  884. alignnment and we sometimes store addresses on
  885. 4-byte aligned addresses (e.g. in the RTTI) }
  886. AsmWrite('.vbyte'#9'8,');
  887. l:=0;
  888. t := '';
  889. repeat
  890. if assigned(tai_const(hp).sym) then
  891. begin
  892. if assigned(tai_const(hp).endsym) then
  893. begin
  894. if (constdef in [aitconst_darwin_dwarf_delta32,aitconst_darwin_dwarf_delta64]) then
  895. begin
  896. s := NextSetLabel;
  897. t := #9'.set '+s+','+tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name;
  898. end
  899. else
  900. s:=tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name
  901. end
  902. else
  903. s:=tai_const(hp).sym.name;
  904. if replaceforbidden then
  905. s:=ReplaceForbiddenAsmSymbolChars(s);
  906. if tai_const(hp).value<>0 then
  907. s:=s+tostr_with_plus(tai_const(hp).value);
  908. end
  909. else
  910. {$ifdef cpu64bitaddr}
  911. s:=tostr(tai_const(hp).value);
  912. {$else cpu64bitaddr}
  913. { 64 bit constants are already handled above in this case }
  914. s:=tostr(longint(tai_const(hp).value));
  915. {$endif cpu64bitaddr}
  916. if constdef = aitconst_half16bit then
  917. s:='('+s+')/2';
  918. AsmWrite(s);
  919. inc(l,length(s));
  920. { Values with symbols are written on a single line to improve
  921. reading of the .s file (PFV) }
  922. if assigned(tai_const(hp).sym) or
  923. not(LastSecType in [sec_data,sec_rodata,sec_rodata_norel]) or
  924. (l>line_length) or
  925. (hp.next=nil) or
  926. (tai(hp.next).typ<>ait_const) or
  927. (tai_const(hp.next).consttype<>constdef) or
  928. assigned(tai_const(hp.next).sym) then
  929. break;
  930. hp:=tai(hp.next);
  931. AsmWrite(',');
  932. until false;
  933. if (t <> '') then
  934. begin
  935. AsmLn;
  936. AsmWrite(t);
  937. end;
  938. end;
  939. AsmLn;
  940. end;
  941. else
  942. internalerror(200704251);
  943. end;
  944. end;
  945. { the "and defined(FPC_HAS_TYPE_EXTENDED)" isn't optimal but currently the only solution
  946. it prevents proper cross compilation to i386 though
  947. }
  948. {$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
  949. ait_real_80bit :
  950. begin
  951. if do_line then
  952. AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_real_80bit(hp).value));
  953. { Make sure e is a extended type, bestreal could be
  954. a different type (bestreal) !! (PFV) }
  955. e:=tai_real_80bit(hp).value;
  956. AsmWrite(#9'.byte'#9);
  957. for i:=0 to 9 do
  958. begin
  959. if i<>0 then
  960. AsmWrite(',');
  961. AsmWrite(tostr(t80bitarray(e)[i]));
  962. end;
  963. for i:=11 to tai_real_80bit(hp).savesize do
  964. AsmWrite(',0');
  965. AsmLn;
  966. end;
  967. {$endif cpuextended}
  968. ait_real_64bit :
  969. begin
  970. if do_line then
  971. AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
  972. d:=tai_real_64bit(hp).value;
  973. { swap the values to correct endian if required }
  974. if source_info.endian <> target_info.endian then
  975. swap64bitarray(t64bitarray(d));
  976. AsmWrite(#9'.byte'#9);
  977. {$ifdef arm}
  978. if tai_real_64bit(hp).formatoptions=fo_hiloswapped then
  979. begin
  980. for i:=4 to 7 do
  981. begin
  982. if i<>4 then
  983. AsmWrite(',');
  984. AsmWrite(tostr(t64bitarray(d)[i]));
  985. end;
  986. for i:=0 to 3 do
  987. begin
  988. AsmWrite(',');
  989. AsmWrite(tostr(t64bitarray(d)[i]));
  990. end;
  991. end
  992. else
  993. {$endif arm}
  994. begin
  995. for i:=0 to 7 do
  996. begin
  997. if i<>0 then
  998. AsmWrite(',');
  999. AsmWrite(tostr(t64bitarray(d)[i]));
  1000. end;
  1001. end;
  1002. AsmLn;
  1003. end;
  1004. ait_real_32bit :
  1005. begin
  1006. if do_line then
  1007. AsmWriteLn(target_asm.comment+'value: '+single2str(tai_real_32bit(hp).value));
  1008. sin:=tai_real_32bit(hp).value;
  1009. { swap the values to correct endian if required }
  1010. if source_info.endian <> target_info.endian then
  1011. swap32bitarray(t32bitarray(sin));
  1012. AsmWrite(#9'.byte'#9);
  1013. for i:=0 to 3 do
  1014. begin
  1015. if i<>0 then
  1016. AsmWrite(',');
  1017. AsmWrite(tostr(t32bitarray(sin)[i]));
  1018. end;
  1019. AsmLn;
  1020. end;
  1021. ait_comp_64bit :
  1022. begin
  1023. if do_line then
  1024. AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_comp_64bit(hp).value));
  1025. AsmWrite(#9'.byte'#9);
  1026. co:=comp(tai_comp_64bit(hp).value);
  1027. { swap the values to correct endian if required }
  1028. if source_info.endian <> target_info.endian then
  1029. swap64bitarray(t64bitarray(co));
  1030. for i:=0 to 7 do
  1031. begin
  1032. if i<>0 then
  1033. AsmWrite(',');
  1034. AsmWrite(tostr(t64bitarray(co)[i]));
  1035. end;
  1036. AsmLn;
  1037. end;
  1038. ait_string :
  1039. begin
  1040. pos:=0;
  1041. if not(target_info.system in systems_aix) then
  1042. begin
  1043. for i:=1 to tai_string(hp).len do
  1044. begin
  1045. if pos=0 then
  1046. begin
  1047. AsmWrite(#9'.ascii'#9'"');
  1048. pos:=20;
  1049. end;
  1050. ch:=tai_string(hp).str[i-1];
  1051. case ch of
  1052. #0, {This can't be done by range, because a bug in FPC}
  1053. #1..#31,
  1054. #128..#255 : s:='\'+tostr(ord(ch) shr 6)+tostr((ord(ch) and 63) shr 3)+tostr(ord(ch) and 7);
  1055. '"' : s:='\"';
  1056. '\' : s:='\\';
  1057. else
  1058. s:=ch;
  1059. end;
  1060. AsmWrite(s);
  1061. inc(pos,length(s));
  1062. if (pos>line_length) or (i=tai_string(hp).len) then
  1063. begin
  1064. AsmWriteLn('"');
  1065. pos:=0;
  1066. end;
  1067. end;
  1068. end
  1069. else
  1070. WriteAixStringConst(tai_string(hp));
  1071. end;
  1072. ait_label :
  1073. begin
  1074. if (tai_label(hp).labsym.is_used) then
  1075. begin
  1076. if (tai_label(hp).labsym.bind=AB_PRIVATE_EXTERN) then
  1077. begin
  1078. AsmWrite(#9'.private_extern ');
  1079. AsmWriteln(tai_label(hp).labsym.name);
  1080. end;
  1081. if tai_label(hp).labsym.bind in [AB_GLOBAL,AB_PRIVATE_EXTERN] then
  1082. begin
  1083. AsmWrite('.globl'#9);
  1084. if replaceforbidden then
  1085. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_label(hp).labsym.name))
  1086. else
  1087. AsmWriteLn(tai_label(hp).labsym.name);
  1088. end;
  1089. if replaceforbidden then
  1090. AsmWrite(ReplaceForbiddenAsmSymbolChars(tai_label(hp).labsym.name))
  1091. else
  1092. AsmWrite(tai_label(hp).labsym.name);
  1093. AsmWriteLn(':');
  1094. end;
  1095. end;
  1096. ait_symbol :
  1097. begin
  1098. if (tai_symbol(hp).sym.bind=AB_PRIVATE_EXTERN) then
  1099. begin
  1100. AsmWrite(#9'.private_extern ');
  1101. if replaceforbidden then
  1102. AsmWriteln(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name))
  1103. else
  1104. AsmWriteln(tai_symbol(hp).sym.name);
  1105. end;
  1106. if (target_info.system = system_powerpc64_linux) and
  1107. (tai_symbol(hp).sym.typ = AT_FUNCTION) and (cs_profile in current_settings.moduleswitches) then
  1108. AsmWriteLn('.globl _mcount');
  1109. if tai_symbol(hp).is_global then
  1110. begin
  1111. AsmWrite('.globl'#9);
  1112. if replaceforbidden then
  1113. AsmWriteln(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name))
  1114. else
  1115. AsmWriteln(tai_symbol(hp).sym.name);
  1116. end;
  1117. if (target_info.system = system_powerpc64_linux) and
  1118. (tai_symbol(hp).sym.typ = AT_FUNCTION) then
  1119. begin
  1120. AsmWriteLn('.section ".opd", "aw"');
  1121. AsmWriteLn('.align 3');
  1122. AsmWriteLn(tai_symbol(hp).sym.name + ':');
  1123. AsmWriteLn('.quad .' + tai_symbol(hp).sym.name + ', .TOC.@tocbase, 0');
  1124. AsmWriteLn('.previous');
  1125. AsmWriteLn('.size ' + tai_symbol(hp).sym.name + ', 24');
  1126. if (tai_symbol(hp).is_global) then
  1127. AsmWriteLn('.globl .' + tai_symbol(hp).sym.name);
  1128. AsmWriteLn('.type .' + tai_symbol(hp).sym.name + ', @function');
  1129. { the dotted name is the name of the actual function entry }
  1130. AsmWrite('.');
  1131. end
  1132. else if (target_info.system in systems_aix) and
  1133. (tai_symbol(hp).sym.typ = AT_FUNCTION) then
  1134. begin
  1135. if target_info.system=system_powerpc_aix then
  1136. begin
  1137. s:=#9'.long .';
  1138. ch:='2';
  1139. end
  1140. else
  1141. begin
  1142. s:=#9'.llong .';
  1143. ch:='3';
  1144. end;
  1145. AsmWriteLn(#9'.csect '+ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name)+'[DS],'+ch);
  1146. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name)+':');
  1147. AsmWriteln(s+ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name)+', TOC[tc0], 0');
  1148. AsmWriteln(#9'.csect .text[PR]');
  1149. if (tai_symbol(hp).is_global) then
  1150. AsmWriteLn('.globl .'+ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name))
  1151. else
  1152. AsmWriteLn('.lglobl .'+ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name));
  1153. { the dotted name is the name of the actual function entry }
  1154. AsmWrite('.');
  1155. end
  1156. else
  1157. begin
  1158. if (target_info.system <> system_arm_linux) then
  1159. sepChar := '@'
  1160. else
  1161. sepChar := '#';
  1162. if (tf_needs_symbol_type in target_info.flags) then
  1163. begin
  1164. AsmWrite(#9'.type'#9 + tai_symbol(hp).sym.name);
  1165. if (needsObject(tai_symbol(hp))) then
  1166. AsmWriteLn(',' + sepChar + 'object')
  1167. else
  1168. AsmWriteLn(',' + sepChar + 'function');
  1169. end;
  1170. end;
  1171. if replaceforbidden then
  1172. if not(tai_symbol(hp).has_value) then
  1173. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name + ':'))
  1174. else
  1175. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name + '=' + tostr(tai_symbol(hp).value)))
  1176. else if not(tai_symbol(hp).has_value) then
  1177. AsmWriteLn(tai_symbol(hp).sym.name + ':')
  1178. else
  1179. AsmWriteLn(tai_symbol(hp).sym.name + '=' + tostr(tai_symbol(hp).value));
  1180. end;
  1181. {$ifdef arm}
  1182. ait_thumb_func:
  1183. begin
  1184. AsmWriteLn(#9'.thumb_func');
  1185. end;
  1186. {$endif arm}
  1187. ait_ent:
  1188. begin
  1189. AsmWrite(#9'.ent'#9);
  1190. if replaceforbidden then
  1191. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_ent(hp).Name))
  1192. else
  1193. AsmWriteLn(tai_ent(hp).Name);
  1194. end;
  1195. ait_ent_end:
  1196. begin
  1197. AsmWrite(#9'.end'#9);
  1198. if replaceforbidden then
  1199. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_ent_end(hp).Name))
  1200. else
  1201. AsmWriteLn(tai_ent_end(hp).Name);
  1202. end;
  1203. ait_symbol_end :
  1204. begin
  1205. if tf_needs_symbol_size in target_info.flags then
  1206. begin
  1207. s:=target_asm.labelprefix+'e'+tostr(symendcount);
  1208. inc(symendcount);
  1209. AsmWriteLn(s+':');
  1210. AsmWrite(#9'.size'#9);
  1211. if (target_info.system = system_powerpc64_linux) and (tai_symbol_end(hp).sym.typ = AT_FUNCTION) then
  1212. AsmWrite('.');
  1213. if replaceforbidden then
  1214. AsmWrite(ReplaceForbiddenAsmSymbolChars(tai_symbol_end(hp).sym.name))
  1215. else
  1216. AsmWrite(tai_symbol_end(hp).sym.name);
  1217. AsmWrite(', '+s+' - ');
  1218. if (target_info.system = system_powerpc64_linux) and (tai_symbol_end(hp).sym.typ = AT_FUNCTION) then
  1219. AsmWrite('.');
  1220. if replaceforbidden then
  1221. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbol_end(hp).sym.name))
  1222. else
  1223. AsmWriteLn(tai_symbol_end(hp).sym.name);
  1224. end;
  1225. end;
  1226. ait_instruction :
  1227. begin
  1228. WriteInstruction(hp);
  1229. end;
  1230. ait_stab :
  1231. begin
  1232. if assigned(tai_stab(hp).str) then
  1233. begin
  1234. AsmWrite(#9'.'+stabtypestr[tai_stab(hp).stabtype]+' ');
  1235. AsmWritePChar(tai_stab(hp).str);
  1236. AsmLn;
  1237. end;
  1238. end;
  1239. ait_force_line,
  1240. ait_function_name :
  1241. ;
  1242. ait_cutobject :
  1243. begin
  1244. if SmartAsm then
  1245. begin
  1246. { only reset buffer if nothing has changed }
  1247. if AsmSize=AsmStartSize then
  1248. AsmClear
  1249. else
  1250. begin
  1251. AsmClose;
  1252. DoAssemble;
  1253. AsmCreate(tai_cutobject(hp).place);
  1254. end;
  1255. { avoid empty files }
  1256. while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
  1257. begin
  1258. if tai(hp.next).typ=ait_section then
  1259. LastSecType:=tai_section(hp.next).sectype;
  1260. hp:=tai(hp.next);
  1261. end;
  1262. if LastSecType<>sec_none then
  1263. WriteSection(LastSecType,'',secorder_default,last_align);
  1264. AsmStartSize:=AsmSize;
  1265. end;
  1266. end;
  1267. ait_marker :
  1268. if tai_marker(hp).kind=mark_NoLineInfoStart then
  1269. inc(InlineLevel)
  1270. else if tai_marker(hp).kind=mark_NoLineInfoEnd then
  1271. dec(InlineLevel);
  1272. ait_directive :
  1273. begin
  1274. WriteDirectiveName(tai_directive(hp).directive);
  1275. if tai_directive(hp).name <>'' then
  1276. AsmWrite(tai_directive(hp).name);
  1277. AsmLn;
  1278. end;
  1279. ait_seh_directive :
  1280. begin
  1281. {$ifdef TEST_WIN64_SEH}
  1282. AsmWrite(sehdirectivestr[tai_seh_directive(hp).kind]);
  1283. case tai_seh_directive(hp).datatype of
  1284. sd_none:;
  1285. sd_string:
  1286. begin
  1287. AsmWrite(' '+tai_seh_directive(hp).data.name^);
  1288. if (tai_seh_directive(hp).data.flags and 1)<>0 then
  1289. AsmWrite(',@except');
  1290. if (tai_seh_directive(hp).data.flags and 2)<>0 then
  1291. AsmWrite(',@unwind');
  1292. end;
  1293. sd_reg:
  1294. AsmWrite(' '+gas_regname(tai_seh_directive(hp).data.reg));
  1295. sd_offset:
  1296. AsmWrite(' '+tostr(tai_seh_directive(hp).data.offset));
  1297. sd_regoffset:
  1298. AsmWrite(' '+gas_regname(tai_seh_directive(hp).data.reg)+', '+
  1299. tostr(tai_seh_directive(hp).data.offset));
  1300. end;
  1301. AsmLn;
  1302. {$endif TEST_WIN64_SEH}
  1303. end;
  1304. ait_varloc:
  1305. begin
  1306. if tai_varloc(hp).newlocationhi<>NR_NO then
  1307. AsmWrite(strpnew('Var '+tai_varloc(hp).varsym.realname+' located in register '+
  1308. std_regname(tai_varloc(hp).newlocationhi)+':'+std_regname(tai_varloc(hp).newlocation)))
  1309. else
  1310. AsmWrite(strpnew('Var '+tai_varloc(hp).varsym.realname+' located in register '+
  1311. std_regname(tai_varloc(hp).newlocation)));
  1312. AsmLn;
  1313. end;
  1314. else
  1315. internalerror(2006012201);
  1316. end;
  1317. hp:=tai(hp.next);
  1318. end;
  1319. end;
  1320. procedure TGNUAssembler.WriteExtraHeader;
  1321. begin
  1322. end;
  1323. procedure TGNUAssembler.WriteExtraFooter;
  1324. begin
  1325. end;
  1326. procedure TGNUAssembler.WriteInstruction(hp: tai);
  1327. begin
  1328. InstrWriter.WriteInstruction(hp);
  1329. end;
  1330. procedure TGNUAssembler.WriteWeakSymbolDef(s: tasmsymbol);
  1331. begin
  1332. AsmWriteLn(#9'.weak '+s.name);
  1333. end;
  1334. procedure TGNUAssembler.WriteAixStringConst(hp: tai_string);
  1335. type
  1336. tterminationkind = (term_none,term_string,term_nostring);
  1337. var
  1338. i: longint;
  1339. pos: longint;
  1340. s: string;
  1341. ch: char;
  1342. instring: boolean;
  1343. procedure newstatement(terminationkind: tterminationkind);
  1344. begin
  1345. case terminationkind of
  1346. term_none: ;
  1347. term_string:
  1348. AsmWriteLn('"');
  1349. term_nostring:
  1350. AsmLn;
  1351. end;
  1352. AsmWrite(#9'.byte'#9);
  1353. pos:=20;
  1354. instring:=false;
  1355. end;
  1356. begin
  1357. pos:=0;
  1358. for i:=1 to hp.len do
  1359. begin
  1360. if pos=0 then
  1361. newstatement(term_none);
  1362. ch:=hp.str[i-1];
  1363. case ch of
  1364. #0..#31,
  1365. #127..#255 :
  1366. begin
  1367. if instring then
  1368. newstatement(term_string);
  1369. if pos=20 then
  1370. s:=tostr(ord(ch))
  1371. else
  1372. s:=', '+tostr(ord(ch))
  1373. end;
  1374. '"' :
  1375. if instring then
  1376. s:='""'
  1377. else
  1378. begin
  1379. if pos<>20 then
  1380. newstatement(term_nostring);
  1381. s:='"""';
  1382. instring:=true;
  1383. end;
  1384. else
  1385. if not instring then
  1386. begin
  1387. if (pos<>20) then
  1388. newstatement(term_nostring);
  1389. s:='"'+ch;
  1390. instring:=true;
  1391. end
  1392. else
  1393. s:=ch;
  1394. end;
  1395. AsmWrite(s);
  1396. inc(pos,length(s));
  1397. if (pos>line_length) or (i=tai_string(hp).len) then
  1398. begin
  1399. if instring then
  1400. AsmWriteLn('"')
  1401. else
  1402. AsmLn;
  1403. pos:=0;
  1404. end;
  1405. end;
  1406. end;
  1407. procedure TGNUAssembler.WriteAixIntConst(hp: tai_const);
  1408. var
  1409. pos, size: longint;
  1410. begin
  1411. { only big endian AIX supported for now }
  1412. if target_info.endian<>endian_big then
  1413. internalerror(2012010401);
  1414. { limitation: can only write 4 bytes at a time }
  1415. pos:=0;
  1416. size:=tai_const(hp).size;
  1417. while pos<(size-4) do
  1418. begin
  1419. AsmWrite(#9'.vbyte'#9'4, ');
  1420. AsmWriteln(tostr(longint(tai_const(hp).value shr ((size-pos-4)*8))));
  1421. inc(pos,4);
  1422. end;
  1423. AsmWrite(#9'.vbyte'#9);
  1424. AsmWrite(tostr(size-pos));
  1425. AsmWrite(', ');
  1426. case size-pos of
  1427. 1: AsmWrite(tostr(byte(tai_const(hp).value)));
  1428. 2: AsmWrite(tostr(word(tai_const(hp).value)));
  1429. 4: AsmWrite(tostr(longint(tai_const(hp).value)));
  1430. else
  1431. internalerror(2012010402);
  1432. end;
  1433. end;
  1434. procedure TGNUAssembler.WriteUnalignedIntConst(hp: tai_const);
  1435. var
  1436. pos, size: longint;
  1437. begin
  1438. size:=tai_const(hp).size;
  1439. AsmWrite(#9'.byte'#9);
  1440. if target_info.endian=endian_big then
  1441. begin
  1442. pos:=size-1;
  1443. while pos>=0 do
  1444. begin
  1445. AsmWrite(tostr((tai_const(hp).value shr (pos*8)) and $ff));
  1446. dec(pos);
  1447. if pos>=0 then
  1448. AsmWrite(', ')
  1449. else
  1450. AsmLn;
  1451. end;
  1452. end
  1453. else
  1454. begin
  1455. pos:=0;
  1456. while pos<size do
  1457. begin
  1458. AsmWriteln(tostr((tai_const(hp).value shr (pos*8)) and $ff));
  1459. inc(pos);
  1460. if pos<=size then
  1461. AsmWrite(', ')
  1462. else
  1463. AsmLn;
  1464. end;
  1465. end;
  1466. AsmLn;
  1467. end;
  1468. procedure TGNUAssembler.WriteDirectiveName(dir: TAsmDirective);
  1469. begin
  1470. AsmWrite('.'+directivestr[dir]+' ');
  1471. end;
  1472. procedure TGNUAssembler.WriteAsmList;
  1473. var
  1474. n : string;
  1475. hal : tasmlisttype;
  1476. i: longint;
  1477. begin
  1478. {$ifdef EXTDEBUG}
  1479. if current_module.mainsource<>'' then
  1480. Comment(V_Debug,'Start writing gas-styled assembler output for '+current_module.mainsource);
  1481. {$endif}
  1482. if current_module.mainsource<>'' then
  1483. n:=ExtractFileName(current_module.mainsource)
  1484. else
  1485. n:=InputFileName;
  1486. { gcc does not add it either for Darwin. Grep for
  1487. TARGET_ASM_FILE_START_FILE_DIRECTIVE in gcc/config/*.h
  1488. }
  1489. if not(target_info.system in systems_darwin) then
  1490. AsmWriteLn(#9'.file "'+FixFileName(n)+'"');
  1491. WriteExtraHeader;
  1492. AsmStartSize:=AsmSize;
  1493. symendcount:=0;
  1494. for hal:=low(TasmlistType) to high(TasmlistType) do
  1495. begin
  1496. AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmlistTypeStr[hal]);
  1497. writetree(current_asmdata.asmlists[hal]);
  1498. AsmWriteLn(target_asm.comment+'End asmlist '+AsmlistTypeStr[hal]);
  1499. end;
  1500. { add weak symbol markers }
  1501. for i:=0 to current_asmdata.asmsymboldict.count-1 do
  1502. if (tasmsymbol(current_asmdata.asmsymboldict[i]).bind=AB_WEAK_EXTERNAL) then
  1503. writeweaksymboldef(tasmsymbol(current_asmdata.asmsymboldict[i]));
  1504. if create_smartlink_sections and
  1505. (target_info.system in systems_darwin) then
  1506. AsmWriteLn(#9'.subsections_via_symbols');
  1507. { "no executable stack" marker for Linux }
  1508. if (target_info.system in systems_linux) and
  1509. not(cs_executable_stack in current_settings.moduleswitches) then
  1510. begin
  1511. AsmWriteLn('.section .note.GNU-stack,"",%progbits');
  1512. end;
  1513. AsmLn;
  1514. {$ifdef EXTDEBUG}
  1515. if current_module.mainsource<>'' then
  1516. Comment(V_Debug,'Done writing gas-styled assembler output for '+current_module.mainsource);
  1517. {$endif EXTDEBUG}
  1518. end;
  1519. {****************************************************************************}
  1520. { Apple/GNU Assembler writer }
  1521. {****************************************************************************}
  1522. function TAppleGNUAssembler.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
  1523. begin
  1524. if (target_info.system in systems_darwin) then
  1525. case atype of
  1526. sec_bss:
  1527. { all bss (lcomm) symbols are automatically put in the right }
  1528. { place by using the lcomm assembler directive }
  1529. atype := sec_none;
  1530. sec_debug_frame,
  1531. sec_eh_frame:
  1532. begin
  1533. result := '.section __DWARF,__debug_info,regular,debug';
  1534. exit;
  1535. end;
  1536. sec_debug_line:
  1537. begin
  1538. result := '.section __DWARF,__debug_line,regular,debug';
  1539. exit;
  1540. end;
  1541. sec_debug_info:
  1542. begin
  1543. result := '.section __DWARF,__debug_info,regular,debug';
  1544. exit;
  1545. end;
  1546. sec_debug_abbrev:
  1547. begin
  1548. result := '.section __DWARF,__debug_abbrev,regular,debug';
  1549. exit;
  1550. end;
  1551. sec_rodata:
  1552. begin
  1553. result := '.const_data';
  1554. exit;
  1555. end;
  1556. sec_rodata_norel:
  1557. begin
  1558. result := '.const';
  1559. exit;
  1560. end;
  1561. sec_fpc:
  1562. begin
  1563. result := '.section __TEXT, .fpc, regular, no_dead_strip';
  1564. exit;
  1565. end;
  1566. sec_code:
  1567. begin
  1568. if (aname='fpc_geteipasebx') or
  1569. (aname='fpc_geteipasecx') then
  1570. begin
  1571. result:='.section __TEXT,__textcoal_nt,coalesced,pure_instructions'#10'.weak_definition '+aname+
  1572. #10'.private_extern '+aname;
  1573. exit;
  1574. end;
  1575. end;
  1576. sec_data_nonlazy:
  1577. begin
  1578. result:='.section __DATA, __nl_symbol_ptr,non_lazy_symbol_pointers';
  1579. exit;
  1580. end;
  1581. sec_data_lazy:
  1582. begin
  1583. result:='.section __DATA, __la_symbol_ptr,lazy_symbol_pointers';
  1584. exit;
  1585. end;
  1586. sec_init_func:
  1587. begin
  1588. result:='.section __DATA, __mod_init_func, mod_init_funcs';
  1589. exit;
  1590. end;
  1591. sec_term_func:
  1592. begin
  1593. result:='.section __DATA, __mod_term_func, mod_term_funcs';
  1594. exit;
  1595. end;
  1596. sec_objc_protocol_ext:
  1597. begin
  1598. result:='.section __OBJC, __protocol_ext, regular, no_dead_strip';
  1599. exit;
  1600. end;
  1601. sec_objc_class_ext:
  1602. begin
  1603. result:='.section __OBJC, __class_ext, regular, no_dead_strip';
  1604. exit;
  1605. end;
  1606. sec_objc_property:
  1607. begin
  1608. result:='.section __OBJC, __property, regular, no_dead_strip';
  1609. exit;
  1610. end;
  1611. sec_objc_image_info:
  1612. begin
  1613. result:='.section __OBJC, __image_info, regular, no_dead_strip';
  1614. exit;
  1615. end;
  1616. sec_objc_cstring_object:
  1617. begin
  1618. result:='.section __OBJC, __cstring_object, regular, no_dead_strip';
  1619. exit;
  1620. end;
  1621. sec_objc_sel_fixup:
  1622. begin
  1623. result:='.section __OBJC, __sel_fixup, regular, no_dead_strip';
  1624. exit;
  1625. end;
  1626. sec_objc_message_refs:
  1627. begin
  1628. if (target_info.system in systems_objc_nfabi) then
  1629. begin
  1630. result:='.section __DATA, __objc_selrefs, literal_pointers, no_dead_strip';
  1631. exit;
  1632. end;
  1633. end;
  1634. sec_objc_cls_refs:
  1635. begin
  1636. if (target_info.system in systems_objc_nfabi) then
  1637. begin
  1638. result:='.section __DATA, __objc_clsrefs, regular, no_dead_strip';
  1639. exit;
  1640. end;
  1641. end;
  1642. sec_objc_meth_var_names,
  1643. sec_objc_class_names:
  1644. begin
  1645. if (target_info.system in systems_objc_nfabi) then
  1646. begin
  1647. result:='.cstring';
  1648. exit
  1649. end;
  1650. end;
  1651. sec_objc_inst_meth,
  1652. sec_objc_cls_meth,
  1653. sec_objc_cat_inst_meth,
  1654. sec_objc_cat_cls_meth:
  1655. begin
  1656. if (target_info.system in systems_objc_nfabi) then
  1657. begin
  1658. result:='.section __DATA, __objc_const';
  1659. exit;
  1660. end;
  1661. end;
  1662. sec_objc_meta_class,
  1663. sec_objc_class:
  1664. begin
  1665. if (target_info.system in systems_objc_nfabi) then
  1666. begin
  1667. result:='.section __DATA, __objc_data';
  1668. exit;
  1669. end;
  1670. end;
  1671. sec_objc_sup_refs:
  1672. begin
  1673. result:='.section __DATA, __objc_superrefs, regular, no_dead_strip';
  1674. exit
  1675. end;
  1676. sec_objc_classlist:
  1677. begin
  1678. result:='.section __DATA, __objc_classlist, regular, no_dead_strip';
  1679. exit
  1680. end;
  1681. sec_objc_nlclasslist:
  1682. begin
  1683. result:='.section __DATA, __objc_nlclasslist, regular, no_dead_strip';
  1684. exit
  1685. end;
  1686. sec_objc_catlist:
  1687. begin
  1688. result:='.section __DATA, __objc_catlist, regular, no_dead_strip';
  1689. exit
  1690. end;
  1691. sec_objc_nlcatlist:
  1692. begin
  1693. result:='.section __DATA, __objc_nlcatlist, regular, no_dead_strip';
  1694. exit
  1695. end;
  1696. sec_objc_protolist:
  1697. begin
  1698. result:='.section __DATA, __objc_protolist, coalesced, no_dead_strip';
  1699. exit;
  1700. end;
  1701. end;
  1702. result := inherited sectionname(atype,aname,aorder);
  1703. end;
  1704. procedure TAppleGNUAssembler.WriteWeakSymbolDef(s: tasmsymbol);
  1705. begin
  1706. AsmWriteLn(#9'.weak_reference '+s.name);
  1707. end;
  1708. {****************************************************************************}
  1709. { a.out/GNU Assembler writer }
  1710. {****************************************************************************}
  1711. function TAoutGNUAssembler.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
  1712. const
  1713. (* Translation table - replace unsupported section types with basic ones. *)
  1714. SecXTable: array[TAsmSectionType] of TAsmSectionType = (
  1715. sec_none,
  1716. sec_none,
  1717. sec_code,
  1718. sec_data,
  1719. sec_data (* sec_rodata *),
  1720. sec_data (* sec_rodata_norel *),
  1721. sec_bss,
  1722. sec_data (* sec_threadvar *),
  1723. { used for wince exception handling }
  1724. sec_code (* sec_pdata *),
  1725. { used for darwin import stubs }
  1726. sec_code (* sec_stub *),
  1727. sec_data,(* sec_data_nonlazy *)
  1728. sec_data,(* sec_data_lazy *)
  1729. sec_data,(* sec_init_func *)
  1730. sec_data,(* sec_term_func *)
  1731. { stabs }
  1732. sec_stab,sec_stabstr,
  1733. { win32 }
  1734. sec_data (* sec_idata2 *),
  1735. sec_data (* sec_idata4 *),
  1736. sec_data (* sec_idata5 *),
  1737. sec_data (* sec_idata6 *),
  1738. sec_data (* sec_idata7 *),
  1739. sec_data (* sec_edata *),
  1740. { C++ exception handling unwinding (uses dwarf) }
  1741. sec_eh_frame,
  1742. { dwarf }
  1743. sec_debug_frame,
  1744. sec_debug_info,
  1745. sec_debug_line,
  1746. sec_debug_abbrev,
  1747. { ELF resources (+ references to stabs debug information sections) }
  1748. sec_code (* sec_fpc *),
  1749. { Table of contents section }
  1750. sec_code (* sec_toc *),
  1751. sec_code (* sec_init *),
  1752. sec_code (* sec_fini *),
  1753. sec_none (* sec_objc_class *),
  1754. sec_none (* sec_objc_meta_class *),
  1755. sec_none (* sec_objc_cat_cls_meth *),
  1756. sec_none (* sec_objc_cat_inst_meth *),
  1757. sec_none (* sec_objc_protocol *),
  1758. sec_none (* sec_objc_string_object *),
  1759. sec_none (* sec_objc_cls_meth *),
  1760. sec_none (* sec_objc_inst_meth *),
  1761. sec_none (* sec_objc_cls_refs *),
  1762. sec_none (* sec_objc_message_refs *),
  1763. sec_none (* sec_objc_symbols *),
  1764. sec_none (* sec_objc_category *),
  1765. sec_none (* sec_objc_class_vars *),
  1766. sec_none (* sec_objc_instance_vars *),
  1767. sec_none (* sec_objc_module_info *),
  1768. sec_none (* sec_objc_class_names *),
  1769. sec_none (* sec_objc_meth_var_types *),
  1770. sec_none (* sec_objc_meth_var_names *),
  1771. sec_none (* sec_objc_selector_strs *),
  1772. sec_none (* sec_objc_protocol_ext *),
  1773. sec_none (* sec_objc_class_ext *),
  1774. sec_none (* sec_objc_property *),
  1775. sec_none (* sec_objc_image_info *),
  1776. sec_none (* sec_objc_cstring_object *),
  1777. sec_none (* sec_objc_sel_fixup *),
  1778. sec_none (* sec_objc_data *),
  1779. sec_none (* sec_objc_const *),
  1780. sec_none (* sec_objc_sup_refs *),
  1781. sec_none (* sec_data_coalesced *),
  1782. sec_none (* sec_objc_classlist *),
  1783. sec_none (* sec_objc_nlclasslist *),
  1784. sec_none (* sec_objc_catlist *),
  1785. sec_none (* sec_objc_nlcatlist *),
  1786. sec_none (* sec_objc_protlist *)
  1787. );
  1788. begin
  1789. Result := inherited SectionName (SecXTable [AType], AName, AOrder);
  1790. end;
  1791. {****************************************************************************}
  1792. { Abstract Instruction Writer }
  1793. {****************************************************************************}
  1794. constructor TCPUInstrWriter.create(_owner: TGNUAssembler);
  1795. begin
  1796. inherited create;
  1797. owner := _owner;
  1798. end;
  1799. end.