Browse Source

* Fixed linking for arm-wince target.

git-svn-id: trunk@3349 -
yury 19 years ago
parent
commit
9ad6409662
2 changed files with 21 additions and 3 deletions
  1. 5 0
      compiler/ogcoff.pas
  2. 16 3
      compiler/systems/t_win.pas

+ 5 - 0
compiler/ogcoff.pas

@@ -1367,8 +1367,13 @@ const win32stub : array[0..131] of byte=(
            header.syms:=symidx;
            header.syms:=symidx;
            if win32 then
            if win32 then
              begin
              begin
+{$ifdef arm}
+               header.flag:=PE_FILE_32BIT_MACHINE or
+                            PE_FILE_LINE_NUMS_STRIPPED or PE_FILE_LOCAL_SYMS_STRIPPED;
+{$else arm}
                header.flag:=PE_FILE_BYTES_REVERSED_LO or PE_FILE_32BIT_MACHINE or
                header.flag:=PE_FILE_BYTES_REVERSED_LO or PE_FILE_32BIT_MACHINE or
                             PE_FILE_LINE_NUMS_STRIPPED or PE_FILE_LOCAL_SYMS_STRIPPED;
                             PE_FILE_LINE_NUMS_STRIPPED or PE_FILE_LOCAL_SYMS_STRIPPED;
+{$endif arm}
                if not gotreloc then
                if not gotreloc then
                  header.flag:=header.flag or PE_FILE_RELOCS_STRIPPED;
                  header.flag:=header.flag or PE_FILE_RELOCS_STRIPPED;
              end
              end

+ 16 - 3
compiler/systems/t_win.pas

@@ -328,16 +328,23 @@ implementation
           objdata.free;
           objdata.free;
         end;
         end;
 
 
-        procedure AddImport(const afuncname:string;ordnr:word;isvar:boolean);
+        procedure AddImport(const afuncname, implabelname:string;ordnr:word;isvar:boolean);
         const
         const
 {$ifdef x86_64}
 {$ifdef x86_64}
           jmpopcode : array[0..2] of byte = (
           jmpopcode : array[0..2] of byte = (
             $ff,$24,$25
             $ff,$24,$25
           );
           );
 {$else x86_64}
 {$else x86_64}
+  {$ifdef arm}
+          jmpopcode : array[0..7] of byte = (
+            $00,$c0,$9f,$e5,    // ldr ip, [pc, #0]
+            $00,$f0,$9c,$e5     // ldr pc, [ip]
+          );
+  {$else arm}
           jmpopcode : array[0..1] of byte = (
           jmpopcode : array[0..1] of byte = (
             $ff,$25
             $ff,$25
           );
           );
+  {$endif arm}
 {$endif x86_64}
 {$endif x86_64}
           nopopcodes : array[0..1] of byte = (
           nopopcodes : array[0..1] of byte = (
             $90,$90
             $90,$90
@@ -393,7 +400,7 @@ implementation
           if not isvar then
           if not isvar then
             begin
             begin
               objdata.SetSection(textobjsection);
               objdata.SetSection(textobjsection);
-              implabel:=objdata.SymbolDefine(afuncname,AB_GLOBAL,AT_FUNCTION);
+              implabel:=objdata.SymbolDefine(implabelname,AB_GLOBAL,AT_FUNCTION);
               objdata.writebytes(jmpopcode,sizeof(jmpopcode));
               objdata.writebytes(jmpopcode,sizeof(jmpopcode));
               objdata.writereloc(0,sizeof(longint),idata5label,RELOC_ABSOLUTE32);
               objdata.writereloc(0,sizeof(longint),idata5label,RELOC_ABSOLUTE32);
               objdata.writebytes(nopopcodes,align(objdata.CurrObjSec.size,sizeof(nopopcodes))-objdata.CurrObjSec.size);
               objdata.writebytes(nopopcodes,align(objdata.CurrObjSec.size,sizeof(nopopcodes))-objdata.CurrObjSec.size);
@@ -406,6 +413,7 @@ implementation
       var
       var
          hp1 : timportList;
          hp1 : timportList;
          hp2 : twin32imported_item;
          hp2 : twin32imported_item;
+         mangledstring : string;
       begin
       begin
         AsmPrefix:='imp'+Lower(current_module.modulename^);
         AsmPrefix:='imp'+Lower(current_module.modulename^);
         idatalabnr:=0;
         idatalabnr:=0;
@@ -421,7 +429,11 @@ implementation
             hp2:=twin32imported_item(hp1.imported_items.first);
             hp2:=twin32imported_item(hp1.imported_items.first);
             while assigned(hp2) do
             while assigned(hp2) do
               begin
               begin
-                AddImport(hp2.name^,hp2.ordnr,hp2.is_var);
+                if assigned(hp2.procdef) then
+                  mangledstring:=hp2.procdef.mangledname
+                else
+                  mangledstring:=hp2.name^;
+                AddImport(hp2.name^,mangledstring,hp2.ordnr,hp2.is_var);
                 hp2:=twin32imported_item(hp2.next);
                 hp2:=twin32imported_item(hp2.next);
               end;
               end;
             EndImport;
             EndImport;
@@ -1679,6 +1691,7 @@ initialization
 {$endif x86_64}
 {$endif x86_64}
 {$ifdef arm}
 {$ifdef arm}
   RegisterExternalLinker(system_arm_wince_info,TLinkerWin32);
   RegisterExternalLinker(system_arm_wince_info,TLinkerWin32);
+  RegisterInternalLinker(system_arm_wince_info,TPECoffLinker);
   RegisterImport(system_arm_wince,TImportLibWin32);
   RegisterImport(system_arm_wince,TImportLibWin32);
   RegisterExport(system_arm_wince,TExportLibWin32);
   RegisterExport(system_arm_wince,TExportLibWin32);
   RegisterRes(res_gnu_wince_windres_info);
   RegisterRes(res_gnu_wince_windres_info);