瀏覽代碼

* Fetch PECOFF section sizes correctly (not including zero padding), resolves #22788.

git-svn-id: trunk@22879 -
sergei 12 年之前
父節點
當前提交
47cd83ae14
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      rtl/inc/exeinfo.pp

+ 10 - 0
rtl/inc/exeinfo.pp

@@ -379,7 +379,17 @@ begin
      if asecname=secname then
        begin
          secofs:=cardinal(sechdr.datapos) + E.ImgOffset;
+{$ifdef GO32V2}
          seclen:=sechdr.datalen;
+{$else GO32V2}
+         { In PECOFF, datalen includes file padding up to the next section.
+           vsize is the actual payload size if it does not exceed datalen,
+           otherwise it is .bss (or alike) section that we should ignore.  }
+         if sechdr.vsize<=sechdr.datalen then
+           seclen:=sechdr.vsize
+         else
+           exit;
+{$endif GO32V2}
          FindSectionCoff:=true;
          exit;
        end;