Quellcode durchsuchen

+ compiler part of WinCE patches from Yuri Sidorov

git-svn-id: trunk@573 -
florian vor 20 Jahren
Ursprung
Commit
c2fe9e3814

+ 3 - 0
compiler/arm/cputarg.pas

@@ -38,6 +38,9 @@ implementation
     {$ifndef NOTARGETLINUX}
       ,t_linux
     {$endif}
+    {$ifndef NOTARGETWINCE}
+      ,t_win
+    {$endif}
 
 {**************************************
              Assemblers

+ 1 - 1
compiler/pdecsub.pas

@@ -1920,7 +1920,7 @@ const
               if not(
                      assigned(pd.import_dll) and
                      (target_info.system in [system_i386_win32,system_i386_wdosx,
-                                             system_i386_emx,system_i386_os2])
+                                             system_i386_emx,system_i386_os2,system_arm_wince])
                     ) then
                 begin
                   if not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then

+ 1 - 1
compiler/pdecvar.pas

@@ -871,7 +871,7 @@ implementation
                 { address }
                 else if is_constintnode(pt) and
                         ((target_info.system in [system_i386_go32v2,system_i386_watcom,
-                                                 system_i386_wdosx,system_i386_win32]) or
+                                                 system_i386_wdosx,system_i386_win32,system_arm_wince]) or
                          (m_objfpc in aktmodeswitches) or
                          (m_delphi in aktmodeswitches)) then
                  begin

+ 2 - 2
compiler/pexports.pas

@@ -113,7 +113,7 @@ implementation
                      an underline }
                    if InternalProcName[1]='_' then
                      delete(InternalProcName,1,1)
-                   else if (target_info.system in [system_i386_win32,system_i386_wdosx]) and UseDeffileForExports then
+                   else if (target_info.system in [system_i386_win32,system_i386_wdosx,system_arm_wince]) and UseDeffileForExports then
                      begin
                        Message(parser_e_dlltool_unit_var_problem);
                        Message(parser_e_dlltool_unit_var_problem2);
@@ -134,7 +134,7 @@ implementation
                     end;
                    hp.options:=hp.options or eo_index;
                    pt.free;
-                   if target_info.system in [system_i386_win32,system_i386_wdosx] then
+                   if target_info.system in [system_i386_win32,system_i386_wdosx,system_arm_wince] then
                     DefString:=srsym.realname+'='+InternalProcName+' @ '+tostr(hp.index)
                    else
                     DefString:=srsym.realname+'='+InternalProcName; {Index ignored!}

+ 1 - 1
compiler/pmodules.pas

@@ -107,7 +107,7 @@ implementation
          begin
            { regenerate the importssection for win32 }
            if assigned(importssection) and
-              (target_info.system in [system_i386_win32,system_i386_wdosx]) then
+              (target_info.system in [system_i386_win32,system_i386_wdosx, system_arm_wince]) then
             begin
               importsSection.clear;
               importlib.generatesmartlib;

+ 2 - 2
compiler/psub.pas

@@ -1296,7 +1296,7 @@ implementation
                     not(
                         assigned(pd.import_dll) and
                         (target_info.system in [system_i386_win32,system_i386_wdosx,
-                                                system_i386_emx,system_i386_os2])
+                                                system_i386_emx,system_i386_os2,system_arm_wince])
                        ) then
                    begin
                      s:=proc_get_importname(pd);
@@ -1382,7 +1382,7 @@ implementation
                         consume_all_until(_SEMICOLON);
                      end
                    else if islibrary or
-                           (target_info.system in [system_i386_WIN32,system_i386_wdosx,system_i386_Netware,system_i386_netwlibc]) then
+                           (target_info.system in [system_i386_WIN32,system_i386_wdosx,system_i386_Netware,system_i386_netwlibc,system_arm_wince]) then
                      read_exports
                    else
                      begin

+ 67 - 0
compiler/systems/i_win.pas

@@ -157,6 +157,67 @@ unit i_win;
             use_function_relative_addresses : true
           );
 
+       system_arm_wince_info : tsysteminfo =
+          (
+            system       : system_arm_wince;
+            name         : 'WinCE for ARM';
+            shortname    : 'WinCE';
+            flags        : [];
+            cpu          : cpu_arm;
+            unit_env     : '';
+            extradefines : 'UNDER_CE';
+            exeext       : '.exe';
+            defext       : '.def';
+            scriptext    : '.bat';
+            smartext     : '.sl';
+            unitext      : '.ppu';
+            unitlibext   : '.ppl';
+            asmext       : '.s';
+            objext       : '.o';
+            resext       : '.rc';
+            resobjext    : '.or';
+            sharedlibext : '.dll';
+            staticlibext : '.a';
+            staticlibprefix : 'libp';
+            sharedlibprefix : '';
+            sharedClibext : '.dll';
+            staticClibext : '.a';
+            staticClibprefix : 'lib';
+            sharedClibprefix : '';
+            p_ext_support : false;
+            Cprefix      : '_';
+            newline      : #13#10;
+            dirsep       : '\';
+            files_case_relevent : true;
+            assem        : as_gas;
+            assemextern  : as_gas;
+            link         : nil;
+            linkextern   : nil;
+            ar           : ar_gnu_ar;
+            res          : res_gnu_windres;
+            script       : script_dos;
+            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;
+            DllScanSupported:false;
+            use_function_relative_addresses : true
+          );
+          
   implementation
 
 initialization
@@ -175,4 +236,10 @@ initialization
     {$endif WDOSX}
   {$endif WIN64}
 {$endif CPUX86_64}
+
+{$ifdef CPUARM}
+  {$ifdef WINCE}
+    set_source_info(system_arm_wince_info);
+  {$endif WINCE}
+{$endif CPUARM}
 end.

+ 53 - 9
compiler/systems/t_win.pas

@@ -249,7 +249,7 @@ implementation
          suffix : integer;
 {$endif GDB}
          hp2 : twin32imported_item;
-         lhead,lname,lcode,
+         lhead,lname,lcode, {$ifdef ARM} lpcode, {$endif ARM}
          lidata4,lidata5 : tasmlabel;
          href : treference;
       begin
@@ -298,7 +298,9 @@ implementation
                  if not hp2.is_var then
                   begin
                     objectlibrary.getlabel(lcode);
-                    reference_reset_symbol(href,lcode,0);
+                  {$ifdef ARM}
+                    objectlibrary.getlabel(lpcode);
+                  {$endif ARM}
                     { place jump in codesegment, insert a code section in the
                       imporTSection to reduce the amount of .s files (PFV) }
                     new_section(importsSection,sec_code,'',0);
@@ -311,8 +313,19 @@ implementation
                     else
                       mangledstring:=hp2.func^;
                     importsSection.concat(Tai_symbol.Createname_global(mangledstring,AT_FUNCTION,0));
+                  {$ifdef ARM}
+                    reference_reset_symbol(href,lpcode,0);
+                    importsSection.concat(Taicpu.op_reg_ref(A_LDR,NR_R12,href));
+                    reference_reset_base(href,NR_R12,0);
+                    importsSection.concat(Taicpu.op_reg_ref(A_LDR,NR_R15,href));
+                    importsSection.concat(Tai_label.Create(lpcode));
+                    reference_reset_symbol(href,lcode,0);
+                    importsSection.concat(tai_const.create_sym_offset(href.symbol,href.offset));
+                  {$else ARM}
+                    reference_reset_symbol(href,lcode,0);
                     importsSection.concat(Taicpu.Op_ref(A_JMP,S_NO,href));
                     importsSection.concat(Tai_align.Create_op(4,$90));
+                  {$endif ARM}
 {$IfDef GDB}
                     if (cs_debuginfo in aktmoduleswitches) and assigned(hp2.procdef) then
                        hp2.procdef.concatstabto(importssection);
@@ -393,7 +406,7 @@ implementation
       var
          hp1 : timportlist;
          hp2 : twin32imported_item;
-         l1,l2,l3,l4 : tasmlabel;
+         l1,l2,l3,l4 {$ifdef ARM} ,l5 {$endif ARM} : tasmlabel;
          mangledstring : string;
 {$ifdef GDB}
          importname : string;
@@ -455,8 +468,10 @@ implementation
                    if not hp2.is_var then
                     begin
                       objectlibrary.getlabel(l4);
-                      { create indirect jump }
-                      reference_reset_symbol(href,l4,0);
+                    {$ifdef ARM}
+                      objectlibrary.getlabel(l5);
+                    {$endif ARM}
+                      { create indirect jump and }
                       { place jump in codesegment }
                       new_section(importsSection,sec_code,'',0);
 {$IfDef GDB}
@@ -468,8 +483,19 @@ implementation
                       else
                         mangledstring:=hp2.func^;
                       importsSection.concat(Tai_symbol.Createname_global(mangledstring,AT_FUNCTION,0));
+                    {$ifdef ARM}
+                      reference_reset_symbol(href,l5,0);
+                      importsSection.concat(Taicpu.op_reg_ref(A_LDR,NR_R12,href));
+                      reference_reset_base(href,NR_R12,0);
+                      importsSection.concat(Taicpu.op_reg_ref(A_LDR,NR_R15,href));
+                      importsSection.concat(Tai_label.Create(l5));
+                      reference_reset_symbol(href,l4,0);
+                      importsSection.concat(tai_const.create_sym_offset(href.symbol,href.offset));
+                    {$else ARM}
+                      reference_reset_symbol(href,l4,0);
                       importsSection.concat(Taicpu.Op_ref(A_JMP,S_NO,href));
                       importsSection.concat(Tai_align.Create_op(4,$90));
+                    {$endif ARM}
 {$IfDef GDB}
                       if (cs_debuginfo in aktmoduleswitches) and assigned(hp2.procdef) then
                         hp2.procdef.concatstabto(importssection);
@@ -861,18 +887,25 @@ end;
 
 
 Procedure TLinkerWin32.SetDefaultInfo;
+var
+  targetopts: string;
 begin
   with Info do
    begin
-     ExeCmd[1]:='ld -b pe-i386 -m i386pe $OPT $STRIP $APPTYPE $IMAGEBASE $RELOC -o $EXE $RES';
-     DllCmd[1]:='ld -b pe-i386 -m i386pe $OPT $STRIP --dll $APPTYPE $IMAGEBASE $RELOC -o $EXE $RES';
+     {$ifdef ARM}
+       targetopts:='-m armpe';
+     {$else ARM}
+       targetopts:='-b pe-i386 -m i386pe';
+     {$endif ARM}
+     ExeCmd[1]:='ld '+targetopts+' $OPT $STRIP $APPTYPE $IMAGEBASE $RELOC -o $EXE $RES';
+     DllCmd[1]:='ld '+targetopts+' $OPT $STRIP --dll $APPTYPE $IMAGEBASE $RELOC -o $EXE $RES';
      { ExeCmd[2]:='dlltool --as $ASBIN --dllname $EXE --output-exp exp.$$$ $RELOC $DEF';
        use short forms to avoid 128 char limitation problem }
      ExeCmd[2]:='dlltool -S $ASBIN -D $EXE -e exp.$$$ $RELOC $DEF';
-     ExeCmd[3]:='ld -b pe-i386 -m i386pe $OPT $STRIP $APPTYPE $IMAGEBASE -o $EXE $RES exp.$$$';
+     ExeCmd[3]:='ld '+targetopts+' $OPT $STRIP $APPTYPE $IMAGEBASE -o $EXE $RES exp.$$$';
      { DllCmd[2]:='dlltool --as $ASBIN --dllname $EXE --output-exp exp.$$$ $RELOC $DEF'; }
      DllCmd[2]:='dlltool -S $ASBIN -D $EXE -e exp.$$$ $RELOC $DEF';
-     DllCmd[3]:='ld -b pe-i386 -m i386pe $OPT $STRIP --dll $APPTYPE $IMAGEBASE -o $EXE $RES exp.$$$';
+     DllCmd[3]:='ld '+targetopts+' $OPT $STRIP --dll $APPTYPE $IMAGEBASE -o $EXE $RES exp.$$$';
    end;
 end;
 
@@ -1240,6 +1273,10 @@ var
   secroot,hsecroot : psecfill;
   zerobuf : pointer;
 begin
+  {$ifdef ARM}
+    postprocessexecutable:=true;
+    exit;
+  {$endif ARM}
   postprocessexecutable:=false;
   { when -s is used or it's a dll then quit }
   if (cs_link_extern in aktglobalswitches) then
@@ -1627,4 +1664,11 @@ initialization
   RegisterRes(res_gnu_windres_info);
   RegisterTarget(system_x64_win64_info);
 {$endif x86_64}
+{$ifdef arm}
+  RegisterExternalLinker(system_arm_wince_info,TLinkerWin32);
+  RegisterImport(system_arm_wince,TImportLibWin32);
+  RegisterExport(system_arm_wince,TExportLibWin32);
+  RegisterRes(res_gnu_windres_info);
+  RegisterTarget(system_arm_wince_info);
+{$endif arm}
 end.