[fpc-devel] symify.pp broken

Robert Riebisch rr at bttr-software.de
Tue Apr 15 11:21:32 CEST 2008

Tomas Hajny wrote:

> However, I can't believe that information about this offset (i.e. size of
> the stub) isn't already available somewhere in the exe file itself (either
> in the general header or possibly in the COFF section headers), I just

The following simple snippet for computing "stubsize" is based on
function "create_go32_stub" in file "gnu\binutl-2.14\bfd\coff-stgo32.c"
from DJGPP's "bnu21?s.zip". Information is available here:
<http://www.delorie.com/djgpp/doc/exe/>. 512 bytes form a page (or
block) as per Microsoft's definition. "tdosheader" is from file
  tdosheader = packed record
     e_magic : word;
     e_cblp : word;
     e_cp : word;
     e_crlc : word;
     e_cparhdr : word;
     e_minalloc : word;
     e_maxalloc : word;
     e_ss : word;
     e_sp : word;
     e_csum : word;
     e_ip : word;
     e_cs : word;
     e_lfarlc : word;
     e_ovno : word;
     e_res : array[0..3] of word;
     e_oemid : word;
     e_oeminfo : word;
     e_res2 : array[0..9] of word;
     e_lfanew : longint;

  f: file;
  dosheader: tdosheader;
  stubsize: cardinal; /* cardinal OK here? */

  Assign(f, ParamStr(1));
  Reset(f, 1);
  BlockRead(f, dosheader, SizeOf(dosheader));
  if dosheader.e_magic = $5a4d then
    stubsize := dosheader.e_cp * 512;
    if dosheader.e_cblp > 0 then
      stubsize := stubsize + dosheader.e_cblp - 512;
    WriteLn('stub size: ', stubsize);

Robert Riebisch
BTTR Software

More information about the fpc-devel mailing list