Explorar o código

* avoid setting the oso_Data flag on bss sections

git-svn-id: trunk@45567 -
nickysn %!s(int64=5) %!d(string=hai) anos
pai
achega
b29257fd05
Modificáronse 1 ficheiros con 16 adicións e 0 borrados
  1. 16 0
      compiler/ogrel.pas

+ 16 - 0
compiler/ogrel.pas

@@ -709,6 +709,7 @@ implementation
           reloc:TRelRelocation;
           RelocDataOffset: TObjSectionOfs;
           RelocTyp: TObjRelocationType;
+          zeros_only: Boolean;
         begin
           result:=false;
           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');
               exit;
             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 }
           SetLength(ArrTIsRelocHiByte,Length(ArrT));
           LastDataOfsIndex:=2;