objcasm.pas 7.7 KB

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