t_symbian.pas 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2007 by contributors of the Free Pascal Compiler
  4. This unit implements support import,export,link routines
  5. for the Symbian OS target
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit t_symbian;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. cutils,cclasses,
  24. aasmbase,aasmtai,aasmdata,aasmcpu,fmodule,globtype,globals,systems,verbose,
  25. symconst,symdef,symsym,
  26. cscript,gendef,
  27. cpubase,
  28. import,export,link,cgobj, i_symbian;
  29. type
  30. TInternalLinkerSymbian = class(TInternalLinker)
  31. constructor create; override;
  32. procedure DefaultLinkScript; override;
  33. procedure InitSysInitUnitName; override;
  34. end;
  35. implementation
  36. uses
  37. SysUtils,
  38. cfileutl,
  39. cpuinfo,cgutils,dbgbase,
  40. owar,ogbase,ogcoff, t_win;
  41. {****************************************************************************
  42. TInternalLinkerSymbian
  43. ****************************************************************************}
  44. constructor TInternalLinkerSymbian.Create;
  45. begin
  46. inherited Create;
  47. CArObjectReader:=TArObjectReader;
  48. CExeoutput:=TPECoffexeoutput;
  49. CObjInput:=TPECoffObjInput;
  50. end;
  51. procedure TInternalLinkerSymbian.DefaultLinkScript;
  52. var
  53. s,s2,
  54. ibase : TCmdStr;
  55. begin
  56. with LinkScript do
  57. begin
  58. while not ObjectFiles.Empty do
  59. begin
  60. s:=ObjectFiles.GetFirst;
  61. if s<>'' then
  62. Concat('READOBJECT '+MaybeQuoted(s));
  63. end;
  64. while not StaticLibFiles.Empty do
  65. begin
  66. s:=StaticLibFiles.GetFirst;
  67. if s<>'' then
  68. Concat('READSTATICLIBRARY '+MaybeQuoted(s));
  69. end;
  70. While not SharedLibFiles.Empty do
  71. begin
  72. S:=SharedLibFiles.GetFirst;
  73. if FindLibraryFile(s,target_info.staticClibprefix,target_info.staticClibext,s2) then
  74. Concat('READSTATICLIBRARY '+MaybeQuoted(s2))
  75. else
  76. Comment(V_Error,'Import library not found for '+S);
  77. end;
  78. if IsSharedLibrary then
  79. begin
  80. Concat('ISSHAREDLIBRARY');
  81. Concat('ENTRYNAME _E32DLL');
  82. end
  83. else
  84. begin
  85. Concat('ENTRYNAME _E32Startup')
  86. end;
  87. if IsSharedLibrary then
  88. ibase:='10000000'
  89. else
  90. ibase:='400000';
  91. Concat('IMAGEBASE $' + ibase);
  92. Concat('HEADER');
  93. Concat('EXESECTION .text');
  94. Concat(' OBJSECTION .text*');
  95. Concat(' SYMBOL ___CTOR_LIST__');
  96. Concat(' SYMBOL __CTOR_LIST__');
  97. Concat(' LONG -1');
  98. Concat(' OBJSECTION .ctor*');
  99. Concat(' LONG 0');
  100. Concat(' SYMBOL ___DTOR_LIST__');
  101. Concat(' SYMBOL __DTOR_LIST__');
  102. Concat(' LONG -1');
  103. Concat(' OBJSECTION .dtor*');
  104. Concat(' LONG 0');
  105. Concat(' SYMBOL etext');
  106. Concat('ENDEXESECTION');
  107. Concat('EXESECTION .data');
  108. Concat(' SYMBOL __data_start__');
  109. Concat(' OBJSECTION .data*');
  110. Concat(' OBJSECTION .fpc*');
  111. Concat(' SYMBOL edata');
  112. Concat(' SYMBOL __data_end__');
  113. Concat('ENDEXESECTION');
  114. Concat('EXESECTION .rdata');
  115. Concat(' SYMBOL ___RUNTIME_PSEUDO_RELOC_LIST__');
  116. Concat(' SYMBOL __RUNTIME_PSEUDO_RELOC_LIST__');
  117. Concat(' OBJSECTION .rdata_runtime_pseudo_reloc');
  118. Concat(' SYMBOL ___RUNTIME_PSEUDO_RELOC_LIST_END__');
  119. Concat(' SYMBOL __RUNTIME_PSEUDO_RELOC_LIST_END__');
  120. Concat(' OBJSECTION .rdata*');
  121. Concat(' OBJSECTION .rodata*');
  122. Concat('ENDEXESECTION');
  123. Concat('EXESECTION .pdata');
  124. Concat(' OBJSECTION .pdata');
  125. Concat('ENDEXESECTION');
  126. Concat('EXESECTION .bss');
  127. Concat(' SYMBOL __bss_start__');
  128. Concat(' OBJSECTION .bss*');
  129. Concat(' SYMBOL __bss_end__');
  130. Concat('ENDEXESECTION');
  131. Concat('EXESECTION .idata');
  132. Concat(' OBJSECTION .idata$2*');
  133. Concat(' OBJSECTION .idata$3*');
  134. Concat(' ZEROS 20');
  135. Concat(' OBJSECTION .idata$4*');
  136. Concat(' OBJSECTION .idata$5*');
  137. Concat(' OBJSECTION .idata$6*');
  138. Concat(' OBJSECTION .idata$7*');
  139. Concat('ENDEXESECTION');
  140. Concat('EXESECTION .edata');
  141. Concat(' OBJSECTION .edata*');
  142. Concat('ENDEXESECTION');
  143. Concat('EXESECTION .rsrc');
  144. Concat(' OBJSECTION .rsrc*');
  145. Concat('ENDEXESECTION');
  146. Concat('EXESECTION .reloc');
  147. Concat(' OBJSECTION .reloc');
  148. Concat('ENDEXESECTION');
  149. Concat('EXESECTION .stab');
  150. Concat(' OBJSECTION .stab');
  151. Concat('ENDEXESECTION');
  152. Concat('EXESECTION .stabstr');
  153. Concat(' OBJSECTION .stabstr');
  154. Concat('ENDEXESECTION');
  155. Concat('STABS');
  156. Concat('SYMBOLS');
  157. end;
  158. end;
  159. procedure TInternalLinkerSymbian.InitSysInitUnitName;
  160. begin
  161. sysinitunit := 'sysinitpas';
  162. end;
  163. {*****************************************************************************
  164. Initialize
  165. *****************************************************************************}
  166. initialization
  167. { Using external linker as internal doesn't look correct... }
  168. RegisterLinker(ld_windows,TExternalLinkerWin);
  169. RegisterLinker(ld_int_windows,TInternalLinkerWin);
  170. {$ifdef i386}
  171. ///RegisterInternalLinker(system_i386_symbian_info,TExternalLinkerWin);
  172. RegisterImport(system_i386_symbian,TImportLibWin);
  173. RegisterExport(system_i386_symbian,TExportLibWin);
  174. RegisterDLLScanner(system_i386_symbian,TDLLScannerWin);
  175. // RegisterRes(res_gnu_windres_info);
  176. RegisterTarget(system_i386_symbian_info);
  177. {$endif i386}
  178. {$ifdef arm}
  179. // RegisterExternalLinker(system_arm_symbian_info,TExternalLinkerWin);
  180. ///RegisterInternalLinker(system_arm_symbian_info,TInternalLinkerWin);
  181. RegisterImport(system_arm_symbian,TImportLibWin);
  182. RegisterExport(system_arm_symbian,TExportLibWin);
  183. RegisterTarget(system_arm_symbian_info);
  184. {$endif arm}
  185. end.