Browse Source

Merged revisions 7270,7272-7274 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

r7270 (pierre)
* try to fix cygwin import lib problem in internal linker

r7272 (florian)
* better error message in case of parser error


r7273 (florian)
- removed accidently commited writeln


r7274 (florian)
* set ConsoleStartupMode in all startup codes

git-svn-id: branches/fixes_2_2@7275 -

florian 18 years ago
parent
commit
a6db2154d8
5 changed files with 116 additions and 11 deletions
  1. 86 4
      compiler/ogbase.pas
  2. 0 1
      ide/fp.pas
  3. 10 0
      rtl/win32/sysinitgprof.pp
  4. 7 0
      rtl/win32/sysinitpas.pp
  5. 13 6
      utils/fpdoc/makeskel.pp

+ 86 - 4
compiler/ogbase.pas

@@ -740,11 +740,84 @@ implementation
 
 
 
 
     function  TObjSection.FullName:string;
     function  TObjSection.FullName:string;
+      var
+        SecIdata2,
+        SecIdata4,
+        SecIData6,
+        SecIdata7: TObjSection;
+        p : pchar;
+        l,IData6Pos : longint;
+        Idata6Name,dllname : shortstring;
       begin
       begin
         if not assigned(FCachedFullName) then
         if not assigned(FCachedFullName) then
           begin
           begin
             if assigned(ObjData) then
             if assigned(ObjData) then
-              FCachedFullName:=stringdup(ObjData.Name+'('+Name+')')
+              begin
+                { C import libs are not yet ordered by import names
+                  and the objct name does not follow the same order
+                  as the import names, but idata$4 must be
+                  ordered alphabetically PM }
+                SecIdata2:=ObjData.findsection('.idata$2');
+                SecIdata4:=ObjData.findsection('.idata$4');
+                SecIdata6:=ObjData.findsection('.idata$6');
+                SecIdata7:=ObjData.findsection('.idata$7');
+                if (assigned(SecIdata7) and assigned(SecIdata4) and
+                     (Secidata4.Size=4)) or
+                   (assigned(SecIData2)) then
+                  begin
+                    if assigned(secidata6) then
+                      begin
+                        idata6Pos:=SecIdata6.Data.Pos;
+                        SecIdata6.Data.Seek(2);
+                        l:=idata6Pos-2;
+                        if l>255 then
+                          l:=255;
+                        IData6Name[0]:=chr(l);
+                        SecIdata6.Data.Read(IData6Name[1],l);
+                        SecIdata6.Data.Seek(idata6Pos);
+                      end
+                    else
+                      IData6Name:='<empty>';
+                    if assigned(SecIdata2) and
+                       (SecIdata2.ObjSymbolDefines.count=1) then
+                      begin
+                        dllname:=TObjSymbol(SecIdata2.ObjSymbolDefines.Last).name;
+                        if pos('__head_',dllname)=1 then
+                          dllname:=copy(dllname,8,length(dllname));
+                        while (pos('_',dllname)=1) do
+                          delete(dllname,1,1);
+                        dllname:=dllname+' head';
+                      end
+                    else if (SecIdata7.size=4) and
+                       (SecIdata7.ObjRelocations.count=1) and
+                       assigned(TObjRelocation(SecIdata7.ObjRelocations.Last).symbol) then
+                      begin
+                          dllname:=TObjRelocation(SecIdata7.ObjRelocations.Last).symbol.name;
+                        if pos('__head_',dllname)=1 then
+                          dllname:=copy(dllname,8,length(dllname));
+                        while (pos('_',dllname)=1) do
+                          delete(dllname,1,1);
+                        dllname:=dllname+' import';
+                      end
+                    else if (SecIdata7.ObjSymbolDefines.count=1) then
+                      begin
+                        dllname:=TObjSymbol(SecIdata7.ObjSymbolDefines.Last).name;
+                        if pos('_iname',dllname)>0 then
+                          dllname:=copy(dllname,1,pos('_iname',dllname)-1);
+                        while (pos('_',dllname)=1) do
+                          delete(dllname,1,1);
+                        dllname:=dllname+' tail';
+                      end
+                    else
+                      dllname:=ObjData.Name;
+                    FCachedFullName:=stringdup(dllName+'('+Idata6Name+')');
+                    if assigned(exemap) then
+                      exemap.Add(ObjData.Name+'('+Name+') replaced by '+
+                       FCachedFullName^);
+                  end
+                else
+                  FCachedFullName:=stringdup(ObjData.Name+'('+Name+')')
+              end
             else
             else
               FCachedFullName:=stringdup(Name);
               FCachedFullName:=stringdup(Name);
           end;
           end;
@@ -1633,7 +1706,7 @@ implementation
               end;
               end;
           end;
           end;
         { Sort list if needed }
         { Sort list if needed }
-        if CurrExeSec.Name='.idata' then
+        if (CurrExeSec.Name='.idata') then
           TmpObjSectionList.Sort(@ObjSectionNameCompare);
           TmpObjSectionList.Sort(@ObjSectionNameCompare);
         { Add the (sorted) list to the current ExeSection }
         { Add the (sorted) list to the current ExeSection }
         for i:=0 to TmpObjSectionList.Count-1 do
         for i:=0 to TmpObjSectionList.Count-1 do
@@ -1986,7 +2059,9 @@ implementation
                                 exemap.Add('');
                                 exemap.Add('');
                                 firstarchive:=false;
                                 firstarchive:=false;
                               end;
                               end;
-                            exemap.Add(StaticLibrary.ArReader.FileName+' - '+{exesym.ObjSymbol.ObjSection.FullName+}'('+exesym.Name+')');
+                            exemap.Add(StaticLibrary.ArReader.FileName+' - '+
+                              {exesym.ObjSymbol.ObjSection.FullName+}
+                              '('+exesym.Name+')');
                           end;
                           end;
                         objinput:=StaticLibrary.ObjInputClass.Create;
                         objinput:=StaticLibrary.ObjInputClass.Create;
                         objdata:=objinput.newObjData(StaticLibrary.ArReader.FileName);
                         objdata:=objinput.newObjData(StaticLibrary.ArReader.FileName);
@@ -2398,7 +2473,14 @@ implementation
           else
           else
             internalerror(200603316);
             internalerror(200603316);
           if assigned(exemap) then
           if assigned(exemap) then
-            exemap.Add('  References '+refobjsec.fullname);
+            begin
+              objsym:=objreloc.symbol;
+              if assigned(objsym) then
+                exemap.Add('  References  '+objsym.name+' in '
+                  +refobjsec.fullname)
+              else
+                exemap.Add('  References '+refobjsec.fullname);
+            end;
           AddToObjSectionWorkList(refobjsec);
           AddToObjSectionWorkList(refobjsec);
         end;
         end;
 
 

+ 0 - 1
ide/fp.pas

@@ -530,7 +530,6 @@ BEGIN
   Keyboard.RestoreStartMode;
   Keyboard.RestoreStartMode;
 {$endif defined(unix)}
 {$endif defined(unix)}
 {$if defined(windows)}
 {$if defined(windows)}
-  writeln(hexstr(StartupConsoleMode,8));
   SetConsoleMode(GetStdHandle(cardinal(Std_Input_Handle)),StartupConsoleMode);
   SetConsoleMode(GetStdHandle(cardinal(Std_Input_Handle)),StartupConsoleMode);
 {$endif defined(windows)}
 {$endif defined(windows)}
   StreamError:=nil;
   StreamError:=nil;

+ 10 - 0
rtl/win32/sysinitgprof.pp

@@ -45,6 +45,12 @@ unit sysinitgprof;
     procedure CMainEXE;cdecl;forward;
     procedure CMainEXE;cdecl;forward;
     procedure CMainDLL;cdecl;forward;
     procedure CMainDLL;cdecl;forward;
 
 
+    const
+      STD_INPUT_HANDLE = dword(-10);
+
+    function GetStdHandle(nStdHandle:DWORD) : THandle; stdcall; external 'kernel32' name 'GetStdHandle';
+    function GetConsoleMode(hConsoleHandle: THandle; var lpMode: DWORD): Boolean; stdcall; external 'kernel32' name 'GetConsoleMode';
+
     procedure EXEgmon_start;
     procedure EXEgmon_start;
       begin
       begin
         if monstarted=0 then
         if monstarted=0 then
@@ -96,6 +102,10 @@ unit sysinitgprof;
           subl   $0x8,%esp
           subl   $0x8,%esp
           andl   $0xfffffff0,%esp
           andl   $0xfffffff0,%esp
         end;
         end;
+        { it seems cygwin messed around with the console mode so we've to
+          store the startup console mode before cygwin can do anything (FK)
+        }
+        GetConsoleMode(GetStdHandle((Std_Input_Handle)),StartupConsoleMode);
         Cygwin_crt0(@CMainEXE);
         Cygwin_crt0(@CMainEXE);
       end;
       end;
 
 

+ 7 - 0
rtl/win32/sysinitpas.pp

@@ -25,10 +25,17 @@ unit sysinitpas;
     procedure EXE_Entry; external name '_FPC_EXE_Entry';
     procedure EXE_Entry; external name '_FPC_EXE_Entry';
     function DLL_entry : longbool; external name '_FPC_DLL_Entry';
     function DLL_entry : longbool; external name '_FPC_DLL_Entry';
 
 
+    const
+      STD_INPUT_HANDLE = dword(-10);
+
+    function GetStdHandle(nStdHandle:DWORD) : THandle; stdcall; external 'kernel32' name 'GetStdHandle';
+    function GetConsoleMode(hConsoleHandle: THandle; var lpMode: DWORD): Boolean; stdcall; external 'kernel32' name 'GetConsoleMode';
 
 
     procedure _FPC_mainCRTStartup;stdcall;public name '_mainCRTStartup';
     procedure _FPC_mainCRTStartup;stdcall;public name '_mainCRTStartup';
     begin
     begin
       IsConsole:=true;
       IsConsole:=true;
+      { do it like it is necessary for the startup code linking against cygwin }
+      GetConsoleMode(GetStdHandle((Std_Input_Handle)),StartupConsoleMode);
       Exe_entry;
       Exe_entry;
     end;
     end;
 
 

+ 13 - 6
utils/fpdoc/makeskel.pp

@@ -59,7 +59,7 @@ var
   DisableProtected,
   DisableProtected,
   DisablePrivate,
   DisablePrivate,
   DisableFunctionResults: Boolean;
   DisableFunctionResults: Boolean;
- 
+
   EmitClassSeparator: Boolean;
   EmitClassSeparator: Boolean;
   PackageName, OutputName: String;
   PackageName, OutputName: String;
   f: Text;
   f: Text;
@@ -87,14 +87,14 @@ function TSkelEngine.CreateElement(AClass: TPTreeElement; const AName: String;
         If (PT<>Nil) and ((PT is TPasProcedure) or (PT is TPasProcedure))   then
         If (PT<>Nil) and ((PT is TPasProcedure) or (PT is TPasProcedure))   then
           PP:=PT.Parent
           PP:=PT.Parent
         else
         else
-          PP:=Nil;  
+          PP:=Nil;
         If (PP<>Nil) and (PP is TPasClassType) then
         If (PP<>Nil) and (PP is TPasClassType) then
           begin
           begin
           ParentVisible:=((not DisablePrivate or (PT.Visibility<>visPrivate)) and
           ParentVisible:=((not DisablePrivate or (PT.Visibility<>visPrivate)) and
                          (not DisableProtected or (PT.Visibility<>visProtected)));
                          (not DisableProtected or (PT.Visibility<>visProtected)));
           end;
           end;
-        end;  
-      end;         
+        end;
+      end;
     Result:=Assigned(AParent) and (Length(AName) > 0) and
     Result:=Assigned(AParent) and (Length(AName) > 0) and
             (ParentVisible and (not DisableArguments or (APasElement.ClassType <> TPasArgument))) and
             (ParentVisible and (not DisableArguments or (APasElement.ClassType <> TPasArgument))) and
             (ParentVisible and (not DisableFunctionResults or (APasElement.ClassType <> TPasResultElement))) and
             (ParentVisible and (not DisableFunctionResults or (APasElement.ClassType <> TPasResultElement))) and
@@ -380,13 +380,20 @@ begin
          WriteLn(f, '</module> <!-- ', Module.Name, ' -->');
          WriteLn(f, '</module> <!-- ', Module.Name, ' -->');
          WriteLn(f, '');
          WriteLn(f, '');
        except
        except
-        on e:EFileNotFoundError do
+         on e:EFileNotFoundError do
            begin
            begin
              Writeln(StdErr,' file ', e.message, ' not found');
              Writeln(StdErr,' file ', e.message, ' not found');
              close(f);
              close(f);
              Halt(1);
              Halt(1);
            end;
            end;
-         end;
+         on e:EParserError do
+           begin
+             Writeln(StdErr,'', e.filename,'(',e.row,',',e.column,') Fatal: ',e.message);
+             close(f);
+             Halt(1);
+           end;
+       end;
+
       finally
       finally
         Engine.Free;
         Engine.Free;
        end;
        end;