瀏覽代碼

* autoswitch to writing 32-bit PUBDEF OMF records if there's a need to encode a
32-bit offset

git-svn-id: trunk@39089 -

nickysn 7 年之前
父節點
當前提交
a656d98657
共有 1 個文件被更改,包括 19 次插入0 次删除
  1. 19 0
      compiler/omfbase.pas

+ 19 - 0
compiler/omfbase.pas

@@ -410,6 +410,8 @@ interface
       procedure DecodeFrom(RawRecord: TOmfRawRecord);override;
       procedure DecodeFrom(RawRecord: TOmfRawRecord);override;
       procedure EncodeTo(RawRecord: TOmfRawRecord);override;
       procedure EncodeTo(RawRecord: TOmfRawRecord);override;
 
 
+      procedure MaybeGo32;
+
       property Is32Bit: Boolean read FIs32Bit write FIs32Bit;
       property Is32Bit: Boolean read FIs32Bit write FIs32Bit;
       property BaseGroupIndex: Integer read FBaseGroupIndex write FBaseGroupIndex;
       property BaseGroupIndex: Integer read FBaseGroupIndex write FBaseGroupIndex;
       property BaseSegmentIndex: Integer read FBaseSegmentIndex write FBaseSegmentIndex;
       property BaseSegmentIndex: Integer read FBaseSegmentIndex write FBaseSegmentIndex;
@@ -1718,6 +1720,7 @@ implementation
       Len,LastIncludedIndex,NextOfs,I: Integer;
       Len,LastIncludedIndex,NextOfs,I: Integer;
       PubName: TOmfPublicNameElement;
       PubName: TOmfPublicNameElement;
     begin
     begin
+      MaybeGo32;
       if Is32Bit then
       if Is32Bit then
         RawRecord.RecordType:=RT_PUBDEF32
         RawRecord.RecordType:=RT_PUBDEF32
       else
       else
@@ -1770,6 +1773,22 @@ implementation
       NextIndex:=LastIncludedIndex+1;
       NextIndex:=LastIncludedIndex+1;
     end;
     end;
 
 
+  procedure TOmfRecord_PUBDEF.MaybeGo32;
+    var
+      I: Integer;
+      PubName: TOmfPublicNameElement;
+    begin
+      for I:=0 to PublicNames.Count-1 do
+        begin
+          PubName:=TOmfPublicNameElement(PublicNames[I]);
+          if PubName.PublicOffset>$ffff then
+            begin
+              Is32Bit:=true;
+              exit;
+            end;
+        end;
+    end;
+
   { TOmfExternalNameElement }
   { TOmfExternalNameElement }
 
 
   function TOmfExternalNameElement.GetLengthInFile: Integer;
   function TOmfExternalNameElement.GetLengthInFile: Integer;