Selaa lähdekoodia

+ support AB_LOCAL symbols in OMF object files, by implementing support for
LPUBDEF/LPUBDEF32 OMF records

git-svn-id: trunk@39210 -

nickysn 7 vuotta sitten
vanhempi
commit
bfdd75eabf
2 muutettua tiedostoa jossa 37 lisäystä ja 8 poistoa
  1. 14 2
      compiler/ogomf.pas
  2. 23 6
      compiler/omfbase.pas

+ 14 - 2
compiler/ogomf.pas

@@ -903,7 +903,14 @@ implementation
               begin
                 PublicNameElem:=TOmfPublicNameElement.Create(PubNamesForSection[objsym.objsection.index-1],objsym.Name);
                 PublicNameElem.PublicOffset:=objsym.offset;
-              end;
+                PublicNameElem.IsLocal:=False;
+              end
+            else if objsym.bind=AB_LOCAL then
+              begin
+                PublicNameElem:=TOmfPublicNameElement.Create(PubNamesForSection[objsym.objsection.index-1],objsym.Name);
+                PublicNameElem.PublicOffset:=objsym.offset;
+                PublicNameElem.IsLocal:=True;
+              end
           end;
 
         for i:=0 to Data.ObjSectionList.Count-1 do
@@ -984,6 +991,7 @@ implementation
         GrpDef: TOmfRecord_GRPDEF;
         DGroupSegments: TSegmentList;
         nsections: Integer;
+        objsym: TObjSymbol;
       begin
         { calc amount of sections we have and set their index, starting with 1 }
         nsections:=1;
@@ -1396,7 +1404,10 @@ implementation
             if not CaseSensitiveSymbols then
               symname:=UpCase(symname);
             objsym:=objdata.CreateSymbol(symname);
-            objsym.bind:=AB_GLOBAL;
+            if PubDefElem.IsLocal then
+              objsym.bind:=AB_LOCAL
+            else
+              objsym.bind:=AB_GLOBAL;
             objsym.typ:=AT_FUNCTION;
             objsym.group:=basegroup;
             objsym.objsection:=objsec;
@@ -1988,6 +1999,7 @@ implementation
             RT_EXTDEF:
               if not ReadExtDef(FRawRecord,objdata) then
                 exit;
+            RT_LPUBDEF,RT_LPUBDEF32,
             RT_PUBDEF,RT_PUBDEF32:
               if not ReadPubDef(FRawRecord,objdata) then
                 exit;

+ 23 - 6
compiler/omfbase.pas

@@ -393,11 +393,13 @@ interface
     private
       FPublicOffset: DWord;
       FTypeIndex: Integer;
+      FIsLocal: Boolean;
     public
       function GetLengthInFile(Is32Bit: Boolean): Integer;
 
       property PublicOffset: DWord read FPublicOffset write FPublicOffset;
       property TypeIndex: Integer read FTypeIndex write FTypeIndex;
+      property IsLocal: Boolean read FIsLocal write FIsLocal;
     end;
 
     { TOmfRecord_PUBDEF }
@@ -405,6 +407,7 @@ interface
     TOmfRecord_PUBDEF = class(TOmfParsedRecord)
     private
       FIs32Bit: Boolean;
+      FIsLocal: Boolean;
       FBaseGroupIndex: Integer;
       FBaseSegmentIndex: Integer;
       FBaseFrame: Word;
@@ -418,6 +421,7 @@ interface
       procedure MaybeGo32;
 
       property Is32Bit: Boolean read FIs32Bit write FIs32Bit;
+      property IsLocal: Boolean read FIsLocal write FIsLocal;
       property BaseGroupIndex: Integer read FBaseGroupIndex write FBaseGroupIndex;
       property BaseSegmentIndex: Integer read FBaseSegmentIndex write FBaseSegmentIndex;
       property BaseFrame: Word read FBaseFrame write FBaseFrame;
@@ -1754,9 +1758,10 @@ implementation
       PublicOffset: DWord;
       PubName: TOmfPublicNameElement;
     begin
-      if not (RawRecord.RecordType in [RT_PUBDEF,RT_PUBDEF32]) then
+      if not (RawRecord.RecordType in [RT_PUBDEF,RT_PUBDEF32,RT_LPUBDEF,RT_LPUBDEF32]) then
         internalerror(2015040301);
-      Is32Bit:=RawRecord.RecordType=RT_PUBDEF32;
+      Is32Bit:=RawRecord.RecordType in [RT_PUBDEF32,RT_LPUBDEF32];
+      IsLocal:=RawRecord.RecordType in [RT_LPUBDEF,RT_LPUBDEF32];
 
       NextOfs:=RawRecord.ReadIndexedRef(0,FBaseGroupIndex);
       NextOfs:=RawRecord.ReadIndexedRef(NextOfs,FBaseSegmentIndex);
@@ -1790,6 +1795,7 @@ implementation
             end;
           NextOfs:=RawRecord.ReadIndexedRef(NextOfs,TypeIndex);
           PubName:=TOmfPublicNameElement.Create(PublicNames,Name);
+          PubName.IsLocal:=IsLocal;
           PubName.PublicOffset:=PublicOffset;
           PubName.TypeIndex:=TypeIndex;
         end;
@@ -1802,11 +1808,20 @@ implementation
       Len,LastIncludedIndex,NextOfs,I: Integer;
       PubName: TOmfPublicNameElement;
     begin
+      if NextIndex>=PublicNames.Count then
+        internalerror(2018061101);
       MaybeGo32;
-      if Is32Bit then
-        RawRecord.RecordType:=RT_PUBDEF32
+      IsLocal:=TOmfPublicNameElement(PublicNames[NextIndex]).IsLocal;
+      if IsLocal then
+        if Is32Bit then
+          RawRecord.RecordType:=RT_LPUBDEF32
+        else
+          RawRecord.RecordType:=RT_LPUBDEF
       else
-        RawRecord.RecordType:=RT_PUBDEF;
+        if Is32Bit then
+          RawRecord.RecordType:=RT_PUBDEF32
+        else
+          RawRecord.RecordType:=RT_PUBDEF;
 
       NextOfs:=RawRecord.WriteIndexedRef(0,BaseGroupIndex);
       NextOfs:=RawRecord.WriteIndexedRef(NextOfs,BaseSegmentIndex);
@@ -1823,7 +1838,9 @@ implementation
       repeat
         Inc(LastIncludedIndex);
         Inc(Len,TOmfPublicNameElement(PublicNames[LastIncludedIndex]).GetLengthInFile(Is32Bit));
-      until (LastIncludedIndex>=(PublicNames.Count-1)) or ((Len+TOmfPublicNameElement(PublicNames[LastIncludedIndex+1]).GetLengthInFile(Is32Bit))>=RecordLengthLimit);
+      until (LastIncludedIndex>=(PublicNames.Count-1)) or
+            ((Len+TOmfPublicNameElement(PublicNames[LastIncludedIndex+1]).GetLengthInFile(Is32Bit))>=RecordLengthLimit) or
+            (TOmfPublicNameElement(PublicNames[LastIncludedIndex+1]).IsLocal<>IsLocal);
 
       { write the public names... }
       for I:=NextIndex to LastIncludedIndex do