2
0
Эх сурвалжийг харах

Added basic compiler and fpcmake support for Symobi.
Symobi uses PE as its current file format (there might be a change to ELF somewhen, but I'll work on that when it's necessary) and thus typical PE modifications are necessary here as well.
Also the external resource support is used here as well (at least until I've found a way to access the PE image).
Note: Writing DLLs is not yet supported

* compiler/ogbase.pas:
Apply the same name mangling replacement as on Windows targets (Note to self: apply this to NativeNT as well)
* compiler/ogcoff.pas:
- Add Symobi as a supported target for the internal PE assembler
- Symobi always needs a relocation section (base address is ignored)
* compiler/pdecvar.pas:
Imported variables are used using indirect references as well (Note to self: apply this to NativeNT as well)
* compiler/options.pas:
The stack check feature is disabled as I don't yet know how I can access the PE image to read the stack values (also I'd need to check whether they are used at all...)

git-svn-id: branches/svenbarth/symobi@18059 -

svenbarth 14 жил өмнө
parent
commit
e0aded34e3

+ 2 - 0
.gitattributes

@@ -538,6 +538,7 @@ compiler/systems/i_os2.pas svneol=native#text/plain
 compiler/systems/i_palmos.pas svneol=native#text/plain
 compiler/systems/i_palmos.pas svneol=native#text/plain
 compiler/systems/i_sunos.pas svneol=native#text/plain
 compiler/systems/i_sunos.pas svneol=native#text/plain
 compiler/systems/i_symbian.pas svneol=native#text/plain
 compiler/systems/i_symbian.pas svneol=native#text/plain
+compiler/systems/i_symobi.pas svneol=native#text/pascal
 compiler/systems/i_watcom.pas svneol=native#text/plain
 compiler/systems/i_watcom.pas svneol=native#text/plain
 compiler/systems/i_wdosx.pas svneol=native#text/plain
 compiler/systems/i_wdosx.pas svneol=native#text/plain
 compiler/systems/i_wii.pas svneol=native#text/plain
 compiler/systems/i_wii.pas svneol=native#text/plain
@@ -563,6 +564,7 @@ compiler/systems/t_os2.pas svneol=native#text/plain
 compiler/systems/t_palmos.pas svneol=native#text/plain
 compiler/systems/t_palmos.pas svneol=native#text/plain
 compiler/systems/t_sunos.pas svneol=native#text/plain
 compiler/systems/t_sunos.pas svneol=native#text/plain
 compiler/systems/t_symbian.pas svneol=native#text/plain
 compiler/systems/t_symbian.pas svneol=native#text/plain
+compiler/systems/t_symobi.pas svneol=native#text/pascal
 compiler/systems/t_watcom.pas svneol=native#text/plain
 compiler/systems/t_watcom.pas svneol=native#text/plain
 compiler/systems/t_wdosx.pas svneol=native#text/plain
 compiler/systems/t_wdosx.pas svneol=native#text/plain
 compiler/systems/t_wii.pas svneol=native#text/plain
 compiler/systems/t_wii.pas svneol=native#text/plain

+ 3 - 0
compiler/compiler.pas

@@ -116,6 +116,9 @@ uses
 {$ifdef nativent}
 {$ifdef nativent}
   ,i_nativent
   ,i_nativent
 {$endif nativent}
 {$endif nativent}
+{$ifdef symobi}
+  ,i_symobi
+{$endif}
   ,globtype;
   ,globtype;
 
 
 function Compile(const cmd:TCmdStr):longint;
 function Compile(const cmd:TCmdStr):longint;

+ 3 - 0
compiler/i386/cputarg.pas

@@ -83,6 +83,9 @@ implementation
     {$ifndef NOTARGETEMBEDDED}
     {$ifndef NOTARGETEMBEDDED}
       ,t_embed
       ,t_embed
     {$endif}
     {$endif}
+	{$ifndef NOTARGETSYMOBI}
+	  ,t_symobi
+	{$endif}
 
 
 {**************************************
 {**************************************
              Assemblers
              Assemblers

+ 1 - 1
compiler/ogbase.pas

@@ -1490,7 +1490,7 @@ implementation
         FMangledName:=AMangledName;
         FMangledName:=AMangledName;
         { Replace ? and @ in import name, since GNU AS does not allow these characters in symbol names. }
         { Replace ? and @ in import name, since GNU AS does not allow these characters in symbol names. }
         { This allows to import VC++ mangled names from DLLs. }
         { This allows to import VC++ mangled names from DLLs. }
-        if target_info.system in systems_all_windows then
+        if target_info.system in systems_all_windows+[system_i386_symobi] then
           begin
           begin
             Replace(FMangledName,'?','__q$$');
             Replace(FMangledName,'?','__q$$');
 {$ifdef arm}
 {$ifdef arm}

+ 4 - 1
compiler/ogcoff.pas

@@ -2545,6 +2545,9 @@ const pemagic : array[0..3] of byte = (
         inherited createcoff(true);
         inherited createcoff(true);
         CExeSection:=TPECoffExeSection;
         CExeSection:=TPECoffExeSection;
         CObjData:=TPECoffObjData;
         CObjData:=TPECoffObjData;
+        { always generate the relocation section for Symobi }
+        if target_info.system=system_i386_symobi then
+          RelocSection:=true;
       end;
       end;
 
 
 
 
@@ -3048,7 +3051,7 @@ const pemagic : array[0..3] of byte = (
             idtxt  : 'PECOFF';
             idtxt  : 'PECOFF';
             asmbin : '';
             asmbin : '';
             asmcmd : '';
             asmcmd : '';
-            supported_targets : [system_i386_win32,system_i386_nativent];
+            supported_targets : [system_i386_win32,system_i386_nativent,system_i386_symobi];
             flags : [af_outputbinary,af_smartlink_sections];
             flags : [af_outputbinary,af_smartlink_sections];
             labelprefix : '.L';
             labelprefix : '.L';
             comment : '';
             comment : '';

+ 2 - 0
compiler/options.pas

@@ -2293,6 +2293,8 @@ begin
     system_i386_nativent:
     system_i386_nativent:
       // until these features are implemented, they are disabled in the compiler
       // until these features are implemented, they are disabled in the compiler
       target_unsup_features:=[f_stackcheck];
       target_unsup_features:=[f_stackcheck];
+	system_i386_symobi:
+	  target_unsup_features:=[f_stackcheck];
     else
     else
       target_unsup_features:=[];
       target_unsup_features:=[];
   end;
   end;

+ 1 - 1
compiler/pdecvar.pas

@@ -1004,7 +1004,7 @@ implementation
 
 
       { Windows uses an indirect reference using import tables }
       { Windows uses an indirect reference using import tables }
       if is_dll and
       if is_dll and
-         (target_info.system in systems_all_windows) then
+         (target_info.system in systems_all_windows+[system_i386_symobi]) then
         include(vs.varoptions,vo_is_dll_var);
         include(vs.varoptions,vo_is_dll_var);
 
 
       { This can only happen if vs.typ=staticvarsym }
       { This can only happen if vs.typ=staticvarsym }

+ 2 - 1
compiler/systems.inc

@@ -146,7 +146,8 @@
              system_mipsel_linux,       { 67 }
              system_mipsel_linux,       { 67 }
              system_i386_nativent,      { 68 }
              system_i386_nativent,      { 68 }
              system_i386_iphonesim,     { 69 }
              system_i386_iphonesim,     { 69 }
-             system_powerpc_wii         { 70 }
+             system_powerpc_wii,        { 70 }
+			 system_i386_symobi         { 71 }
        );
        );
 
 
      type
      type

+ 107 - 0
compiler/systems/i_symobi.pas

@@ -0,0 +1,107 @@
+{
+    Copyright (c) 2011 by Sven Barth
+
+    This unit implements support information structures for Symobi
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ****************************************************************************
+}
+
+unit i_symobi;
+
+{$i fpcdefs.inc}
+
+  interface
+
+    uses
+       systems, rescmn;
+
+    const
+
+       system_i386_symobi_info : tsysteminfo =
+          (
+            system       : system_i386_symobi;
+            name         : 'Symobi for i386';
+            shortname    : 'Symobi';
+            flags        : [tf_smartlink_library
+                            ,tf_smartlink_sections{,tf_section_threadvars}{,tf_needs_dwarf_cfi},
+                            tf_no_pic_supported,
+                            tf_no_generic_stackcheck,tf_has_winlike_resources,
+                            tf_dwarf_only_local_labels,
+                            tf_safecall_exceptions];
+            cpu          : cpu_i386;
+            unit_env     : 'SYMOBIUNITS';
+            extradefines : 'SYMOBI;UNIX;HASSYMOBI';
+            exeext       : '.exe';
+            defext       : '.def';
+            scriptext    : '.sh';
+            smartext     : '.sl';
+            unitext      : '.ppu';
+            unitlibext   : '.ppl';
+            asmext       : '.s';
+            objext       : '.o';
+            resext       : '.res';
+            resobjext    : '.or';
+            sharedlibext : '.dll';
+            staticlibext : '.a';
+            staticlibprefix : 'libp';
+            sharedlibprefix : 'lib.';
+            sharedClibext : '.dll';
+            staticClibext : '.a';
+            staticClibprefix : 'lib';
+            sharedClibprefix : 'lib.';
+            importlibprefix : 'libimp';
+            importlibext : '.a';
+            Cprefix      : '';
+            newline      : #10;
+            dirsep       : '/';
+            assem        : as_i386_pecoff;
+            assemextern  : as_gas;
+            link         : nil;
+            linkextern   : nil;
+            ar           : ar_gnu_ar;
+            res          : res_ext;
+            dbg          : dbg_stabs;
+            script       : script_unix;
+            endian       : endian_little;
+            alignment    :
+              (
+                procalign       : 4;
+                loopalign       : 4;
+                jumpalign       : 0;
+                constalignmin   : 0;
+                constalignmax   : 4;
+                varalignmin     : 0;
+                varalignmax     : 4;
+                localalignmin   : 0;
+                localalignmax   : 4;
+                recordalignmin  : 0;
+                recordalignmax  : 2;
+                maxCrecordalign : 4
+              );
+            first_parm_offset : 8;
+            stacksize   : 262144;
+            abi          : abi_default;
+          );
+
+  implementation
+
+initialization
+{$ifdef cpu86}
+  {$ifdef Symobi}
+     set_source_info(system_i386_Symobi_info);
+  {$endif}
+{$endif cpu86}
+end.

+ 95 - 0
compiler/systems/t_symobi.pas

@@ -0,0 +1,95 @@
+{
+    Copyright (c) 2011 by Sven Barth
+
+    This unit implements support import,export,link routines
+    for the Symobi Target
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ****************************************************************************
+}
+unit t_symobi;
+
+{$i fpcdefs.inc}
+
+interface
+
+
+implementation
+
+  uses
+    SysUtils,
+    cutils,
+    ogbase,ogcoff,
+    globtype,globals,systems,verbose,
+    import,export,link,t_win,i_symobi,rescmn,comprsrc;
+
+
+    type
+      TImportLibSymobi=class(TImportLibWin)
+      end;
+
+      TExportLibSymobi=class(TExportLibWin)
+      end;
+
+      TInternalLinkerSymobi = class(TInternalLinkerWin)
+        constructor create;override;
+        procedure ConcatEntryName; override;
+		function MakeExecutable:boolean;override;
+      end;
+	  
+{****************************************************************************
+                            TInternalLinkerSymobi
+****************************************************************************}
+
+    constructor TInternalLinkerSymobi.create;
+      begin
+        inherited create;
+        CExeoutput:=TPECoffexeoutput;
+        CObjInput:=TPECoffObjInput;
+      end;
+
+    procedure TInternalLinkerSymobi.ConcatEntryName;
+      begin
+        with LinkScript do
+          begin
+            if IsSharedLibrary then
+			  { TODO : verify this }
+              Concat('ENTRYNAME _DLLMainCRTStartup')
+            else
+			  { we need to use the startupname defined in the helper }
+              Concat('ENTRYNAME FPC_SYSTEMMAIN');
+          end;
+      end;
+	  
+	function TInternalLinkerSymobi.MakeExecutable:boolean;
+	  begin
+	    result:=inherited MakeExecutable;
+	  end;
+
+	  
+{*****************************************************************************
+                                     Initialize
+*****************************************************************************}
+
+initialization
+{$ifdef i386}
+  { Symobi }
+  RegisterInternalLinker(system_i386_symobi_info,TInternalLinkerSymobi);
+  RegisterImport(system_i386_symobi,TImportLibSymobi);
+  RegisterExport(system_i386_symobi,TExportLibSymobi);
+  RegisterRes(res_ext_info,TWinLikeResourceFile);
+  RegisterTarget(system_i386_symobi_info);
+{$endif i386}
+end.

+ 6 - 0
utils/fpcm/fpcmake.ini

@@ -1024,6 +1024,12 @@ SHAREDLIBEXT=.so
 SHORTSUFFIX=wii
 SHORTSUFFIX=wii
 endif
 endif
 
 
+# Symobi
+ifeq ($(OS_TARGET),symobi)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=symobi
+endif
+
 else
 else
 # long version for 1.0.x - target specific extensions
 # long version for 1.0.x - target specific extensions
 
 

+ 5 - 4
utils/fpcm/fpcmmain.pp

@@ -71,7 +71,7 @@ interface
         o_amiga,o_atari, o_solaris, o_qnx, o_netware, o_openbsd,o_wdosx,
         o_amiga,o_atari, o_solaris, o_qnx, o_netware, o_openbsd,o_wdosx,
         o_palmos,o_macos,o_darwin,o_emx,o_watcom,o_morphos,o_netwlibc,
         o_palmos,o_macos,o_darwin,o_emx,o_watcom,o_morphos,o_netwlibc,
         o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian,o_nativent,o_iphonesim,
         o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian,o_nativent,o_iphonesim,
-        o_wii
+        o_wii,o_symobi
       );
       );
 
 
       TTargetSet=array[tcpu,tos] of boolean;
       TTargetSet=array[tcpu,tos] of boolean;
@@ -94,7 +94,7 @@ interface
         'amiga','atari','solaris', 'qnx', 'netware','openbsd','wdosx',
         'amiga','atari','solaris', 'qnx', 'netware','openbsd','wdosx',
         'palmos','macos','darwin','emx','watcom','morphos','netwlibc',
         'palmos','macos','darwin','emx','watcom','morphos','netwlibc',
         'win64','wince','gba','nds','embedded','symbian','nativent',
         'win64','wince','gba','nds','embedded','symbian','nativent',
-        'iphonesim', 'wii'
+        'iphonesim', 'wii','symobi'
       );
       );
 
 
       OSSuffix : array[TOS] of string=(
       OSSuffix : array[TOS] of string=(
@@ -102,7 +102,7 @@ interface
         '_amiga','_atari','_solaris', '_qnx', '_netware','_openbsd','_wdosx',
         '_amiga','_atari','_solaris', '_qnx', '_netware','_openbsd','_wdosx',
         '_palmos','_macos','_darwin','_emx','_watcom','_morphos','_netwlibc',
         '_palmos','_macos','_darwin','_emx','_watcom','_morphos','_netwlibc',
         '_win64','_wince','_gba','_nds','_embedded','_symbian','_nativent',
         '_win64','_wince','_gba','_nds','_embedded','_symbian','_nativent',
-        '_iphonesim','_wii'
+        '_iphonesim','_wii','_symobi'
       );
       );
 
 
       { This table is kept OS,Cpu because it is easier to maintain (PFV) }
       { This table is kept OS,Cpu because it is easier to maintain (PFV) }
@@ -138,7 +138,8 @@ interface
         { symbian } ( true,  false, false, false, false, true,  false, false, false, false, false, false, false, false),
         { symbian } ( true,  false, false, false, false, true,  false, false, false, false, false, false, false, false),
         { nativent }( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
         { nativent }( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
         { iphonesim }( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),        
         { iphonesim }( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),        
-        { wii }     ( false, false, true,  false, false, false, false, false, false, false, false, false, false, false)        
+        { wii }     ( false, false, true,  false, false, false, false, false, false, false, false, false, false, false),        
+        { symobi }  ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false)        
       );
       );
 
 
     type
     type