Sfoglia il codice sorgente

* avoid setting the oso_Data flag on bss sections

git-svn-id: trunk@45567 -
nickysn 5 anni fa
parent
commit
b29257fd05
1 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  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;