浏览代码

* avoid setting the oso_Data flag on bss sections

git-svn-id: trunk@45567 -
nickysn 5 年之前
父节点
当前提交
b29257fd05
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16 0
      compiler/ogrel.pas

+ 16 - 0
compiler/ogrel.pas

@@ -709,6 +709,7 @@ implementation
           reloc:TRelRelocation;
           reloc:TRelRelocation;
           RelocDataOffset: TObjSectionOfs;
           RelocDataOffset: TObjSectionOfs;
           RelocTyp: TObjRelocationType;
           RelocTyp: TObjRelocationType;
+          zeros_only: Boolean;
         begin
         begin
           result:=false;
           result:=false;
           if (length(T)<5) or (((length(T)-2) mod 3)<>0) then
           if (length(T)<5) or (((length(T)-2) mod 3)<>0) then
@@ -781,6 +782,21 @@ implementation
               InputError('Area offset in T exceeds area size');
               InputError('Area offset in T exceeds area size');
               exit;
               exit;
             end;
             end;
+          { section name is '_BSS'/'_STACK'/'_HEAP' and there are no relocations }
+          if ((ObjSec.Name='_BSS') or (ObjSec.Name='_STACK') or (ObjSec.Name='_HEAP')) and
+             (length(ArrR)=4) then
+            begin
+              zeros_only:=true;
+              for i:=2 to length(ArrT)-1 do
+                if ArrT[i]<>0 then
+                  begin
+                    zeros_only:=false;
+                    break;
+                  end;
+              { avoid setting the oso_Data flag on .bss sections, if there are no relocations and all data is zero }
+              if zeros_only then
+                exit;
+            end;
           { parse relocations }
           { parse relocations }
           SetLength(ArrTIsRelocHiByte,Length(ArrT));
           SetLength(ArrTIsRelocHiByte,Length(ArrT));
           LastDataOfsIndex:=2;
           LastDataOfsIndex:=2;