objcasm.pas 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. {
  2. Copyright (c) 2016 by Jonas Maebe
  3. This unit implements Objective-C assembler helper routines.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. {$i fpcdefs.inc}
  18. unit objcasm;
  19. interface
  20. uses
  21. aasmbase;
  22. { Workaround for mantis #29906: bug in PPC jump table generation if a jump
  23. table is created for a case-statement that handles at least the lowest
  24. and highest possible value of the case expression type }
  25. {$ifndef VER3_0_0}
  26. function objc_section_name(sec: TObjCAsmSectionType): string;
  27. {$else}
  28. function objc_section_name(sec: TAsmSectionType): string;
  29. {$endif}
  30. implementation
  31. uses
  32. verbose,
  33. systems;
  34. {$ifndef VER3_0_0}
  35. function objc_section_name(sec: TObjCAsmSectionType): string;
  36. {$else}
  37. function objc_section_name(sec: TAsmSectionType): string;
  38. {$endif}
  39. begin
  40. result:='';
  41. if target_info.system in systems_darwin then
  42. case sec of
  43. sec_objc_protocol:
  44. begin
  45. if not(target_info.system in systems_objc_nfabi) then
  46. result:='__OBJC, __protocol, regular, no_dead_strip'
  47. else
  48. internalerror(2015010605);
  49. end;
  50. sec_objc_protocol_ext:
  51. begin
  52. result:='__OBJC, __protocol_ext, regular, no_dead_strip';
  53. end;
  54. sec_objc_category:
  55. begin
  56. if not(target_info.system in systems_objc_nfabi) then
  57. result:='__OBJC, __category, regular, no_dead_strip'
  58. else
  59. internalerror(2015010606);
  60. end;
  61. sec_objc_class_ext:
  62. begin
  63. result:='__OBJC, __class_ext, regular, no_dead_strip';
  64. end;
  65. sec_objc_property:
  66. begin
  67. result:='__OBJC, __property, regular, no_dead_strip';
  68. end;
  69. sec_objc_image_info:
  70. begin
  71. if target_info.system in systems_objc_nfabi then
  72. result:='__DATA, __objc_imageinfo, regular, no_dead_strip'
  73. else
  74. result:='__OBJC, __image_info, regular, no_dead_strip';
  75. end;
  76. sec_objc_cstring_object:
  77. begin
  78. result:='__OBJC, __cstring_object, regular, no_dead_strip';
  79. end;
  80. sec_objc_sel_fixup:
  81. begin
  82. result:='__OBJC, __sel_fixup, regular, no_dead_strip';
  83. exit;
  84. end;
  85. sec_objc_message_refs:
  86. begin
  87. if target_info.system in systems_objc_nfabi then
  88. result:='__DATA, __objc_selrefs, literal_pointers, no_dead_strip'
  89. else
  90. result:='__OBJC, __message_refs, literal_pointers, no_dead_strip';
  91. end;
  92. sec_objc_symbols:
  93. begin
  94. if not(target_info.system in systems_objc_nfabi) then
  95. result:='__OBJC, __symbols, regular, no_dead_strip'
  96. else
  97. internalerror(2016010603);
  98. end;
  99. sec_objc_instance_vars:
  100. begin
  101. if target_info.system in systems_objc_nfabi then
  102. result:='__DATA, __objc_const'
  103. else
  104. result:=' __OBJC, __instance_vars, regular, no_dead_strip';
  105. end;
  106. sec_objc_cls_refs:
  107. begin
  108. if target_info.system in systems_objc_nfabi then
  109. result:='__DATA, __objc_clsrefs, regular, no_dead_strip'
  110. else
  111. result:='__OBJC, __cls_refs, literal_pointers, no_dead_strip';
  112. end;
  113. sec_objc_meth_var_types:
  114. begin
  115. if target_info.system in systems_objc_nfabi then
  116. result:='__TEXT, __objc_methtype, cstring_literals'
  117. else
  118. result:='__TEXT, __cstring, cstring_literals';
  119. end;
  120. sec_objc_meth_var_names:
  121. begin
  122. if target_info.system in systems_objc_nfabi then
  123. result:='__TEXT, __objc_methname, cstring_literals'
  124. else
  125. result:='__TEXT, __cstring, cstring_literals';
  126. end;
  127. sec_objc_class_names:
  128. begin
  129. if target_info.system in systems_objc_nfabi then
  130. result:='__TEXT, __objc_classname, cstring_literals'
  131. else
  132. result:='__TEXT, __cstring, cstring_literals';
  133. end;
  134. sec_objc_inst_meth:
  135. begin
  136. if target_info.system in systems_objc_nfabi then
  137. result:='__DATA, __objc_const'
  138. else
  139. result:='__OBJC, __inst_meth, regular, no_dead_strip';
  140. end;
  141. sec_objc_cls_meth:
  142. begin
  143. if target_info.system in systems_objc_nfabi then
  144. result:='__DATA, __objc_const'
  145. else
  146. result:='__OBJC, __cls_meth, regular, no_dead_strip';
  147. end;
  148. sec_objc_cat_inst_meth:
  149. begin
  150. if target_info.system in systems_objc_nfabi then
  151. result:='__DATA, __objc_const'
  152. else
  153. result:='__OBJC, __cat_inst_meth, regular, no_dead_strip';
  154. end;
  155. sec_objc_cat_cls_meth:
  156. begin
  157. if target_info.system in systems_objc_nfabi then
  158. result:='__DATA, __objc_const'
  159. else
  160. result:='__OBJC, __cat_cls_meth, regular, no_dead_strip';
  161. end;
  162. sec_objc_meta_class:
  163. begin
  164. if target_info.system in systems_objc_nfabi then
  165. result:='__DATA, __objc_const'
  166. else
  167. result:='__OBJC, __meta_class, regular, no_dead_strip';
  168. end;
  169. sec_objc_class:
  170. begin
  171. if target_info.system in systems_objc_nfabi then
  172. result:='__DATA, __objc_const'
  173. else
  174. result:='__OBJC, __class, regular, no_dead_strip';
  175. end;
  176. sec_objc_sup_refs:
  177. begin
  178. result:='__DATA, __objc_superrefs, regular, no_dead_strip';
  179. end;
  180. sec_objc_classlist:
  181. begin
  182. result:='__DATA, __objc_classlist, regular, no_dead_strip';
  183. end;
  184. sec_objc_nlclasslist:
  185. begin
  186. result:='__DATA, __objc_nlclasslist, regular, no_dead_strip';
  187. end;
  188. sec_objc_catlist:
  189. begin
  190. result:='__DATA, __objc_catlist, regular, no_dead_strip';
  191. end;
  192. sec_objc_nlcatlist:
  193. begin
  194. result:='__DATA, __objc_nlcatlist, regular, no_dead_strip';
  195. end;
  196. sec_objc_protolist:
  197. begin
  198. result:='__DATA, __objc_protolist, coalesced, no_dead_strip';
  199. end;
  200. sec_objc_module_info:
  201. begin
  202. if not(target_info.system in systems_objc_nfabi) then
  203. result:=' __OBJC, __module_info, regular, no_dead_strip'
  204. else
  205. internalerror(2016010601);
  206. end;
  207. sec_objc_data:
  208. begin
  209. result:='__DATA, __objc_data';
  210. end;
  211. sec_objc_const:
  212. begin
  213. result:='__DATA, __objc_const';
  214. end;
  215. sec_data_coalesced:
  216. begin
  217. result:='__DATA, __datacoal_nt, coalesced';
  218. end;
  219. else
  220. internalerror(2016010101);
  221. end
  222. else
  223. internalerror(2016010102);
  224. end;
  225. end.