aggas.pas 68 KB

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