aggas.pas 69 KB

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