aggas.pas 68 KB

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