Browse Source

* Added virtual function TObjSection.GetAltName to be able to specify additional section name by descendants.
* OMF: Use the name of the first global symbol as an addition section name. This name is visible in the linker map file and helps tracking of section references.

git-svn-id: trunk@46298 -

yury 5 years ago
parent
commit
985220d94c
2 changed files with 30 additions and 2 deletions
  1. 17 2
      compiler/ogbase.pas
  2. 13 0
      compiler/ogomf.pas

+ 17 - 2
compiler/ogbase.pas

@@ -309,6 +309,8 @@ interface
        FSizeLimit : TObjSectionOfs;
        procedure SetSecOptions(Aoptions:TObjSectionOptions);
        procedure SectionTooLargeError;
+     protected
+       function GetAltName: string; virtual;
      public
        ObjData    : TObjData;
        index      : longword;  { index of section in section headers }
@@ -1013,6 +1015,12 @@ implementation
       end;
 
 
+    function TObjSection.GetAltName: string;
+      begin
+        result:='';
+      end;
+
+
     function TObjSection.write(const d;l:TObjSectionOfs):TObjSectionOfs;
       begin
         result:=size;
@@ -1152,13 +1160,20 @@ implementation
 
 
     function  TObjSection.FullName:string;
+      var
+        s: string;
       begin
         if not assigned(FCachedFullName) then
           begin
+            s:=GetAltName;
+            if s<>'' then
+              s:=Name+s
+            else
+              s:=Name;
             if assigned(ObjData) then
-              FCachedFullName:=stringdup(ObjData.Name+'('+Name+')')
+              FCachedFullName:=stringdup(ObjData.Name+'('+s+')')
             else
-              FCachedFullName:=stringdup(Name);
+              FCachedFullName:=stringdup(s);
           end;
         result:=FCachedFullName^;
       end;

+ 13 - 0
compiler/ogomf.pas

@@ -74,6 +74,7 @@ interface
       private
         FClassName: string;
         FOverlayName: string;
+        FFirstSym: TObjSymbol;
         FCombination: TOmfSegmentCombination;
         FUse: TOmfSegmentUse;
         FPrimaryGroup: TObjSectionGroup;
@@ -81,6 +82,8 @@ interface
         FMZExeUnifiedLogicalSegment: TMZExeUnifiedLogicalSegment;
         FLinNumEntries: TOmfSubRecord_LINNUM_MsLink_LineNumberList;
         function GetOmfAlignment: TOmfSegmentAlignment;
+      protected
+        function GetAltName: string; override;
       public
         constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:longint;Aoptions:TObjSectionOptions);override;
         destructor destroy;override;
@@ -1006,6 +1009,14 @@ implementation
         end;
       end;
 
+    function TOmfObjSection.GetAltName: string;
+      begin
+        if FFirstSym<>nil then
+          result:='/'+FFirstSym.Name
+        else
+          result:='';
+      end;
+
     constructor TOmfObjSection.create(AList: TFPHashObjectList;
           const Aname: string; Aalign: longint; Aoptions: TObjSectionOptions);
       begin
@@ -1983,6 +1994,8 @@ implementation
             objsym.objsection:=objsec;
             objsym.offset:=PubDefElem.PublicOffset;
             objsym.size:=0;
+            if (objsym.bind=AB_GLOBAL) and (objsec.FFirstSym=nil) then
+              objsec.FFirstSym:=objsym;
           end;
         PubDefRec.Free;
         Result:=True;