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

* ogcoff.pas: sort all objsections having '$' in the name, not just .idata$*. This is a documented PECOFF feature and it is required for tls callback stuff to link correctly regardless of the order of declarations in source files.

git-svn-id: trunk@17968 -
sergei 14 жил өмнө
parent
commit
6a2e87121b

+ 4 - 4
compiler/ogbase.pas

@@ -439,7 +439,7 @@ interface
         function  writeData:boolean;virtual;abstract;
         function  writeData:boolean;virtual;abstract;
         property CExeSection:TExeSectionClass read FCExeSection write FCExeSection;
         property CExeSection:TExeSectionClass read FCExeSection write FCExeSection;
         property CObjData:TObjDataClass read FCObjData write FCObjData;
         property CObjData:TObjDataClass read FCObjData write FCObjData;
-        procedure Order_ObjSectionList(ObjSectionList : TFPObjectList);virtual;
+        procedure Order_ObjSectionList(ObjSectionList : TFPObjectList; const aPattern:string);virtual;
       public
       public
         CurrDataPos  : aword;
         CurrDataPos  : aword;
         MaxMemPos    : qword;
         MaxMemPos    : qword;
@@ -1599,7 +1599,7 @@ implementation
 
 
     procedure TExeOutput.Load_EntryName(const aname:string);
     procedure TExeOutput.Load_EntryName(const aname:string);
       begin
       begin
-        EntryName:=aname;
+        FEntryName:=aname;
       end;
       end;
 
 
 
 
@@ -1698,7 +1698,7 @@ implementation
               end;
               end;
           end;
           end;
         { Order list if needed }
         { Order list if needed }
-        Order_ObjSectionList(TmpObjSectionList);
+        Order_ObjSectionList(TmpObjSectionList,aname);
         { Add the (ordered) list to the current ExeSection }
         { Add the (ordered) list to the current ExeSection }
         for i:=0 to TmpObjSectionList.Count-1 do
         for i:=0 to TmpObjSectionList.Count-1 do
           begin
           begin
@@ -1709,7 +1709,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TExeOutput.Order_ObjSectionList(ObjSectionList : TFPObjectList);
+    procedure TExeOutput.Order_ObjSectionList(ObjSectionList : TFPObjectList; const aPattern:string);
       begin
       begin
       end;
       end;
 
 

+ 6 - 3
compiler/ogcoff.pas

@@ -235,7 +235,7 @@ interface
          procedure ExeSectionList_write_data(p:TObject;arg:pointer);
          procedure ExeSectionList_write_data(p:TObject;arg:pointer);
        protected
        protected
          function writedata:boolean;override;
          function writedata:boolean;override;
-         procedure Order_ObjSectionList(ObjSectionList : TFPObjectList);override;
+         procedure Order_ObjSectionList(ObjSectionList : TFPObjectList;const aPattern:string);override;
        public
        public
          constructor createcoff(awin32:boolean);
          constructor createcoff(awin32:boolean);
          procedure MemPos_Header;override;
          procedure MemPos_Header;override;
@@ -2518,9 +2518,12 @@ const pemagic : array[0..3] of byte = (
         Result:=CompareStr(I1.Name,I2.Name);
         Result:=CompareStr(I1.Name,I2.Name);
       end;
       end;
 
 
-    procedure TCoffexeoutput.Order_ObjSectionList(ObjSectionList: TFPObjectList);
+    procedure TCoffexeoutput.Order_ObjSectionList(ObjSectionList: TFPObjectList;const aPattern:string);
       begin
       begin
-        if CurrExeSec.Name = '.idata' then
+        { Sort sections having '$' in the name, that's how PECOFF documentation
+          tells to handle them. However, look for '$' in the pattern, not in section
+          names, because the latter often get superfluous '$' due to mangling. }
+        if Pos('$',aPattern)>0 then
           ObjSectionList.Sort(@IdataObjSectionCompare);
           ObjSectionList.Sort(@IdataObjSectionCompare);
       end;
       end;