aggas.pas 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895
  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,
  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_16bit_unaligned,
  838. aitconst_32bit_unaligned,
  839. aitconst_64bit_unaligned:
  840. begin
  841. { the AIX assembler (and for compatibility, the GNU
  842. assembler when targeting AIX) automatically aligns
  843. .short/.long/.llong to a multiple of 2/4/8 bytes. We
  844. don't want that, since this may be data inside a packed
  845. record -> use .vbyte instead (byte stream of fixed
  846. length) }
  847. if (target_info.system in systems_aix) and
  848. (constdef in [aitconst_128bit,aitconst_64bit,aitconst_32bit,aitconst_16bit]) and
  849. not assigned(tai_const(hp).sym) then
  850. begin
  851. WriteAixIntConst(tai_const(hp));
  852. end
  853. else if (target_info.system in systems_darwin) and
  854. (constdef in [aitconst_uleb128bit,aitconst_sleb128bit]) then
  855. begin
  856. AsmWrite(ait_const2str[aitconst_8bit]);
  857. case tai_const(hp).consttype of
  858. aitconst_uleb128bit:
  859. WriteDecodedUleb128(qword(tai_const(hp).value));
  860. aitconst_sleb128bit:
  861. WriteDecodedSleb128(int64(tai_const(hp).value));
  862. end
  863. end
  864. else
  865. begin
  866. if (constdef in ait_unaligned_consts) and
  867. (target_info.system in use_ua_sparc_systems) then
  868. AsmWrite(ait_ua_sparc_const2str[constdef])
  869. else if (constdef in ait_unaligned_consts) and
  870. (target_info.system in use_ua_alpha_systems) then
  871. AsmWrite(ait_ua_alpha_const2str[constdef])
  872. else if (constdef in ait_unaligned_consts) and
  873. (target_info.system in use_ua_elf_systems) then
  874. AsmWrite(ait_ua_elf_const2str[constdef])
  875. { we can also have unaligned pointers in packed record
  876. constants, which don't get translated into
  877. unaligned tai -> always use vbyte }
  878. else if target_info.system in systems_aix then
  879. AsmWrite(#9'.vbyte'#9+tostr(tai_const(hp).size)+',')
  880. else
  881. AsmWrite(ait_const2str[constdef]);
  882. l:=0;
  883. t := '';
  884. repeat
  885. if assigned(tai_const(hp).sym) then
  886. begin
  887. if assigned(tai_const(hp).endsym) then
  888. begin
  889. if (constdef in [aitconst_darwin_dwarf_delta32,aitconst_darwin_dwarf_delta64]) then
  890. begin
  891. s := NextSetLabel;
  892. t := #9'.set '+s+','+tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name;
  893. end
  894. else
  895. s:=tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name
  896. end
  897. else
  898. s:=tai_const(hp).sym.name;
  899. if replaceforbidden then
  900. s:=ReplaceForbiddenAsmSymbolChars(s);
  901. if tai_const(hp).value<>0 then
  902. s:=s+tostr_with_plus(tai_const(hp).value);
  903. end
  904. else
  905. {$ifdef cpu64bitaddr}
  906. s:=tostr(tai_const(hp).value);
  907. {$else cpu64bitaddr}
  908. { 64 bit constants are already handled above in this case }
  909. s:=tostr(longint(tai_const(hp).value));
  910. {$endif cpu64bitaddr}
  911. if constdef = aitconst_half16bit then
  912. s:='('+s+')/2';
  913. AsmWrite(s);
  914. inc(l,length(s));
  915. { Values with symbols are written on a single line to improve
  916. reading of the .s file (PFV) }
  917. if assigned(tai_const(hp).sym) or
  918. not(LastSecType in [sec_data,sec_rodata,sec_rodata_norel]) or
  919. (l>line_length) or
  920. (hp.next=nil) or
  921. (tai(hp.next).typ<>ait_const) or
  922. (tai_const(hp.next).consttype<>constdef) or
  923. assigned(tai_const(hp.next).sym) then
  924. break;
  925. hp:=tai(hp.next);
  926. AsmWrite(',');
  927. until false;
  928. if (t <> '') then
  929. begin
  930. AsmLn;
  931. AsmWrite(t);
  932. end;
  933. end;
  934. AsmLn;
  935. end;
  936. else
  937. internalerror(200704251);
  938. end;
  939. end;
  940. ait_realconst :
  941. begin
  942. WriteRealConstAsBytes(tai_realconst(hp),#9'.byte'#9,do_line);
  943. end;
  944. ait_string :
  945. begin
  946. pos:=0;
  947. if not(target_info.system in systems_aix) then
  948. begin
  949. for i:=1 to tai_string(hp).len do
  950. begin
  951. if pos=0 then
  952. begin
  953. AsmWrite(#9'.ascii'#9'"');
  954. pos:=20;
  955. end;
  956. ch:=tai_string(hp).str[i-1];
  957. case ch of
  958. #0, {This can't be done by range, because a bug in FPC}
  959. #1..#31,
  960. #128..#255 : s:='\'+tostr(ord(ch) shr 6)+tostr((ord(ch) and 63) shr 3)+tostr(ord(ch) and 7);
  961. '"' : s:='\"';
  962. '\' : s:='\\';
  963. else
  964. s:=ch;
  965. end;
  966. AsmWrite(s);
  967. inc(pos,length(s));
  968. if (pos>line_length) or (i=tai_string(hp).len) then
  969. begin
  970. AsmWriteLn('"');
  971. pos:=0;
  972. end;
  973. end;
  974. end
  975. else
  976. WriteAixStringConst(tai_string(hp));
  977. end;
  978. ait_label :
  979. begin
  980. if (tai_label(hp).labsym.is_used) then
  981. begin
  982. if (tai_label(hp).labsym.bind=AB_PRIVATE_EXTERN) then
  983. begin
  984. AsmWrite(#9'.private_extern ');
  985. AsmWriteln(tai_label(hp).labsym.name);
  986. end;
  987. if tai_label(hp).labsym.bind in [AB_GLOBAL,AB_PRIVATE_EXTERN] then
  988. begin
  989. {$ifdef arm}
  990. { do no change arm mode accidently, .globl seems to reset the mode }
  991. if GenerateThumbCode or GenerateThumb2Code then
  992. AsmWriteln(#9'.thumb_func'#9);
  993. {$endif arm}
  994. AsmWrite('.globl'#9);
  995. if replaceforbidden then
  996. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_label(hp).labsym.name))
  997. else
  998. AsmWriteLn(tai_label(hp).labsym.name);
  999. end;
  1000. if replaceforbidden then
  1001. AsmWrite(ReplaceForbiddenAsmSymbolChars(tai_label(hp).labsym.name))
  1002. else
  1003. AsmWrite(tai_label(hp).labsym.name);
  1004. AsmWriteLn(':');
  1005. end;
  1006. end;
  1007. ait_symbol :
  1008. begin
  1009. if (tai_symbol(hp).sym.bind=AB_PRIVATE_EXTERN) then
  1010. begin
  1011. AsmWrite(#9'.private_extern ');
  1012. if replaceforbidden then
  1013. AsmWriteln(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name))
  1014. else
  1015. AsmWriteln(tai_symbol(hp).sym.name);
  1016. end;
  1017. if (target_info.system=system_powerpc64_linux) and
  1018. (tai_symbol(hp).sym.typ=AT_FUNCTION) and
  1019. (cs_profile in current_settings.moduleswitches) then
  1020. AsmWriteLn('.globl _mcount');
  1021. if tai_symbol(hp).is_global then
  1022. begin
  1023. AsmWrite('.globl'#9);
  1024. if replaceforbidden then
  1025. AsmWriteln(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name))
  1026. else
  1027. AsmWriteln(tai_symbol(hp).sym.name);
  1028. end;
  1029. if (target_info.system=system_powerpc64_linux) and
  1030. use_dotted_functions and
  1031. (tai_symbol(hp).sym.typ=AT_FUNCTION) then
  1032. begin
  1033. AsmWriteLn('.section ".opd", "aw"');
  1034. AsmWriteLn('.align 3');
  1035. AsmWriteLn(tai_symbol(hp).sym.name + ':');
  1036. AsmWriteLn('.quad .' + tai_symbol(hp).sym.name + ', .TOC.@tocbase, 0');
  1037. AsmWriteLn('.previous');
  1038. AsmWriteLn('.size ' + tai_symbol(hp).sym.name + ', 24');
  1039. if (tai_symbol(hp).is_global) then
  1040. AsmWriteLn('.globl .' + tai_symbol(hp).sym.name);
  1041. AsmWriteLn('.type .' + tai_symbol(hp).sym.name + ', @function');
  1042. { the dotted name is the name of the actual function entry }
  1043. AsmWrite('.');
  1044. end
  1045. else if (target_info.system in systems_aix) and
  1046. (tai_symbol(hp).sym.typ = AT_FUNCTION) then
  1047. begin
  1048. if target_info.system=system_powerpc_aix then
  1049. begin
  1050. s:=#9'.long .';
  1051. ch:='2';
  1052. end
  1053. else
  1054. begin
  1055. s:=#9'.llong .';
  1056. ch:='3';
  1057. end;
  1058. AsmWriteLn(#9'.csect '+ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name)+'[DS],'+ch);
  1059. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name)+':');
  1060. AsmWriteln(s+ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name)+', TOC[tc0], 0');
  1061. AsmWriteln(#9'.csect .text[PR]');
  1062. if (tai_symbol(hp).is_global) then
  1063. AsmWriteLn('.globl .'+ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name))
  1064. else
  1065. AsmWriteLn('.lglobl .'+ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name));
  1066. { the dotted name is the name of the actual function entry }
  1067. AsmWrite('.');
  1068. end
  1069. else
  1070. begin
  1071. if ((target_info.system <> system_arm_linux) and (target_info.system <> system_arm_android)) then
  1072. sepChar := '@'
  1073. else
  1074. sepChar := '#';
  1075. if (tf_needs_symbol_type in target_info.flags) then
  1076. begin
  1077. AsmWrite(#9'.type'#9 + tai_symbol(hp).sym.name);
  1078. if (needsObject(tai_symbol(hp))) then
  1079. AsmWriteLn(',' + sepChar + 'object')
  1080. else
  1081. AsmWriteLn(',' + sepChar + 'function');
  1082. end;
  1083. end;
  1084. if replaceforbidden then
  1085. if not(tai_symbol(hp).has_value) then
  1086. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name + ':'))
  1087. else
  1088. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name + '=' + tostr(tai_symbol(hp).value)))
  1089. else if not(tai_symbol(hp).has_value) then
  1090. AsmWriteLn(tai_symbol(hp).sym.name + ':')
  1091. else
  1092. AsmWriteLn(tai_symbol(hp).sym.name + '=' + tostr(tai_symbol(hp).value));
  1093. end;
  1094. ait_symbolpair:
  1095. begin
  1096. AsmWrite(#9);
  1097. AsmWrite(symbolpairkindstr[tai_symbolpair(hp).kind]);
  1098. AsmWrite(' ');
  1099. if tai_symbolpair(hp).kind<>spk_localentry then
  1100. s:=', '
  1101. else
  1102. { the .localentry directive has to specify the size from the
  1103. start till here of the non-local entry code as second argument }
  1104. s:=', .-';
  1105. if replaceforbidden then
  1106. begin
  1107. { avoid string truncation }
  1108. AsmWrite(ReplaceForbiddenAsmSymbolChars(tai_symbolpair(hp).sym^)+s);
  1109. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbolpair(hp).value^));
  1110. end
  1111. else
  1112. begin
  1113. { avoid string truncation }
  1114. AsmWrite(tai_symbolpair(hp).sym^+s);
  1115. AsmWriteLn(tai_symbolpair(hp).value^);
  1116. end;
  1117. end;
  1118. ait_weak:
  1119. begin
  1120. if replaceforbidden then
  1121. AsmWriteLn(#9'.weak '+ReplaceForbiddenAsmSymbolChars(tai_weak(hp).sym^))
  1122. else
  1123. AsmWriteLn(#9'.weak '+tai_weak(hp).sym^);
  1124. end;
  1125. ait_symbol_end :
  1126. begin
  1127. if tf_needs_symbol_size in target_info.flags then
  1128. begin
  1129. s:=target_asm.labelprefix+'e'+tostr(symendcount);
  1130. inc(symendcount);
  1131. AsmWriteLn(s+':');
  1132. AsmWrite(#9'.size'#9);
  1133. if (target_info.system=system_powerpc64_linux) and
  1134. use_dotted_functions and
  1135. (tai_symbol_end(hp).sym.typ=AT_FUNCTION) then
  1136. AsmWrite('.');
  1137. if replaceforbidden then
  1138. AsmWrite(ReplaceForbiddenAsmSymbolChars(tai_symbol_end(hp).sym.name))
  1139. else
  1140. AsmWrite(tai_symbol_end(hp).sym.name);
  1141. AsmWrite(', '+s+' - ');
  1142. if (target_info.system=system_powerpc64_linux) and
  1143. use_dotted_functions and
  1144. (tai_symbol_end(hp).sym.typ=AT_FUNCTION) then
  1145. AsmWrite('.');
  1146. if replaceforbidden then
  1147. AsmWriteLn(ReplaceForbiddenAsmSymbolChars(tai_symbol_end(hp).sym.name))
  1148. else
  1149. AsmWriteLn(tai_symbol_end(hp).sym.name);
  1150. end;
  1151. end;
  1152. ait_instruction :
  1153. begin
  1154. WriteInstruction(hp);
  1155. end;
  1156. ait_stab :
  1157. begin
  1158. if assigned(tai_stab(hp).str) then
  1159. begin
  1160. AsmWrite(#9'.'+stabtypestr[tai_stab(hp).stabtype]+' ');
  1161. AsmWritePChar(tai_stab(hp).str);
  1162. AsmLn;
  1163. end;
  1164. end;
  1165. ait_force_line,
  1166. ait_function_name :
  1167. ;
  1168. ait_cutobject :
  1169. begin
  1170. if SmartAsm then
  1171. begin
  1172. { only reset buffer if nothing has changed }
  1173. if AsmSize=AsmStartSize then
  1174. AsmClear
  1175. else
  1176. begin
  1177. AsmClose;
  1178. DoAssemble;
  1179. AsmCreate(tai_cutobject(hp).place);
  1180. end;
  1181. { avoid empty files }
  1182. while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
  1183. begin
  1184. if tai(hp.next).typ=ait_section then
  1185. LastSecType:=tai_section(hp.next).sectype;
  1186. hp:=tai(hp.next);
  1187. end;
  1188. if LastSecType<>sec_none then
  1189. WriteSection(LastSecType,'',secorder_default,last_align);
  1190. AsmStartSize:=AsmSize;
  1191. end;
  1192. end;
  1193. ait_marker :
  1194. if tai_marker(hp).kind=mark_NoLineInfoStart then
  1195. inc(InlineLevel)
  1196. else if tai_marker(hp).kind=mark_NoLineInfoEnd then
  1197. dec(InlineLevel);
  1198. ait_directive :
  1199. begin
  1200. WriteDirectiveName(tai_directive(hp).directive);
  1201. if tai_directive(hp).name <>'' then
  1202. begin
  1203. if replaceforbidden then
  1204. AsmWrite(ReplaceForbiddenAsmSymbolChars(tai_directive(hp).name))
  1205. else
  1206. AsmWrite(tai_directive(hp).name);
  1207. end;
  1208. AsmLn;
  1209. end;
  1210. ait_seh_directive :
  1211. begin
  1212. {$ifndef DISABLE_WIN64_SEH}
  1213. AsmWrite(sehdirectivestr[tai_seh_directive(hp).kind]);
  1214. case tai_seh_directive(hp).datatype of
  1215. sd_none:;
  1216. sd_string:
  1217. begin
  1218. AsmWrite(' '+tai_seh_directive(hp).data.name^);
  1219. if (tai_seh_directive(hp).data.flags and 1)<>0 then
  1220. AsmWrite(',@except');
  1221. if (tai_seh_directive(hp).data.flags and 2)<>0 then
  1222. AsmWrite(',@unwind');
  1223. end;
  1224. sd_reg:
  1225. AsmWrite(' '+gas_regname(tai_seh_directive(hp).data.reg));
  1226. sd_offset:
  1227. AsmWrite(' '+tostr(tai_seh_directive(hp).data.offset));
  1228. sd_regoffset:
  1229. AsmWrite(' '+gas_regname(tai_seh_directive(hp).data.reg)+', '+
  1230. tostr(tai_seh_directive(hp).data.offset));
  1231. end;
  1232. AsmLn;
  1233. {$endif DISABLE_WIN64_SEH}
  1234. end;
  1235. ait_varloc:
  1236. begin
  1237. if tai_varloc(hp).newlocationhi<>NR_NO then
  1238. AsmWrite(strpnew('Var '+tai_varloc(hp).varsym.realname+' located in register '+
  1239. std_regname(tai_varloc(hp).newlocationhi)+':'+std_regname(tai_varloc(hp).newlocation)))
  1240. else
  1241. AsmWrite(strpnew('Var '+tai_varloc(hp).varsym.realname+' located in register '+
  1242. std_regname(tai_varloc(hp).newlocation)));
  1243. AsmLn;
  1244. end;
  1245. else
  1246. internalerror(2006012201);
  1247. end;
  1248. lasthp:=hp;
  1249. hp:=tai(hp.next);
  1250. end;
  1251. end;
  1252. procedure TGNUAssembler.WriteExtraHeader;
  1253. begin
  1254. end;
  1255. procedure TGNUAssembler.WriteExtraFooter;
  1256. begin
  1257. end;
  1258. procedure TGNUAssembler.WriteInstruction(hp: tai);
  1259. begin
  1260. InstrWriter.WriteInstruction(hp);
  1261. end;
  1262. procedure TGNUAssembler.WriteWeakSymbolDef(s: tasmsymbol);
  1263. begin
  1264. AsmWriteLn(#9'.weak '+s.name);
  1265. end;
  1266. procedure TGNUAssembler.WriteAixStringConst(hp: tai_string);
  1267. type
  1268. tterminationkind = (term_none,term_string,term_nostring);
  1269. var
  1270. i: longint;
  1271. pos: longint;
  1272. s: string;
  1273. ch: char;
  1274. instring: boolean;
  1275. procedure newstatement(terminationkind: tterminationkind);
  1276. begin
  1277. case terminationkind of
  1278. term_none: ;
  1279. term_string:
  1280. AsmWriteLn('"');
  1281. term_nostring:
  1282. AsmLn;
  1283. end;
  1284. AsmWrite(#9'.byte'#9);
  1285. pos:=20;
  1286. instring:=false;
  1287. end;
  1288. begin
  1289. pos:=0;
  1290. instring:=false;
  1291. for i:=1 to hp.len do
  1292. begin
  1293. if pos=0 then
  1294. newstatement(term_none);
  1295. ch:=hp.str[i-1];
  1296. case ch of
  1297. #0..#31,
  1298. #127..#255 :
  1299. begin
  1300. if instring then
  1301. newstatement(term_string);
  1302. if pos=20 then
  1303. s:=tostr(ord(ch))
  1304. else
  1305. s:=', '+tostr(ord(ch))
  1306. end;
  1307. '"' :
  1308. if instring then
  1309. s:='""'
  1310. else
  1311. begin
  1312. if pos<>20 then
  1313. newstatement(term_nostring);
  1314. s:='"""';
  1315. instring:=true;
  1316. end;
  1317. else
  1318. if not instring then
  1319. begin
  1320. if (pos<>20) then
  1321. newstatement(term_nostring);
  1322. s:='"'+ch;
  1323. instring:=true;
  1324. end
  1325. else
  1326. s:=ch;
  1327. end;
  1328. AsmWrite(s);
  1329. inc(pos,length(s));
  1330. if (pos>line_length) or (i=tai_string(hp).len) then
  1331. begin
  1332. if instring then
  1333. AsmWriteLn('"')
  1334. else
  1335. AsmLn;
  1336. pos:=0;
  1337. end;
  1338. end;
  1339. end;
  1340. procedure TGNUAssembler.WriteAixIntConst(hp: tai_const);
  1341. var
  1342. pos, size: longint;
  1343. begin
  1344. { only big endian AIX supported for now }
  1345. if target_info.endian<>endian_big then
  1346. internalerror(2012010401);
  1347. { limitation: can only write 4 bytes at a time }
  1348. pos:=0;
  1349. size:=tai_const(hp).size;
  1350. while pos<(size-4) do
  1351. begin
  1352. AsmWrite(#9'.vbyte'#9'4, ');
  1353. AsmWriteln(tostr(longint(tai_const(hp).value shr ((size-pos-4)*8))));
  1354. inc(pos,4);
  1355. end;
  1356. AsmWrite(#9'.vbyte'#9);
  1357. AsmWrite(tostr(size-pos));
  1358. AsmWrite(', ');
  1359. case size-pos of
  1360. 1: AsmWrite(tostr(byte(tai_const(hp).value)));
  1361. 2: AsmWrite(tostr(word(tai_const(hp).value)));
  1362. 4: AsmWrite(tostr(longint(tai_const(hp).value)));
  1363. else
  1364. internalerror(2012010402);
  1365. end;
  1366. end;
  1367. procedure TGNUAssembler.WriteUnalignedIntConst(hp: tai_const);
  1368. var
  1369. pos, size: longint;
  1370. begin
  1371. size:=tai_const(hp).size;
  1372. AsmWrite(#9'.byte'#9);
  1373. if target_info.endian=endian_big then
  1374. begin
  1375. pos:=size-1;
  1376. while pos>=0 do
  1377. begin
  1378. AsmWrite(tostr((tai_const(hp).value shr (pos*8)) and $ff));
  1379. dec(pos);
  1380. if pos>=0 then
  1381. AsmWrite(', ')
  1382. else
  1383. AsmLn;
  1384. end;
  1385. end
  1386. else
  1387. begin
  1388. pos:=0;
  1389. while pos<size do
  1390. begin
  1391. AsmWriteln(tostr((tai_const(hp).value shr (pos*8)) and $ff));
  1392. inc(pos);
  1393. if pos<=size then
  1394. AsmWrite(', ')
  1395. else
  1396. AsmLn;
  1397. end;
  1398. end;
  1399. AsmLn;
  1400. end;
  1401. procedure TGNUAssembler.WriteDirectiveName(dir: TAsmDirective);
  1402. begin
  1403. AsmWrite('.'+directivestr[dir]+' ');
  1404. end;
  1405. procedure TGNUAssembler.WriteAsmList;
  1406. var
  1407. n : string;
  1408. hal : tasmlisttype;
  1409. i: longint;
  1410. begin
  1411. {$ifdef EXTDEBUG}
  1412. if current_module.mainsource<>'' then
  1413. Comment(V_Debug,'Start writing gas-styled assembler output for '+current_module.mainsource);
  1414. {$endif}
  1415. if current_module.mainsource<>'' then
  1416. n:=ExtractFileName(current_module.mainsource)
  1417. else
  1418. n:=InputFileName;
  1419. { gcc does not add it either for Darwin. Grep for
  1420. TARGET_ASM_FILE_START_FILE_DIRECTIVE in gcc/config/*.h
  1421. }
  1422. if not(target_info.system in systems_darwin) then
  1423. AsmWriteLn(#9'.file "'+FixFileName(n)+'"');
  1424. WriteExtraHeader;
  1425. AsmStartSize:=AsmSize;
  1426. symendcount:=0;
  1427. for hal:=low(TasmlistType) to high(TasmlistType) do
  1428. begin
  1429. if not (current_asmdata.asmlists[hal].empty) then
  1430. begin
  1431. AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmlistTypeStr[hal]);
  1432. writetree(current_asmdata.asmlists[hal]);
  1433. AsmWriteLn(target_asm.comment+'End asmlist '+AsmlistTypeStr[hal]);
  1434. end;
  1435. end;
  1436. { add weak symbol markers }
  1437. for i:=0 to current_asmdata.asmsymboldict.count-1 do
  1438. if (tasmsymbol(current_asmdata.asmsymboldict[i]).bind=AB_WEAK_EXTERNAL) then
  1439. writeweaksymboldef(tasmsymbol(current_asmdata.asmsymboldict[i]));
  1440. if create_smartlink_sections and
  1441. (target_info.system in systems_darwin) then
  1442. AsmWriteLn(#9'.subsections_via_symbols');
  1443. { "no executable stack" marker }
  1444. { TODO: used by OpenBSD/NetBSD as well? }
  1445. if (target_info.system in (systems_linux + systems_android + systems_freebsd + systems_dragonfly)) and
  1446. not(cs_executable_stack in current_settings.moduleswitches) then
  1447. begin
  1448. AsmWriteLn('.section .note.GNU-stack,"",%progbits');
  1449. end;
  1450. AsmLn;
  1451. WriteExtraFooter;
  1452. {$ifdef EXTDEBUG}
  1453. if current_module.mainsource<>'' then
  1454. Comment(V_Debug,'Done writing gas-styled assembler output for '+current_module.mainsource);
  1455. {$endif EXTDEBUG}
  1456. end;
  1457. {****************************************************************************}
  1458. { Apple/GNU Assembler writer }
  1459. {****************************************************************************}
  1460. function TAppleGNUAssembler.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
  1461. begin
  1462. if (target_info.system in systems_darwin) then
  1463. case atype of
  1464. sec_bss:
  1465. { all bss (lcomm) symbols are automatically put in the right }
  1466. { place by using the lcomm assembler directive }
  1467. atype := sec_none;
  1468. sec_debug_frame,
  1469. sec_eh_frame:
  1470. begin
  1471. result := '.section __DWARF,__debug_info,regular,debug';
  1472. exit;
  1473. end;
  1474. sec_debug_line:
  1475. begin
  1476. result := '.section __DWARF,__debug_line,regular,debug';
  1477. exit;
  1478. end;
  1479. sec_debug_info:
  1480. begin
  1481. result := '.section __DWARF,__debug_info,regular,debug';
  1482. exit;
  1483. end;
  1484. sec_debug_abbrev:
  1485. begin
  1486. result := '.section __DWARF,__debug_abbrev,regular,debug';
  1487. exit;
  1488. end;
  1489. sec_rodata:
  1490. begin
  1491. result := '.const_data';
  1492. exit;
  1493. end;
  1494. sec_rodata_norel:
  1495. begin
  1496. result := '.const';
  1497. exit;
  1498. end;
  1499. sec_fpc:
  1500. begin
  1501. result := '.section __TEXT, .fpc, regular, no_dead_strip';
  1502. exit;
  1503. end;
  1504. sec_code:
  1505. begin
  1506. if (aname='fpc_geteipasebx') or
  1507. (aname='fpc_geteipasecx') then
  1508. begin
  1509. result:='.section __TEXT,__textcoal_nt,coalesced,pure_instructions'#10'.weak_definition '+aname+
  1510. #10'.private_extern '+aname;
  1511. exit;
  1512. end;
  1513. end;
  1514. sec_data_nonlazy:
  1515. begin
  1516. result:='.section __DATA, __nl_symbol_ptr,non_lazy_symbol_pointers';
  1517. exit;
  1518. end;
  1519. sec_data_lazy:
  1520. begin
  1521. result:='.section __DATA, __la_symbol_ptr,lazy_symbol_pointers';
  1522. exit;
  1523. end;
  1524. sec_init_func:
  1525. begin
  1526. result:='.section __DATA, __mod_init_func, mod_init_funcs';
  1527. exit;
  1528. end;
  1529. sec_term_func:
  1530. begin
  1531. result:='.section __DATA, __mod_term_func, mod_term_funcs';
  1532. exit;
  1533. end;
  1534. sec_objc_protocol_ext:
  1535. begin
  1536. result:='.section __OBJC, __protocol_ext, regular, no_dead_strip';
  1537. exit;
  1538. end;
  1539. sec_objc_class_ext:
  1540. begin
  1541. result:='.section __OBJC, __class_ext, regular, no_dead_strip';
  1542. exit;
  1543. end;
  1544. sec_objc_property:
  1545. begin
  1546. result:='.section __OBJC, __property, regular, no_dead_strip';
  1547. exit;
  1548. end;
  1549. sec_objc_image_info:
  1550. begin
  1551. if (target_info.system in systems_objc_nfabi) then
  1552. result:='.section __DATA,__objc_imageinfo,regular,no_dead_strip'
  1553. else
  1554. result:='.section __OBJC, __image_info, regular, no_dead_strip';
  1555. exit;
  1556. end;
  1557. sec_objc_cstring_object:
  1558. begin
  1559. result:='.section __OBJC, __cstring_object, regular, no_dead_strip';
  1560. exit;
  1561. end;
  1562. sec_objc_sel_fixup:
  1563. begin
  1564. result:='.section __OBJC, __sel_fixup, regular, no_dead_strip';
  1565. exit;
  1566. end;
  1567. sec_objc_message_refs:
  1568. begin
  1569. if (target_info.system in systems_objc_nfabi) then
  1570. begin
  1571. result:='.section __DATA, __objc_selrefs, literal_pointers, no_dead_strip';
  1572. exit;
  1573. end;
  1574. end;
  1575. sec_objc_cls_refs:
  1576. begin
  1577. if (target_info.system in systems_objc_nfabi) then
  1578. begin
  1579. result:='.section __DATA, __objc_clsrefs, regular, no_dead_strip';
  1580. exit;
  1581. end;
  1582. end;
  1583. sec_objc_meth_var_types:
  1584. begin
  1585. if (target_info.system in systems_objc_nfabi) then
  1586. begin
  1587. result:='.section __TEXT,__objc_methtype,cstring_literals';
  1588. exit
  1589. end;
  1590. end;
  1591. sec_objc_meth_var_names:
  1592. begin
  1593. if (target_info.system in systems_objc_nfabi) then
  1594. begin
  1595. result:='.section __TEXT,__objc_methname,cstring_literals';
  1596. exit
  1597. end;
  1598. end;
  1599. sec_objc_class_names:
  1600. begin
  1601. if (target_info.system in systems_objc_nfabi) then
  1602. begin
  1603. result:='.section __TEXT,__objc_classname,cstring_literals';
  1604. exit
  1605. end;
  1606. end;
  1607. sec_objc_inst_meth,
  1608. sec_objc_cls_meth,
  1609. sec_objc_cat_inst_meth,
  1610. sec_objc_cat_cls_meth:
  1611. begin
  1612. if (target_info.system in systems_objc_nfabi) then
  1613. begin
  1614. result:='.section __DATA, __objc_const';
  1615. exit;
  1616. end;
  1617. end;
  1618. sec_objc_meta_class,
  1619. sec_objc_class:
  1620. begin
  1621. if (target_info.system in systems_objc_nfabi) then
  1622. begin
  1623. result:='.section __DATA, __objc_data';
  1624. exit;
  1625. end;
  1626. end;
  1627. sec_objc_sup_refs:
  1628. begin
  1629. result:='.section __DATA, __objc_superrefs, regular, no_dead_strip';
  1630. exit
  1631. end;
  1632. sec_objc_classlist:
  1633. begin
  1634. result:='.section __DATA, __objc_classlist, regular, no_dead_strip';
  1635. exit
  1636. end;
  1637. sec_objc_nlclasslist:
  1638. begin
  1639. result:='.section __DATA, __objc_nlclasslist, regular, no_dead_strip';
  1640. exit
  1641. end;
  1642. sec_objc_catlist:
  1643. begin
  1644. result:='.section __DATA, __objc_catlist, regular, no_dead_strip';
  1645. exit
  1646. end;
  1647. sec_objc_nlcatlist:
  1648. begin
  1649. result:='.section __DATA, __objc_nlcatlist, regular, no_dead_strip';
  1650. exit
  1651. end;
  1652. sec_objc_protolist:
  1653. begin
  1654. result:='.section __DATA, __objc_protolist, coalesced, no_dead_strip';
  1655. exit;
  1656. end;
  1657. end;
  1658. result := inherited sectionname(atype,aname,aorder);
  1659. end;
  1660. procedure TAppleGNUAssembler.WriteWeakSymbolDef(s: tasmsymbol);
  1661. begin
  1662. AsmWriteLn(#9'.weak_reference '+s.name);
  1663. end;
  1664. {****************************************************************************}
  1665. { a.out/GNU Assembler writer }
  1666. {****************************************************************************}
  1667. function TAoutGNUAssembler.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
  1668. const
  1669. (* Translation table - replace unsupported section types with basic ones. *)
  1670. SecXTable: array[TAsmSectionType] of TAsmSectionType = (
  1671. sec_none,
  1672. sec_none,
  1673. sec_code,
  1674. sec_data,
  1675. sec_data (* sec_rodata *),
  1676. sec_data (* sec_rodata_norel *),
  1677. sec_bss,
  1678. sec_data (* sec_threadvar *),
  1679. { used for wince exception handling }
  1680. sec_code (* sec_pdata *),
  1681. { used for darwin import stubs }
  1682. sec_code (* sec_stub *),
  1683. sec_data,(* sec_data_nonlazy *)
  1684. sec_data,(* sec_data_lazy *)
  1685. sec_data,(* sec_init_func *)
  1686. sec_data,(* sec_term_func *)
  1687. { stabs }
  1688. sec_stab,sec_stabstr,
  1689. { win32 }
  1690. sec_data (* sec_idata2 *),
  1691. sec_data (* sec_idata4 *),
  1692. sec_data (* sec_idata5 *),
  1693. sec_data (* sec_idata6 *),
  1694. sec_data (* sec_idata7 *),
  1695. sec_data (* sec_edata *),
  1696. { C++ exception handling unwinding (uses dwarf) }
  1697. sec_eh_frame,
  1698. { dwarf }
  1699. sec_debug_frame,
  1700. sec_debug_info,
  1701. sec_debug_line,
  1702. sec_debug_abbrev,
  1703. { ELF resources (+ references to stabs debug information sections) }
  1704. sec_code (* sec_fpc *),
  1705. { Table of contents section }
  1706. sec_code (* sec_toc *),
  1707. sec_code (* sec_init *),
  1708. sec_code (* sec_fini *),
  1709. sec_none (* sec_objc_class *),
  1710. sec_none (* sec_objc_meta_class *),
  1711. sec_none (* sec_objc_cat_cls_meth *),
  1712. sec_none (* sec_objc_cat_inst_meth *),
  1713. sec_none (* sec_objc_protocol *),
  1714. sec_none (* sec_objc_string_object *),
  1715. sec_none (* sec_objc_cls_meth *),
  1716. sec_none (* sec_objc_inst_meth *),
  1717. sec_none (* sec_objc_cls_refs *),
  1718. sec_none (* sec_objc_message_refs *),
  1719. sec_none (* sec_objc_symbols *),
  1720. sec_none (* sec_objc_category *),
  1721. sec_none (* sec_objc_class_vars *),
  1722. sec_none (* sec_objc_instance_vars *),
  1723. sec_none (* sec_objc_module_info *),
  1724. sec_none (* sec_objc_class_names *),
  1725. sec_none (* sec_objc_meth_var_types *),
  1726. sec_none (* sec_objc_meth_var_names *),
  1727. sec_none (* sec_objc_selector_strs *),
  1728. sec_none (* sec_objc_protocol_ext *),
  1729. sec_none (* sec_objc_class_ext *),
  1730. sec_none (* sec_objc_property *),
  1731. sec_none (* sec_objc_image_info *),
  1732. sec_none (* sec_objc_cstring_object *),
  1733. sec_none (* sec_objc_sel_fixup *),
  1734. sec_none (* sec_objc_data *),
  1735. sec_none (* sec_objc_const *),
  1736. sec_none (* sec_objc_sup_refs *),
  1737. sec_none (* sec_data_coalesced *),
  1738. sec_none (* sec_objc_classlist *),
  1739. sec_none (* sec_objc_nlclasslist *),
  1740. sec_none (* sec_objc_catlist *),
  1741. sec_none (* sec_objc_nlcatlist *),
  1742. sec_none (* sec_objc_protlist *),
  1743. sec_none (* sec_stack *),
  1744. sec_none (* sec_heap *)
  1745. );
  1746. begin
  1747. Result := inherited SectionName (SecXTable [AType], AName, AOrder);
  1748. end;
  1749. {****************************************************************************}
  1750. { Abstract Instruction Writer }
  1751. {****************************************************************************}
  1752. constructor TCPUInstrWriter.create(_owner: TGNUAssembler);
  1753. begin
  1754. inherited create;
  1755. owner := _owner;
  1756. end;
  1757. end.