aggas.pas 70 KB

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