aggas.pas 68 KB

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