Przeglądaj źródła

Merged revisions 2330,2378,2438,2511 via svnmerge from
http://[email protected]/svn/fpc/trunk

........
r2330 | jonas | 2006-01-23 11:54:48 +0100 (Mon, 23 Jan 2006) | 2 lines

* don't destroy edi when allocating the stack frame for win32

........
r2378 | tom_at_work | 2006-01-29 19:01:53 +0100 (Sun, 29 Jan 2006) | 3 lines

* fixed -dUSE_SYSUTILS compilation
* the call to "ar" is now automatically broken into multiple calls, avoiding shell errors when expanding the '*' in the original commandline

........
r2438 | florian | 2006-02-05 11:32:19 +0100 (Sun, 05 Feb 2006) | 2 lines

* moved insertation of pc relative data for arm target

........
r2511 | florian | 2006-02-10 20:08:43 +0100 (Fri, 10 Feb 2006) | 2 lines

* ensure always 16 byte aligned memory blocks

........

git-svn-id: branches/fixes_2_0@2794 -

peter 19 lat temu
rodzic
commit
20215ad4fd
5 zmienionych plików z 77 dodań i 11 usunięć
  1. 2 1
      compiler/globals.pas
  2. 56 4
      compiler/link.pas
  3. 8 4
      compiler/psub.pas
  4. 5 2
      compiler/x86/cgx86.pas
  5. 6 0
      rtl/inc/heap.inc

+ 2 - 1
compiler/globals.pas

@@ -711,7 +711,8 @@ implementation
           then
             Delete (F, Length (F), 1);
 {$IFDEF USE_SYSUTILS}
-        PathExists := FileGetAttr(F) and faDirectory = faDirectory;
+        I := FileGetAttr(F);
+        PathExists := (I <> -1) and (I and faDirectory = faDirectory);
 {$ELSE USE_SYSUTILS}
         Assign (FF, FExpand (F));
         GetFAttr (FF, A);

+ 56 - 4
compiler/link.pas

@@ -177,6 +177,38 @@ begin
 end;
 
 
+    { searches a (windows) DLL file }
+    function FindDLL(const s:string;var founddll:string):boolean;
+      var
+        sysdir : string;
+        Found : boolean;
+      begin
+        Found:=false;
+        { Look for DLL in:
+          1. Current dir
+          2. Library Path
+          3. windir,windir/system,windir/system32 }
+        Found:=FindFile(s,'.'+source_info.DirSep,founddll);
+        if (not found) then
+         Found:=librarysearchpath.FindFile(s,founddll);
+        if (not found) then
+         begin
+           {$IFDEF USE_SYSUTILS}
+           sysdir:=FixPath(GetEnvironmentVariable('windir'),false);
+           {$ELSE USE_SYSUTILS}
+           sysdir:=FixPath(GetEnv('windir'),false);
+           {$ENDIF USE_SYSUTILS}
+           Found:=FindFile(s,sysdir+';'+sysdir+'system'+source_info.DirSep+';'+sysdir+'system32'+source_info.DirSep,founddll);
+         end;
+        if (not found) then
+         begin
+           message1(exec_w_libfile_not_found,s);
+           FoundDll:=s;
+         end;
+        FindDll:=Found;
+      end;
+
+
 { searches an library file }
 function FindLibraryFile(s:string;const prefix,ext:string;var foundfile : string) : boolean;
 var
@@ -552,10 +584,22 @@ end;
 
 Function TExternalLinker.MakeStaticLibrary:boolean;
 var
-  smartpath,
-  cmdstr : TCmdStr;
+  smartpath : TCmdStr;
+
+  function GetNextFiles(const maxCmdLength : AInt; var item : TStringListItem) : string;
+  begin
+    result := '';
+    while (assigned(item) and ((length(result) + length(item.str) + 1) < maxCmdLength)) do begin
+      result := result + ' ' + item.str;
+      item := TStringListItem(item.next);
+    end;
+  end;
+
+var
   binstr  : string;
   success : boolean;
+  cmdstr, nextcmd : TCmdStr;
+  current : TStringListItem;
 begin
   MakeStaticLibrary:=false;
 { remove the library, to be sure that it is rewritten }
@@ -564,8 +608,16 @@ begin
   smartpath:=current_module.outputpath^+FixPath(lower(current_module.modulename^)+target_info.smartext,false);
   SplitBinCmd(target_ar.arcmd,binstr,cmdstr);
   Replace(cmdstr,'$LIB',maybequoted(current_module.staticlibfilename^));
-  Replace(cmdstr,'$FILES',FixFileName(smartpath+current_module.asmprefix^+'*'+target_info.objext));
-  success:=DoExec(FindUtil(binstr),cmdstr,false,true);
+  { create AR commands }
+  success := true;
+  nextcmd := cmdstr;
+  current := TStringListItem(SmartLinkOFiles.First);
+  repeat
+    Replace(nextcmd,'$FILES',GetNextFiles(240 - length(nextcmd), current));
+    success:=DoExec(FindUtil(binstr),nextcmd,false,true);
+    nextcmd := cmdstr;
+  until (not assigned(current)) or (not success);
+
 { Clean up }
   if not(cs_asm_leave in aktglobalswitches) then
    if not(cs_link_extern in aktglobalswitches) then

+ 8 - 4
compiler/psub.pas

@@ -852,15 +852,19 @@ implementation
               end;
 {$endif NoOpt}
 
-            { Add end symbol and debug info }
-            aktfilepos:=exitpos;
-            gen_proc_symbol_end(templist);
-            aktproccode.concatlist(templist);
 
 {$ifdef ARM}
             insertpcrelativedata(aktproccode,aktlocaldata);
 {$endif ARM}
 
+            { Add end symbol and debug info }
+            { this must be done after the pcrelativedata is appended else the distance calculation of
+              insertpcrelativedata will be wrong, further the pc indirect data is part of the procedure
+              so it should be inserted before the end symbol (FK)
+            }
+            aktfilepos:=exitpos;
+            gen_proc_symbol_end(templist);
+            aktproccode.concatlist(templist);
 {$ifdef POWERPC}
             fixup_jmps(aktproccode);
 {$endif POWERPC}

+ 5 - 2
compiler/x86/cgx86.pas

@@ -1687,7 +1687,7 @@ unit cgx86;
                     for i:=1 to localsize div winstackpagesize do
                       begin
                          reference_reset_base(href,NR_ESP,localsize-i*winstackpagesize);
-                         list.concat(Taicpu.op_const_ref(A_MOV,S_L,0,href));
+                         list.concat(Taicpu.op_reg_ref(A_MOV,S_L,NR_EAX,href));
                       end;
                     list.concat(Taicpu.op_reg(A_PUSH,S_L,NR_EAX));
                  end
@@ -1695,14 +1695,17 @@ unit cgx86;
                  begin
                     objectlibrary.getlabel(again);
                     getcpuregister(list,NR_EDI);
+                    list.concat(Taicpu.op_reg(A_PUSH,S_L,NR_EDI));
                     list.concat(Taicpu.op_const_reg(A_MOV,S_L,localsize div winstackpagesize,NR_EDI));
                     a_label(list,again);
                     list.concat(Taicpu.op_const_reg(A_SUB,S_L,winstackpagesize-4,NR_ESP));
                     list.concat(Taicpu.op_reg(A_PUSH,S_L,NR_EAX));
                     list.concat(Taicpu.op_reg(A_DEC,S_L,NR_EDI));
                     a_jmp_cond(list,OC_NE,again);
+                    list.concat(Taicpu.op_const_reg(A_SUB,S_L,localsize mod winstackpagesize - 4,NR_ESP));
+                    reference_reset_base(href,NR_ESP,localsize-4);
+                    list.concat(Taicpu.op_ref_reg(A_MOV,S_L,href,NR_EDI));
                     ungetcpuregister(list,NR_EDI);
-                    list.concat(Taicpu.op_const_reg(A_SUB,S_L,localsize mod winstackpagesize,NR_ESP));
                  end
              end
            else

+ 6 - 0
rtl/inc/heap.inc

@@ -78,12 +78,18 @@ const
 
 type
   poschunk = ^toschunk;
+  { keep size of this record dividable by 16 }
   toschunk = record
     size,
     used,
     chunkindex : ptrint;
     next,
     prev  : poschunk;
+{$ifdef CPU64}
+    pad1 : array[0..0] of pointer;
+{$else CPU64}
+    pad1 : array[0..2] of pointer;
+{$endif CPU64}
   end;
 
   pmemchunk_fixed  = ^tmemchunk_fixed;