objcasm.pas 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. function objc_section_name(sec: TObjCAsmSectionType): string;
  26. implementation
  27. uses
  28. verbose,
  29. systems;
  30. function objc_section_name(sec: TObjCAsmSectionType): string;
  31. begin
  32. result:='';
  33. if target_info.system in systems_darwin then
  34. case sec of
  35. sec_objc_protocol:
  36. begin
  37. if not(target_info.system in systems_objc_nfabi) then
  38. result:='__OBJC, __protocol, regular, no_dead_strip'
  39. else
  40. internalerror(2015010605);
  41. end;
  42. sec_objc_protocol_ext:
  43. begin
  44. result:='__OBJC, __protocol_ext, regular, no_dead_strip';
  45. end;
  46. sec_objc_category:
  47. begin
  48. if not(target_info.system in systems_objc_nfabi) then
  49. result:='__OBJC, __category, regular, no_dead_strip'
  50. else
  51. internalerror(2015010606);
  52. end;
  53. sec_objc_class_ext:
  54. begin
  55. result:='__OBJC, __class_ext, regular, no_dead_strip';
  56. end;
  57. sec_objc_property:
  58. begin
  59. result:='__OBJC, __property, regular, no_dead_strip';
  60. end;
  61. sec_objc_image_info:
  62. begin
  63. if target_info.system in systems_objc_nfabi then
  64. result:='__DATA, __objc_imageinfo, regular, no_dead_strip'
  65. else
  66. result:='__OBJC, __image_info, regular, no_dead_strip';
  67. end;
  68. sec_objc_cstring_object:
  69. begin
  70. result:='__OBJC, __cstring_object, regular, no_dead_strip';
  71. end;
  72. sec_objc_sel_fixup:
  73. begin
  74. result:='__OBJC, __sel_fixup, regular, no_dead_strip';
  75. exit;
  76. end;
  77. sec_objc_message_refs:
  78. begin
  79. if target_info.system in systems_objc_nfabi then
  80. result:='__DATA, __objc_selrefs, literal_pointers, no_dead_strip'
  81. else
  82. result:='__OBJC, __message_refs, literal_pointers, no_dead_strip';
  83. end;
  84. sec_objc_symbols:
  85. begin
  86. if not(target_info.system in systems_objc_nfabi) then
  87. result:='__OBJC, __symbols, regular, no_dead_strip'
  88. else
  89. internalerror(2016010603);
  90. end;
  91. sec_objc_instance_vars:
  92. begin
  93. if target_info.system in systems_objc_nfabi then
  94. result:='__DATA, __objc_const'
  95. else
  96. result:=' __OBJC, __instance_vars, regular, no_dead_strip';
  97. end;
  98. sec_objc_cls_refs:
  99. begin
  100. if target_info.system in systems_objc_nfabi then
  101. result:='__DATA, __objc_clsrefs, regular, no_dead_strip'
  102. else
  103. result:='__OBJC, __cls_refs, literal_pointers, no_dead_strip';
  104. end;
  105. sec_objc_meth_var_types:
  106. begin
  107. if target_info.system in systems_objc_nfabi then
  108. result:='__TEXT, __objc_methtype, cstring_literals'
  109. else
  110. result:='__TEXT, __cstring, cstring_literals';
  111. end;
  112. sec_objc_meth_var_names:
  113. begin
  114. if target_info.system in systems_objc_nfabi then
  115. result:='__TEXT, __objc_methname, cstring_literals'
  116. else
  117. result:='__TEXT, __cstring, cstring_literals';
  118. end;
  119. sec_objc_class_names:
  120. begin
  121. if target_info.system in systems_objc_nfabi then
  122. result:='__TEXT, __objc_classname, cstring_literals'
  123. else
  124. result:='__TEXT, __cstring, cstring_literals';
  125. end;
  126. sec_objc_inst_meth:
  127. begin
  128. if target_info.system in systems_objc_nfabi then
  129. result:='__DATA, __objc_const'
  130. else
  131. result:='__OBJC, __inst_meth, regular, no_dead_strip';
  132. end;
  133. sec_objc_cls_meth:
  134. begin
  135. if target_info.system in systems_objc_nfabi then
  136. result:='__DATA, __objc_const'
  137. else
  138. result:='__OBJC, __cls_meth, regular, no_dead_strip';
  139. end;
  140. sec_objc_cat_inst_meth:
  141. begin
  142. if target_info.system in systems_objc_nfabi then
  143. result:='__DATA, __objc_const'
  144. else
  145. result:='__OBJC, __cat_inst_meth, regular, no_dead_strip';
  146. end;
  147. sec_objc_cat_cls_meth:
  148. begin
  149. if target_info.system in systems_objc_nfabi then
  150. result:='__DATA, __objc_const'
  151. else
  152. result:='__OBJC, __cat_cls_meth, regular, no_dead_strip';
  153. end;
  154. sec_objc_meta_class:
  155. begin
  156. if target_info.system in systems_objc_nfabi then
  157. result:='__DATA, __objc_const'
  158. else
  159. result:='__OBJC, __meta_class, regular, no_dead_strip';
  160. end;
  161. sec_objc_class:
  162. begin
  163. if target_info.system in systems_objc_nfabi then
  164. result:='__DATA, __objc_const'
  165. else
  166. result:='__OBJC, __class, regular, no_dead_strip';
  167. end;
  168. sec_objc_sup_refs:
  169. begin
  170. result:='__DATA, __objc_superrefs, regular, no_dead_strip';
  171. end;
  172. sec_objc_classlist:
  173. begin
  174. result:='__DATA, __objc_classlist, regular, no_dead_strip';
  175. end;
  176. sec_objc_nlclasslist:
  177. begin
  178. result:='__DATA, __objc_nlclasslist, regular, no_dead_strip';
  179. end;
  180. sec_objc_catlist:
  181. begin
  182. result:='__DATA, __objc_catlist, regular, no_dead_strip';
  183. end;
  184. sec_objc_nlcatlist:
  185. begin
  186. result:='__DATA, __objc_nlcatlist, regular, no_dead_strip';
  187. end;
  188. sec_objc_protolist:
  189. begin
  190. result:='__DATA, __objc_protolist, coalesced, no_dead_strip';
  191. end;
  192. sec_objc_module_info:
  193. begin
  194. if not(target_info.system in systems_objc_nfabi) then
  195. result:=' __OBJC, __module_info, regular, no_dead_strip'
  196. else
  197. internalerror(2016010601);
  198. end;
  199. sec_objc_data:
  200. begin
  201. result:='__DATA, __objc_data';
  202. end;
  203. sec_objc_const:
  204. begin
  205. result:='__DATA, __objc_const';
  206. end;
  207. sec_data_coalesced:
  208. begin
  209. result:='__DATA, __datacoal_nt, coalesced';
  210. end;
  211. else
  212. internalerror(2016010101);
  213. end
  214. else
  215. internalerror(2016010102);
  216. end;
  217. end.