aggas.pas 69 KB

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