aggas.pas 68 KB

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