aggas.pas 68 KB

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