Browse Source

* moved to compiler/utils/

peter 24 years ago
parent
commit
f70033953a
5 changed files with 0 additions and 3538 deletions
  1. 0 116
      utils/crc.pas
  2. 0 924
      utils/ppu.pas
  3. 0 1577
      utils/ppudump.pp
  4. 0 277
      utils/ppufiles.pp
  5. 0 644
      utils/ppumove.pp

+ 0 - 116
utils/crc.pas

@@ -1,116 +0,0 @@
-{
-    $Id$
-    Copyright (c) 2000 by Free Pascal Development Team
-
-    Routines to compute CRC values
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-Unit CRC;
-
-Interface
-Function Crc32(Const HStr:String):longint;
-Function UpdateCrc32(InitCrc:longint;var InBuf;InLen:Longint):longint;
-Function UpdCrc32(InitCrc:longint;b:byte):longint;
-
-
-Implementation
-
-{*****************************************************************************
-                                   Crc 32
-*****************************************************************************}
-
-var
-  Crc32Tbl : array[0..255] of longint;
-
-procedure MakeCRC32Tbl;
-var
-  crc : longint;
-  i,n : byte;
-begin
-  for i:=0 to 255 do
-   begin
-     crc:=i;
-     for n:=1 to 8 do
-      if odd(crc) then
-       crc:=(crc shr 1) xor longint($edb88320)
-      else
-       crc:=crc shr 1;
-     Crc32Tbl[i]:=crc;
-   end;
-end;
-
-
-{$ifopt R+}
-{$define Range_check_on}
-{$endif opt R+}
-
-{$R- needed here }
-{CRC 32}
-Function Crc32(Const HStr:String):longint;
-var
-  i,InitCrc : longint;
-begin
-  if Crc32Tbl[1]=0 then
-   MakeCrc32Tbl;
-  InitCrc:=longint($ffffffff);
-  for i:=1 to Length(Hstr) do
-   InitCrc:=Crc32Tbl[byte(InitCrc) xor ord(Hstr[i])] xor (InitCrc shr 8);
-  Crc32:=InitCrc;
-end;
-
-
-
-Function UpdateCrc32(InitCrc:longint;var InBuf;InLen:Longint):longint;
-var
-  i : word;
-  p : pchar;
-begin
-  if Crc32Tbl[1]=0 then
-   MakeCrc32Tbl;
-  p:=@InBuf;
-  for i:=1 to InLen do
-   begin
-     InitCrc:=Crc32Tbl[byte(InitCrc) xor byte(p^)] xor (InitCrc shr 8);
-     inc(longint(p));
-   end;
-  UpdateCrc32:=InitCrc;
-end;
-
-
-
-Function UpdCrc32(InitCrc:longint;b:byte):longint;
-begin
-  if Crc32Tbl[1]=0 then
-   MakeCrc32Tbl;
-  UpdCrc32:=Crc32Tbl[byte(InitCrc) xor b] xor (InitCrc shr 8);
-end;
-
-{$ifdef Range_check_on}
-{$R+}
-{$undef Range_check_on}
-{$endif Range_check_on}
-
-end.
-{
-  $Log$
-  Revision 1.1  2000-08-13 12:58:06  peter
-    * updated for ppu additions
-
-  Revision 1.2  2000/07/13 11:32:39  michael
-  + removed logs
-}

+ 0 - 924
utils/ppu.pas

@@ -1,924 +0,0 @@
-{
-    $Id$
-    Copyright (c) 1998-2000 by Florian Klaempfl
-
-    Routines to read/write ppu files
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit ppu;
-
-{$H-}
-
-interface
-
-{ Also write the ppu if only crc if done, this can be used with ppudump to
-  see the differences between the intf and implementation }
-{ define INTFPPU}
-
-{$ifdef Test_Double_checksum}
-var
-  CRCFile : text;
-const
-  CRC_array_Size = 200000;
-type
-  tcrc_array = array[0..crc_array_size] of longint;
-  pcrc_array = ^tcrc_array;
-{$endif Test_Double_checksum}
-
-const
-{$ifdef newcg}
-  CurrentPPUVersion=102;
-{$else newcg}
-  CurrentPPUVersion=22;
-{$endif newcg}
-
-{ buffer sizes }
-  maxentrysize = 1024;
-  ppubufsize   = 16384;
-
-{ppu entries}
-  mainentryid         = 1;
-  subentryid          = 2;
-  {special}
-  iberror             = 0;
-  ibstartdefs         = 248;
-  ibenddefs           = 249;
-  ibstartsyms         = 250;
-  ibendsyms           = 251;
-  ibendinterface      = 252;
-  ibendimplementation = 253;
-  ibendbrowser        = 254;
-  ibend               = 255;
-  {general}
-  ibmodulename           = 1;
-  ibsourcefiles          = 2;
-  ibloadunit             = 3;
-  ibinitunit             = 4;
-  iblinkunitofiles       = 5;
-  iblinkunitstaticlibs   = 6;
-  iblinkunitsharedlibs   = 7;
-  iblinkotherofiles      = 8;
-  iblinkotherstaticlibs  = 9;
-  iblinkothersharedlibs  = 10;
-  ibdbxcount             = 11;
-  ibsymref               = 12;
-  ibdefref               = 13;
-  ibendsymtablebrowser   = 14;
-  ibbeginsymtablebrowser = 15;
-  ibusedmacros           = 16;
-  {syms}
-  ibtypesym       = 20;
-  ibprocsym       = 21;
-  ibvarsym        = 22;
-  ibconstsym      = 23;
-  ibenumsym       = 24;
-  ibtypedconstsym = 25;
-  ibabsolutesym   = 26;
-  ibpropertysym   = 27;
-  ibvarsym_C      = 28;
-  ibunitsym       = 29;  { needed for browser }
-  iblabelsym      = 30;
-  ibfuncretsym    = 31;
-  ibsyssym        = 32;
-  {definitions}
-  iborddef         = 40;
-  ibpointerdef     = 41;
-  ibarraydef       = 42;
-  ibprocdef        = 43;
-  ibshortstringdef = 44;
-  ibrecorddef      = 45;
-  ibfiledef        = 46;
-  ibformaldef      = 47;
-  ibobjectdef      = 48;
-  ibenumdef        = 49;
-  ibsetdef         = 50;
-  ibprocvardef     = 51;
-  ibfloatdef       = 52;
-  ibclassrefdef    = 53;
-  iblongstringdef  = 54;
-  ibansistringdef  = 55;
-  ibwidestringdef  = 56;
-  ibvariantdef     = 57;
-
-{ unit flags }
-  uf_init          = $1;
-  uf_finalize      = $2;
-  uf_big_endian    = $4;
-  uf_has_dbx       = $8;
-  uf_has_browser   = $10;
-  uf_in_library    = $20;  { is the file in another file than <ppufile>.* ? }
-  uf_smart_linked  = $40;  { the ppu can be smartlinked }
-  uf_static_linked = $80;  { the ppu can be linked static }
-  uf_shared_linked = $100; { the ppu can be linked shared }
-  uf_local_browser = $200;
-  uf_no_link       = $400; { unit has no .o generated, but can still have
-                             external linking! }
-  uf_has_resources = $800; { unit has resource section }
-
-type
-{$ifdef m68k}
-  ppureal=single;
-{$else}
-  ppureal=extended;
-{$endif}
-
-  tppuerror=(ppuentrytoobig,ppuentryerror);
-
-  tppuheader=packed record { 40 bytes }
-    id       : array[1..3] of char; { = 'PPU' }
-    ver      : array[1..3] of char;
-    compiler : word;
-    cpu      : word;
-    target   : word;
-    flags    : longint;
-    size     : longint; { size of the ppufile without header }
-    checksum : longint; { checksum for this ppufile }
-    interface_checksum : longint;
-    future   : array[0..2] of longint;
-  end;
-
-  tppuentry=packed record
-    id   : byte;
-    nr   : byte;
-    size : longint;
-  end;
-
-  pppufile=^tppufile;
-  tppufile=object
-    f        : file;
-    mode     : byte; {0 - Closed, 1 - Reading, 2 - Writing}
-    error    : boolean;
-    fname    : string;
-    fsize    : longint;
-
-    header   : tppuheader;
-    size,crc : longint;
-{$ifdef Test_Double_checksum}
-    crcindex : longint;
-    crc_index : longint;
-    crcindex2 : longint;
-    crc_index2 : longint;
-    crc_test,crc_test2 : pcrc_array;
-
-{$endif def Test_Double_checksum}
-    interface_crc : longint;
-    do_interface_crc : boolean;
-    crc_only : boolean;    { used to calculate interface_crc before implementation }
-    do_crc,
-    change_endian : boolean;
-
-    buf      : pchar;
-    bufstart,
-    bufsize,
-    bufidx   : longint;
-    entrybufstart,
-    entrystart,
-    entryidx : longint;
-    entry    : tppuentry;
-    entrytyp : byte;
-    closed,
-    tempclosed : boolean;
-    closepos : longint;
-    constructor init(fn:string);
-    destructor  done;
-    procedure flush;
-    procedure close;
-    function  CheckPPUId:boolean;
-    function  GetPPUVersion:longint;
-    procedure NewHeader;
-    procedure NewEntry;
-  {read}
-    function  open:boolean;
-    procedure reloadbuf;
-    procedure readdata(var b;len:longint);
-    procedure skipdata(len:longint);
-    function  readentry:byte;
-    function  EndOfEntry:boolean;
-    procedure getdatabuf(var b;len:longint;var result:longint);
-    procedure getdata(var b;len:longint);
-    function  getbyte:byte;
-    function  getword:word;
-    function  getlongint:longint;
-    function  getreal:ppureal;
-    function  getstring:string;
-    procedure getnormalset(var b);
-    procedure getsmallset(var b);
-    function  skipuntilentry(untilb:byte):boolean;
-  {write}
-    function  create:boolean;
-    procedure writeheader;
-    procedure writebuf;
-    procedure writedata(var b;len:longint);
-    procedure writeentry(ibnr:byte);
-    procedure putdata(var b;len:longint);
-    procedure putbyte(b:byte);
-    procedure putword(w:word);
-    procedure putlongint(l:longint);
-    procedure putreal(d:ppureal);
-    procedure putstring(s:string);
-    procedure putnormalset(var b);
-    procedure putsmallset(var b);
-    procedure tempclose;
-    function  tempopen:boolean;
-  end;
-
-implementation
-
-  uses
-{$ifdef Test_Double_checksum}
-    comphook,
-{$endif def Test_Double_checksum}
-    crc;
-
-{*****************************************************************************
-                                  TPPUFile
-*****************************************************************************}
-
-constructor tppufile.init(fn:string);
-begin
-  fname:=fn;
-  change_endian:=false;
-  crc_only:=false;
-  Mode:=0;
-  NewHeader;
-  Error:=false;
-  closed:=true;
-  tempclosed:=false;
-  getmem(buf,ppubufsize);
-end;
-
-
-destructor tppufile.done;
-begin
-  close;
-  if assigned(buf) then
-    freemem(buf,ppubufsize);
-end;
-
-
-procedure tppufile.flush;
-begin
-  if Mode=2 then
-   writebuf;
-end;
-
-
-procedure tppufile.close;
-begin
-  if Mode<>0 then
-   begin
-     Flush;
-     {$I-}
-      system.close(f);
-     {$I+}
-     if ioresult<>0 then;
-     Mode:=0;
-     closed:=true;
-   end;
-end;
-
-
-function tppufile.CheckPPUId:boolean;
-begin
-  CheckPPUId:=((Header.Id[1]='P') and (Header.Id[2]='P') and (Header.Id[3]='U'));
-end;
-
-
-function tppufile.GetPPUVersion:longint;
-var
-  l    : longint;
-  code : integer;
-begin
-  Val(header.ver[1]+header.ver[2]+header.ver[3],l,code);
-  if code=0 then
-   GetPPUVersion:=l
-  else
-   GetPPUVersion:=0;
-end;
-
-
-procedure tppufile.NewHeader;
-var
-  s : string;
-begin
-  fillchar(header,sizeof(tppuheader),0);
-  str(currentppuversion,s);
-  while length(s)<3 do
-   s:='0'+s;
-  with header do
-   begin
-     Id[1]:='P';
-     Id[2]:='P';
-     Id[3]:='U';
-     Ver[1]:=s[1];
-     Ver[2]:=s[2];
-     Ver[3]:=s[3];
-   end;
-end;
-
-
-{*****************************************************************************
-                                TPPUFile Reading
-*****************************************************************************}
-
-function tppufile.open:boolean;
-var
-  ofmode : byte;
-  i      : longint;
-begin
-  open:=false;
-  assign(f,fname);
-  ofmode:=filemode;
-  filemode:=$0;
-  {$I-}
-   reset(f,1);
-  {$I+}
-  filemode:=ofmode;
-  if ioresult<>0 then
-   exit;
-  closed:=false;
-{read ppuheader}
-  fsize:=filesize(f);
-  if fsize<sizeof(tppuheader) then
-   exit;
-  blockread(f,header,sizeof(tppuheader),i);
-{reset buffer}
-  bufstart:=i;
-  bufsize:=0;
-  bufidx:=0;
-  Mode:=1;
-  FillChar(entry,sizeof(tppuentry),0);
-  entryidx:=0;
-  entrystart:=0;
-  entrybufstart:=0;
-  Error:=false;
-  open:=true;
-end;
-
-
-procedure tppufile.reloadbuf;
-begin
-  inc(bufstart,bufsize);
-  blockread(f,buf^,ppubufsize,bufsize);
-  bufidx:=0;
-end;
-
-
-procedure tppufile.readdata(var b;len:longint);
-var
-  p   : pchar;
-  left,
-  idx : longint;
-begin
-  p:=pchar(@b);
-  idx:=0;
-  while len>0 do
-   begin
-     left:=bufsize-bufidx;
-     if len>left then
-      begin
-        move(buf[bufidx],p[idx],left);
-        dec(len,left);
-        inc(idx,left);
-        reloadbuf;
-        if bufsize=0 then
-         exit;
-      end
-     else
-      begin
-        move(buf[bufidx],p[idx],len);
-        inc(bufidx,len);
-        exit;
-      end;
-   end;
-end;
-
-
-procedure tppufile.skipdata(len:longint);
-var
-  left : longint;
-begin
-  while len>0 do
-   begin
-     left:=bufsize-bufidx;
-     if len>left then
-      begin
-        dec(len,left);
-        reloadbuf;
-        if bufsize=0 then
-         exit;
-      end
-     else
-      begin
-        inc(bufidx,len);
-        exit;
-      end;
-   end;
-end;
-
-
-function tppufile.readentry:byte;
-begin
-  if entryidx<entry.size then
-   skipdata(entry.size-entryidx);
-  readdata(entry,sizeof(tppuentry));
-  entrystart:=bufstart+bufidx;
-  entryidx:=0;
-  if not(entry.id in [mainentryid,subentryid]) then
-   begin
-     readentry:=iberror;
-     error:=true;
-     exit;
-   end;
-  readentry:=entry.nr;
-end;
-
-
-function tppufile.endofentry:boolean;
-begin
-  endofentry:=(entryidx>=entry.size);
-end;
-
-
-procedure tppufile.getdatabuf(var b;len:longint;var result:longint);
-begin
-  if entryidx+len>entry.size then
-   result:=entry.size-entryidx
-  else
-   result:=len;
-  readdata(b,result);
-  inc(entryidx,result);
-end;
-
-
-procedure tppufile.getdata(var b;len:longint);
-begin
-  if entryidx+len>entry.size then
-   begin
-     error:=true;
-     exit;
-   end;
-  readdata(b,len);
-  inc(entryidx,len);
-end;
-
-
-function tppufile.getbyte:byte;
-var
-  b : byte;
-begin
-  if entryidx+1>entry.size then
-   begin
-     error:=true;
-     getbyte:=0;
-     exit;
-   end;
-  readdata(b,1);
-  getbyte:=b;
-  inc(entryidx);
-end;
-
-
-function tppufile.getword:word;
-type
-  pword = ^word;
-var
-  w : word;
-begin
-  if entryidx+2>entry.size then
-   begin
-     error:=true;
-     getword:=0;
-     exit;
-   end;
-  readdata(w,2);
-  if change_endian then
-   getword:=swap(w)
-  else
-   getword:=w;
-  inc(entryidx,2);
-end;
-
-
-function tppufile.getlongint:longint;
-type
-  plongint = ^longint;
-var
-  l : longint;
-begin
-  if entryidx+4>entry.size then
-   begin
-     error:=true;
-     getlongint:=0;
-     exit;
-   end;
-  readdata(l,4);
-  if change_endian then
-  { someone added swap(l : longint) in system unit
-   this broke the following code !! }
-   getlongint:=swap(word(l shr 16)) or (longint(swap(word(l and $ffff))) shl 16)
-  else
-   getlongint:=l;
-  inc(entryidx,4);
-end;
-
-
-function tppufile.getreal:ppureal;
-type
-  pppureal = ^ppureal;
-var
-  d : ppureal;
-begin
-  if entryidx+sizeof(ppureal)>entry.size then
-   begin
-     error:=true;
-     getreal:=0;
-     exit;
-   end;
-  readdata(d,sizeof(ppureal));
-  getreal:=d;
-  inc(entryidx,sizeof(ppureal));
-end;
-
-
-function tppufile.getstring:string;
-var
-  s : string;
-begin
-  s[0]:=chr(getbyte);
-  if entryidx+length(s)>entry.size then
-   begin
-     error:=true;
-     exit;
-   end;
-  ReadData(s[1],length(s));
-  getstring:=s;
-  inc(entryidx,length(s));
-end;
-
-
-procedure tppufile.getsmallset(var b);
-begin
-  getdata(b,4);
-end;
-
-
-procedure tppufile.getnormalset(var b);
-begin
-  getdata(b,32);
-end;
-
-
-function tppufile.skipuntilentry(untilb:byte):boolean;
-var
-  b : byte;
-begin
-  repeat
-    b:=readentry;
-  until (b in [ibend,iberror]) or ((b=untilb) and (entry.id=mainentryid));
-  skipuntilentry:=(b=untilb);
-end;
-
-
-{*****************************************************************************
-                                TPPUFile Writing
-*****************************************************************************}
-
-function tppufile.create:boolean;
-begin
-  create:=false;
-{$ifdef INTFPPU}
-  if crc_only then
-   begin
-     fname:=fname+'.intf';
-     crc_only:=false;
-   end;
-{$endif}
-  if not crc_only then
-    begin
-      assign(f,fname);
-      {$I-}
-       rewrite(f,1);
-      {$I+}
-      if ioresult<>0 then
-       exit;
-      Mode:=2;
-    {write header for sure}
-      blockwrite(f,header,sizeof(tppuheader));
-    end;
-  bufsize:=ppubufsize;
-  bufstart:=sizeof(tppuheader);
-  bufidx:=0;
-{reset}
-  crc:=longint($ffffffff);
-  interface_crc:=longint($ffffffff);
-  do_interface_crc:=true;
-  Error:=false;
-  do_crc:=true;
-  size:=0;
-  entrytyp:=mainentryid;
-{start}
-  NewEntry;
-  create:=true;
-end;
-
-
-procedure tppufile.writeheader;
-var
-  opos : longint;
-begin
-{ flush buffer }
-  writebuf;
-{ update size (w/o header!) in the header }
-  header.size:=bufstart-sizeof(tppuheader);
-{ write header and restore filepos after it }
-  opos:=filepos(f);
-  seek(f,0);
-  blockwrite(f,header,sizeof(tppuheader));
-  seek(f,opos);
-end;
-
-
-procedure tppufile.writebuf;
-begin
-  if not crc_only then
-    blockwrite(f,buf^,bufidx);
-  inc(bufstart,bufidx);
-  bufidx:=0;
-end;
-
-
-procedure tppufile.writedata(var b;len:longint);
-var
-  p   : pchar;
-  left,
-  idx : longint;
-begin
-  if crc_only then
-    exit;
-  p:=pchar(@b);
-  idx:=0;
-  while len>0 do
-   begin
-     left:=bufsize-bufidx;
-     if len>left then
-      begin
-        move(p[idx],buf[bufidx],left);
-        dec(len,left);
-        inc(idx,left);
-        inc(bufidx,left);
-        writebuf;
-      end
-     else
-      begin
-        move(p[idx],buf[bufidx],len);
-        inc(bufidx,len);
-        exit;
-      end;
-   end;
-end;
-
-
-procedure tppufile.NewEntry;
-begin
-  with entry do
-   begin
-     id:=entrytyp;
-     nr:=ibend;
-     size:=0;
-   end;
-{Reset Entry State}
-  entryidx:=0;
-  entrybufstart:=bufstart;
-  entrystart:=bufstart+bufidx;
-{Alloc in buffer}
-  writedata(entry,sizeof(tppuentry));
-end;
-
-
-procedure tppufile.writeentry(ibnr:byte);
-var
-  opos : longint;
-begin
-{create entry}
-  entry.id:=entrytyp;
-  entry.nr:=ibnr;
-  entry.size:=entryidx;
-{it's already been sent to disk ?}
-  if entrybufstart<>bufstart then
-   begin
-    if not crc_only then
-      begin
-      {flush to be sure}
-        WriteBuf;
-      {write entry}
-        opos:=filepos(f);
-        seek(f,entrystart);
-        blockwrite(f,entry,sizeof(tppuentry));
-        seek(f,opos);
-      end;
-     entrybufstart:=bufstart;
-   end
-  else
-   move(entry,buf[entrystart-bufstart],sizeof(entry));
-{Add New Entry, which is ibend by default}
-  entrystart:=bufstart+bufidx; {next entry position}
-  NewEntry;
-end;
-
-
-procedure tppufile.putdata(var b;len:longint);
-begin
-  if do_crc then
-   begin
-     crc:=UpdateCrc32(crc,b,len);
-{$ifdef Test_Double_checksum}
-     if crc_only then
-       begin
-         crc_test2^[crc_index2]:=crc;
-{$ifdef Test_Double_checksum_write}
-         Writeln(CRCFile,crc);
-{$endif Test_Double_checksum_write}
-         if crc_index2<crc_array_size then
-          inc(crc_index2);
-       end
-     else
-       begin
-         if (crcindex2<crc_array_size) and (crcindex2<crc_index2) and
-            (crc_test2^[crcindex2]<>crc) then
-           Do_comment(V_Warning,'impl CRC changed');
-{$ifdef Test_Double_checksum_write}
-         Writeln(CRCFile,crc);
-{$endif Test_Double_checksum_write}
-         inc(crcindex2);
-       end;
-{$endif def Test_Double_checksum}
-     if do_interface_crc then
-       begin
-         interface_crc:=UpdateCrc32(interface_crc,b,len);
-{$ifdef Test_Double_checksum}
-        if crc_only then
-          begin
-            crc_test^[crc_index]:=interface_crc;
-{$ifdef Test_Double_checksum_write}
-            Writeln(CRCFile,interface_crc);
-{$endif Test_Double_checksum_write}
-            if crc_index<crc_array_size then
-             inc(crc_index);
-          end
-        else
-          begin
-            if (crcindex<crc_array_size) and (crcindex<crc_index) and
-               (crc_test^[crcindex]<>interface_crc) then
-              Do_comment(V_Warning,'CRC changed');
-{$ifdef Test_Double_checksum_write}
-            Writeln(CRCFile,interface_crc);
-{$endif Test_Double_checksum_write}
-            inc(crcindex);
-          end;
-{$endif def Test_Double_checksum}
-       end;
-    end;
-  if not crc_only then
-    writedata(b,len);
-  inc(entryidx,len);
-end;
-
-
-procedure tppufile.putbyte(b:byte);
-begin
-  putdata(b,1);
-{  inc(entryidx);}
-end;
-
-
-procedure tppufile.putword(w:word);
-begin
-  if change_endian then
-   w:=swap(w);
-  putdata(w,2);
-end;
-
-
-procedure tppufile.putlongint(l:longint);
-begin
-  if change_endian then
-  { someone added swap(l : longint) in system unit
-   this broke the following code !! }
-   l:=swap(word(l shr 16)) or (longint(swap(word(l and $ffff))) shl 16);
-  putdata(l,4);
-end;
-
-
-procedure tppufile.putreal(d:ppureal);
-begin
-  putdata(d,sizeof(ppureal));
-end;
-
-
-procedure tppufile.putstring(s:string);
-begin
-  putdata(s,length(s)+1);
-end;
-
-
-procedure tppufile.putsmallset(var b);
-begin
-  putdata(b,4);
-end;
-
-
-procedure tppufile.putnormalset(var b);
-begin
-  putdata(b,32);
-end;
-
-
-    procedure tppufile.tempclose;
-      begin
-        if not closed then
-         begin
-            closepos:=filepos(f);
-           {$I-}
-            system.close(f);
-           {$I+}
-           if ioresult<>0 then;
-           closed:=true;
-           tempclosed:=true;
-         end;
-      end;
-
-
-    function tppufile.tempopen:boolean;
-      var
-        ofm : byte;
-      begin
-        tempopen:=false;
-        if not closed or not tempclosed then
-         exit;
-        ofm:=filemode;
-        filemode:=0;
-        {$I-}
-         reset(f,1);
-        {$I+}
-        filemode:=ofm;
-        if ioresult<>0 then
-         exit;
-        closed:=false;
-        tempclosed:=false;
-
-      { restore state }
-        seek(f,closepos);
-        tempopen:=true;
-      end;
-
-end.
-{
-  $Log$
-  Revision 1.3  2001-04-10 21:21:42  peter
-    * variantdef support
-    * propertysym fixed
-
-  Revision 1.7  2001/03/22 00:10:58  florian
-    + basic variant type support in the compiler
-
-  Revision 1.6  2000/12/07 17:19:43  jonas
-    * new constant handling: from now on, hex constants >$7fffffff are
-      parsed as unsigned constants (otherwise, $80000000 got sign extended
-      and became $ffffffff80000000), all constants in the longint range
-      become longints, all constants >$7fffffff and <=cardinal($ffffffff)
-      are cardinals and the rest are int64's.
-    * added lots of longint typecast to prevent range check errors in the
-      compiler and rtl
-    * type casts of symbolic ordinal constants are now preserved
-    * fixed bug where the original resulttype wasn't restored correctly
-      after doing a 64bit rangecheck
-
-  Revision 1.5  2000/10/31 22:02:50  peter
-    * symtable splitted, no real code changes
-
-  Revision 1.4  2000/09/24 15:06:24  peter
-    * use defines.inc
-
-  Revision 1.3  2000/08/13 13:04:38  peter
-    * new ppu version
-
-  Revision 1.2  2000/07/13 11:32:45  michael
-  + removed logs
-
-}

+ 0 - 1577
utils/ppudump.pp

@@ -1,1577 +0,0 @@
-{
-    $Id$
-    Copyright (c) 1998-2000 by the FPC Development Team
-
-    Dumps the contents of a FPC unit file (PPU File)
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************}
-{$ifdef TP}
-  {$N+,E+}
-{$endif}
-program pppdump;
-uses
-{$ifdef go32v2}
-  dpmiexcp,
-{$endif go32v2}
-  ppu;
-
-const
-  Version   = 'Version 1.10';
-  Title     = 'PPU-Analyser';
-  Copyright = 'Copyright (c) 1998-2000 by the Free Pascal Development Team';
-
-{ verbosity }
-  v_none           = $0;
-  v_header         = $1;
-  v_defs           = $2;
-  v_syms           = $4;
-  v_interface      = $8;
-  v_implementation = $10;
-  v_browser        = $20;
-  v_all            = $ff;
-
-var
-  ppufile     : pppufile;
-  space       : string;
-  read_member : boolean;
-  verbose     : longint;
-
-{****************************************************************************
-                          Helper Routines
-****************************************************************************}
-
-const has_errors : boolean = false;
-Procedure Error(const S : string);
-Begin
-   Writeln(S);
-   has_errors:=true;
-End;
-
-Function Target2Str(w:longint):string;
-type
-  ttarget = (target_none
-     ,target_i386_GO32V1,target_i386_GO32V2,target_i386_linux,
-      target_i386_OS2,target_i386_Win32
-     ,target_m68k_Amiga,target_m68k_Atari,target_m68k_Mac,
-      target_m68k_linux,target_m68k_PalmOS
-  );
-const
-  Targets : array[ttarget] of string[10]=('none',
-     'GO32V1','GO32V2','Linux-i386','OS/2','Win32',
-     'Amiga','Mac68k','Atari','Linux-m68k','PalmOs');
-begin
-  if w<=ord(high(ttarget)) then
-    Target2Str:=Targets[ttarget(w)]
-  else
-    Target2Str:='<Unknown>';
-end;
-
-
-Function Cpu2Str(w:longint):string;
-type
-  ttargetcpu=(no_cpu
-       ,i386,m68k,alpha
-  );
-const
-  CpuTxt : array[ttargetcpu] of string[5]=
-    ('none','i386','m68k','alpha');
-begin
-  if w<=ord(high(ttargetcpu)) then
-    Cpu2Str:=CpuTxt[ttargetcpu(w)]
-  else
-    Cpu2Str:='<Unknown>';
-end;
-
-
-function PPUFlags2Str(flags:longint):string;
-type
-  tflagopt=record
-    mask : longint;
-    str  : string[30];
-  end;
-const
-  flagopts=11;
-  flagopt : array[1..flagopts] of tflagopt=(
-    (mask: $1    ;str:'init'),
-    (mask: $2    ;str:'final'),
-    (mask: $4    ;str:'big_endian'),
-    (mask: $8    ;str:'dbx'),
-    (mask: $10   ;str:'browser'),
-    (mask: $20   ;str:'in_library'),
-    (mask: $40   ;str:'smart_linked'),
-    (mask: $80   ;str:'static_linked'),
-    (mask: $100  ;str:'shared_linked'),
-    (mask: $200  ;str:'local_browser'),
-    (mask: $400  ;str:'no_link')
-  );
-var
-  i : longint;
-  first  : boolean;
-  s : string;
-begin
-  s:='';
-  if flags<>0 then
-   begin
-     first:=true;
-     for i:=1to flagopts do
-      if (flags and flagopt[i].mask)<>0 then
-       begin
-         if first then
-           first:=false
-         else
-           s:=s+', ';
-         s:=s+flagopt[i].str;
-       end;
-   end
-  else
-   s:='none';
-  PPUFlags2Str:=s;
-end;
-
-
-const
-  HexTbl : array[0..15] of char='0123456789ABCDEF';
-function HexB(b:byte):string;
-begin
-  HexB[0]:=#2;
-  HexB[1]:=HexTbl[b shr 4];
-  HexB[2]:=HexTbl[b and $f];
-end;
-
-
-{****************************************************************************
-                             Read Routines
-****************************************************************************}
-
-Procedure ReadLinkContainer(const prefix:string);
-{
-  Read a serie of strings and write to the screen starting every line
-  with prefix
-}
-  function maskstr(m:longint):string;
-  const
-    { link options }
-    link_none    = $0;
-    link_allways = $1;
-    link_static  = $2;
-    link_smart   = $4;
-    link_shared  = $8;
-  var
-    s : string;
-  begin
-    s:='';
-    if (m and link_allways)<>0 then
-     s:=s+'always ';
-    if (m and link_static)<>0 then
-     s:=s+'static ';
-    if (m and link_smart)<>0 then
-     s:=s+'smart ';
-    if (m and link_shared)<>0 then
-     s:=s+'shared ';
-    maskstr:=s;
-  end;
-
-var
-  s : string;
-  m : longint;
-begin
-  while not ppufile^.endofentry do
-   begin
-     s:=ppufile^.getstring;
-     m:=ppufile^.getlongint;
-     WriteLn(prefix,s,' (',maskstr(m),')');
-   end;
-end;
-
-
-Procedure ReadContainer(const prefix:string);
-{
-  Read a serie of strings and write to the screen starting every line
-  with prefix
-}
-begin
-  while not ppufile^.endofentry do
-   WriteLn(prefix,ppufile^.getstring);
-end;
-
-
-Procedure ReadRef;
-begin
-  if (verbose and v_browser)=0 then
-   exit;
-  while (not ppufile^.endofentry) and (not ppufile^.error) do
-   Writeln(space,'        - Refered : ',ppufile^.getword,', (',ppufile^.getlongint,',',ppufile^.getword,')');
-end;
-
-
-Procedure ReadPosInfo;
-begin
-  Writeln(ppufile^.getword,' (',ppufile^.getlongint,',',ppufile^.getword,')');
-end;
-
-
-function readderef(const s:string;skipnil:boolean):boolean;
-type
-  tdereftype = (derefnil,derefaktrecordindex,derefaktstaticindex,
-                derefunit,derefrecord,derefindex,
-                dereflocal,derefpara,derefaktlocalindex);
-var
-  b : tdereftype;
-begin
-  readderef:=true;
-  repeat
-    b:=tdereftype(ppufile^.getbyte);
-    case b of
-      derefnil :
-        begin
-          if not skipnil then
-           writeln('nil');
-          readderef:=false;
-          break;
-        end;
-      derefaktrecordindex :
-        begin
-          writeln('AktRecord ',s,' ',ppufile^.getword);
-          break;
-        end;
-      derefaktstaticindex :
-        begin
-          writeln('AktStatic ',s,' ',ppufile^.getword);
-          break;
-        end;
-      derefaktlocalindex :
-        begin
-          writeln('AktLocal ',s,' ',ppufile^.getword);
-          break;
-        end;
-      derefunit :
-        begin
-          writeln('Unit ',ppufile^.getword);
-          break;
-        end;
-      derefrecord :
-        begin
-          write('RecordDef ',ppufile^.getword,', ');
-        end;
-      derefpara :
-        begin
-          write('Parameter of procdef ',ppufile^.getword,', ');
-        end;
-      dereflocal :
-        begin
-          write('Local of procdef ',ppufile^.getword,', ');
-        end;
-      derefindex :
-        begin
-          write(s,' ',ppufile^.getword,', ');
-        end;
-      else
-        begin
-          writeln('!! unsupported dereftyp: ',ord(b));
-          break;
-        end;
-    end;
-  until false;
-end;
-
-
-function readdefref:boolean;
-begin
-  readdefref:=readderef('Definition',false);
-end;
-
-
-function readsymref:boolean;
-begin
-  readsymref:=readderef('Symbol',false);
-end;
-
-
-procedure readtype;
-var
-  b1,b2 : boolean;
-begin
-  b1:=readderef('Definition',true);
-  b2:=readderef('Symbol',true);
-  if not(b1 or b2) then
-   Writeln('nil')
-  else
-   if (b1 and b2) then
-    Writeln('!! Type has both definition and symbol stored');
-end;
-
-
-procedure readsymlist(const s:string);
-begin
-  readdefref;
-  repeat
-    write(s);
-    if not readsymref then
-     break;
-  until false;
-end;
-
-
-procedure read_abstract_proc_def;
-type
-  tproccalloption=(pocall_none,
-    pocall_clearstack,    { Use IBM flat calling convention. (Used by GCC.) }
-    pocall_leftright,     { Push parameters from left to right }
-    pocall_cdecl,         { procedure uses C styled calling }
-    pocall_register,      { procedure uses register (fastcall) calling }
-    pocall_stdcall,       { procedure uses stdcall call }
-    pocall_safecall,      { safe call calling conventions }
-    pocall_palmossyscall, { procedure is a PalmOS system call }
-    pocall_system,
-    pocall_inline,        { Procedure is an assembler macro }
-    pocall_internproc,    { Procedure has compiler magic}
-    pocall_internconst    { procedure has constant evaluator intern }
-  );
-  tproccalloptions=set of tproccalloption;
-  tproctypeoption=(potype_none,
-    potype_proginit,     { Program initialization }
-    potype_unitinit,     { unit initialization }
-    potype_unitfinalize, { unit finalization }
-    potype_constructor,  { Procedure is a constructor }
-    potype_destructor,   { Procedure is a destructor }
-    potype_operator      { Procedure defines an operator }
-  );
-  tproctypeoptions=set of tproctypeoption;
-  tprocoption=(po_none,
-    po_classmethod,       { class method }
-    po_virtualmethod,     { Procedure is a virtual method }
-    po_abstractmethod,    { Procedure is an abstract method }
-    po_staticmethod,      { static method }
-    po_overridingmethod,  { method with override directive }
-    po_methodpointer,     { method pointer, only in procvardef, also used for 'with object do' }
-    po_containsself,      { self is passed explicit to the compiler }
-    po_interrupt,         { Procedure is an interrupt handler }
-    po_iocheck,           { IO checking should be done after a call to the procedure }
-    po_assembler,         { Procedure is written in assembler }
-    po_msgstr,            { method for string message handling }
-    po_msgint,            { method for int message handling }
-    po_exports,           { Procedure has export directive (needed for OS/2) }
-    po_external,          { Procedure is external (in other object or lib)}
-    po_savestdregs,       { save std regs cdecl and stdcall need that ! }
-    po_saveregisters      { save all registers }
-  );
-  tprocoptions=set of tprocoption;
-type
-  tproccallopt=record
-    mask : tproccalloption;
-    str  : string[30];
-  end;
-  tproctypeopt=record
-    mask : tproctypeoption;
-    str  : string[30];
-  end;
-  tprocopt=record
-    mask : tprocoption;
-    str  : string[30];
-  end;
-const
-  proccallopts=12;
-  proccallopt : array[1..proccallopts] of tproccallopt=(
-     (mask:pocall_none;         str:''),
-     (mask:pocall_clearstack;   str:'ClearStack'),
-     (mask:pocall_leftright;    str:'LeftRight'),
-     (mask:pocall_cdecl;        str:'Cdecl'),
-     (mask:pocall_register;     str:'Register'),
-     (mask:pocall_stdcall;      str:'StdCall'),
-     (mask:pocall_safecall;     str:'SafeCall'),
-     (mask:pocall_palmossyscall;str:'PalmOSSysCall'),
-     (mask:pocall_system;       str:'System'),
-     (mask:pocall_inline;       str:'Inline'),
-     (mask:pocall_internproc;   str:'InternProc'),
-     (mask:pocall_internconst;  str:'InternConst')
-  );
-  proctypeopts=6;
-  proctypeopt : array[1..proctypeopts] of tproctypeopt=(
-     (mask:potype_proginit;    str:'ProgInit'),
-     (mask:potype_unitinit;    str:'UnitInit'),
-     (mask:potype_unitfinalize;str:'UnitFinalize'),
-     (mask:potype_constructor; str:'Constructor'),
-     (mask:potype_destructor;  str:'Destructor'),
-     (mask:potype_operator;    str:'Operator')
-  );
-  procopts=16;
-  procopt : array[1..procopts] of tprocopt=(
-     (mask:po_classmethod;     str:'ClassMethod'),
-     (mask:po_virtualmethod;   str:'VirtualMethod'),
-     (mask:po_abstractmethod;  str:'AbstractMethod'),
-     (mask:po_staticmethod;    str:'StaticMethod'),
-     (mask:po_overridingmethod;str:'OverridingMethod'),
-     (mask:po_methodpointer;   str:'MethodPointer'),
-     (mask:po_containsself;    str:'ContainsSelf'),
-     (mask:po_interrupt;       str:'Interrupt'),
-     (mask:po_iocheck;         str:'IOCheck'),
-     (mask:po_assembler;       str:'Assembler'),
-     (mask:po_msgstr;          str:'MsgStr'),
-     (mask:po_msgint;          str:'MsgInt'),
-     (mask:po_exports;         str:'Exports'),
-     (mask:po_external;        str:'External'),
-     (mask:po_savestdregs;     str:'SaveStdRegs'),
-     (mask:po_saveregisters;   str:'SaveRegisters')
-  );
-  tvarspez : array[0..2] of string[5]=('Value','Const','Var  ');
-var
-  proctypeoption  : tproctypeoption;
-  proccalloptions : tproccalloptions;
-  procoptions     : tprocoptions;
-  i,params : longint;
-  first    : boolean;
-begin
-  write(space,'      Return type : ');
-  readtype;
-  writeln(space,'         Fpu used : ',ppufile^.getbyte);
-  proctypeoption:=tproctypeoption(ppufile^.getlongint);
-  if proctypeoption<>potype_none then
-   begin
-     write(space,'       TypeOption : ');
-     first:=true;
-     for i:=1to proctypeopts do
-      if (proctypeopt[i].mask=proctypeoption) then
-       begin
-         if first then
-           first:=false
-         else
-           write(', ');
-         write(proctypeopt[i].str);
-       end;
-     writeln;
-   end;
-  ppufile^.getsmallset(proccalloptions);
-  if proccalloptions<>[] then
-   begin
-     write(space,'      CallOptions : ');
-     first:=true;
-     for i:=1to proccallopts do
-      if (proccallopt[i].mask in proccalloptions) then
-       begin
-         if first then
-           first:=false
-         else
-           write(', ');
-         write(proccallopt[i].str);
-       end;
-     writeln;
-   end;
-  ppufile^.getsmallset(procoptions);
-  if procoptions<>[] then
-   begin
-     write(space,'          Options : ');
-     first:=true;
-     for i:=1to procopts do
-      if (procopt[i].mask in procoptions) then
-       begin
-         if first then
-           first:=false
-         else
-           write(', ');
-         write(procopt[i].str);
-       end;
-     writeln;
-   end;
-  params:=ppufile^.getword;
-  writeln(space,' Nr of parameters : ',params);
-  if params>0 then
-   begin
-     repeat
-       write(space,'  - ',tvarspez[ppufile^.getbyte],' : ');
-       readtype;
-       write(space,'    Default : ');
-       readsymref;
-       dec(params);
-     until params=0;
-   end;
-end;
-
-
-procedure readcommonsym(const s:string);
-type
-  tsymoption=(sp_none,
-    sp_public,
-    sp_private,
-    sp_published,
-    sp_protected,
-    sp_forwarddef,
-    sp_static,
-    sp_primary_typesym    { this is for typesym, to know who is the primary symbol of a def }
-  );
-  tsymoptions=set of tsymoption;
-  tsymopt=record
-    mask : tsymoption;
-    str  : string[30];
-  end;
-const
-  symopts=7;
-  symopt : array[1..symopts] of tsymopt=(
-     (mask:sp_public;         str:'Public'),
-     (mask:sp_private;        str:'Private'),
-     (mask:sp_published;      str:'Published'),
-     (mask:sp_protected;      str:'Protected'),
-     (mask:sp_forwarddef;     str:'ForwardDef'),
-     (mask:sp_static;         str:'Static'),
-     (mask:sp_primary_typesym;str:'PrimaryTypeSym')
-  );
-var
-  symoptions : tsymoptions;
-  i      : longint;
-  first  : boolean;
-begin
-  writeln(space,'** Symbol Nr. ',ppufile^.getword,' **');
-  writeln(space,s,ppufile^.getstring);
-  ppufile^.getsmallset(symoptions);
-  if symoptions<>[] then
-   begin
-     write(space,'    File Pos: ');
-     readposinfo;
-     write(space,'  SymOptions: ');
-     first:=true;
-     for i:=1to symopts do
-      if (symopt[i].mask in symoptions) then
-       begin
-         if first then
-           first:=false
-         else
-           write(', ');
-         write(symopt[i].str);
-       end;
-     writeln;
-   end;
-end;
-
-
-procedure readcommondef(const s:string);
-begin
-  writeln(space,'** Definition Nr. ',ppufile^.getword,' **');
-  writeln(space,s);
-  write  (space,'      Type symbol : ');
-  readsymref;
-end;
-
-
-{****************************************************************************
-                             Read Symbols Part
-****************************************************************************}
-
-procedure readsymbols;
-Const
-  vo_is_C_var = 2;
-Type
-  absolutetyp = (tovar,toasm,toaddr);
-  tconsttyp = (constnone,
-    constord,conststring,constreal,constbool,
-    constint,constchar,constset,constpointer,constnil,
-    constresourcestring
-  );
-var
-  b      : byte;
-  pc     : pchar;
-  totalsyms,
-  symcnt,
-  i,j,len : longint;
-  l1,l2 : longint;
-begin
-  symcnt:=1;
-  with ppufile^ do
-   begin
-     if space<>'' then
-      Writeln(space,'-----------------------------');
-     if readentry=ibstartsyms then
-      begin
-        totalsyms:=getlongint;
-        Writeln(space,'Number of symbols : ',totalsyms);
-        Writeln(space,'Symtable datasize : ',getlongint);
-        Writeln(space,'Symtable alignment: ',getlongint);
-      end
-     else
-      begin
-        totalsyms:=-1;
-        Writeln('!! ibstartsym not found');
-      end;
-     repeat
-       b:=readentry;
-       if not (b in [iberror,ibendsyms]) then
-        inc(symcnt);
-       case b of
-
-         ibunitsym :
-           readcommonsym('Unit symbol ');
-
-         iblabelsym :
-           readcommonsym('Label symbol ');
-
-         ibtypesym :
-           begin
-             readcommonsym('Type symbol ');
-             write(space,' Result Type: ');
-             readtype;
-           end;
-
-         ibprocsym :
-           begin
-             readcommonsym('Procedure symbol ');
-             write(space,'  Definition: ');
-             readdefref;
-           end;
-
-         ibconstsym :
-           begin
-             readcommonsym('Constant symbol ');
-             b:=getbyte;
-             case tconsttyp(b) of
-               constord :
-                 begin
-                   write   (space,'OrdinalType: ');
-                   readtype;
-                   writeln (space,'      Value: ',getlongint)
-                 end;
-               constpointer :
-                 begin
-                   write (space,' Pointer Type: ');
-                   readtype;
-                   writeln (space,'      Value: ',getlongint)
-                 end;
-               conststring,
-               constresourcestring :
-                 begin
-                   len:=getlongint;
-                   getmem(pc,len+1);
-                   getdata(pc^,len);
-                   writeln(space,'      Length: ',len);
-                   writeln(space,'       Value: "',pc,'"');
-                   freemem(pc,len+1);
-                   if tconsttyp(b)=constresourcestring then
-                    writeln(space,'       Index: ',getlongint);
-                 end;
-               constreal :
-                 writeln(space,'       Value: ',getreal);
-               constbool :
-                 if getlongint<>0 then
-                   writeln (space,'      Value : True')
-                 else
-                   writeln (space,'      Value: False');
-               constint :
-                 begin
-                   l1:=getlongint;
-                   l2:=getlongint;
-                   writeln(space,'       Value: ',int64(l2 shl 32) or l1);
-                 end;
-               constchar :
-                 writeln(space,'       Value: "'+chr(getlongint)+'"');
-               constset :
-                 begin
-                   write (space,'     Set Type: ');
-                   readtype;
-                   for i:=1to 4 do
-                    begin
-                      write (space,'       Value: ');
-                      for j:=1to 8 do
-                       begin
-                         if j>1 then
-                          write(',');
-                         write(hexb(getbyte));
-                       end;
-                      writeln;
-                    end;
-                 end;
-               else
-                 Writeln ('!! Invalid unit format : Invalid const type encountered: ',b);
-             end;
-           end;
-
-         ibvarsym :
-           begin
-             readcommonsym('Variable symbol ');
-             writeln(space,'        Type: ',getbyte);
-             if read_member then
-               writeln(space,'     Address: ',getlongint);
-             write  (space,'    Var Type: ');
-             readtype;
-             i:=getlongint;
-             writeln(space,'     Options: ',i);
-             if (i and vo_is_C_var)<>0 then
-               writeln(space,' Mangledname: ',getstring);
-           end;
-
-         ibenumsym :
-           begin
-             readcommonsym('Enumeration symbol ');
-             write  (space,'  Definition: ');
-             readdefref;
-             writeln(space,'       Value: ',getlongint);
-           end;
-
-         ibsyssym :
-           begin
-             readcommonsym('Internal system symbol ');
-             writeln(space,' Internal Nr: ',getlongint);
-           end;
-
-         ibtypedconstsym :
-           begin
-             readcommonsym('Typed constant ');
-             write  (space,' Constant Type: ');
-             readtype;
-             writeln(space,'         Label: ',getstring);
-             writeln(space,'   ReallyConst: ',(getbyte<>0));
-           end;
-
-         ibabsolutesym :
-           begin
-             readcommonsym('Absolute variable symbol ');
-             writeln(space,'          Type: ',getbyte);
-             if read_member then
-               writeln(space,'       Address: ',getlongint);
-             write  (space,'      Var Type: ');
-             readtype;
-             writeln(space,'       Options: ',getlongint);
-             Write (space,'    Relocated to ');
-             b:=getbyte;
-             case absolutetyp(b) of
-               tovar :
-                 Writeln('Name : ',getstring);
-               toasm :
-                 Writeln('Assembler name : ',getstring);
-               toaddr :
-                 begin
-                   Write('Address : ',getlongint);
-                   WriteLn(' (Far: ',getbyte<>0,')');
-                 end;
-               else
-                 Writeln ('!! Invalid unit format : Invalid absolute type encountered: ',b);
-             end;
-           end;
-
-         ibpropertysym :
-           begin
-             readcommonsym('Property ');
-             i:=getlongint;
-             writeln(space,' PropOptions: ',i);
-             if (i and 32)>0 then
-              begin
-                write  (space,'OverrideProp: ');
-                readsymref;
-              end
-             else
-              begin
-                write  (space,'   Prop Type: ');
-                readtype;
-                writeln(space,'       Index: ',getlongint);
-                writeln(space,'     Default: ',getlongint);
-                write  (space,'  Index Type: ');
-                readtype;
-                write  (space,'  Readaccess: ');
-                readsymlist(space+'         Sym: ');
-                write  (space,' Writeaccess: ');
-                readsymlist(space+'         Sym: ');
-                write  (space,'Storedaccess: ');
-                readsymlist(space+'         Sym: ');
-              end;
-           end;
-
-         ibfuncretsym :
-           begin
-             readcommonsym('Func return value ');
-             write  (space,' Return Type: ');
-             readtype;
-             writeln(space,'     Address: ',getlongint);
-           end;
-
-         iberror :
-           begin
-             Writeln('!! Error in PPU');
-             exit;
-           end;
-
-         ibendsyms :
-           break;
-
-         else
-           WriteLn('!! Skipping unsupported PPU Entry in Symbols: ',b);
-       end;
-       if not EndOfEntry then
-        Writeln('!! Entry has more information stored');
-     until false;
-     if (totalsyms<>-1) and (symcnt-1<>totalsyms) then
-       Writeln('!! Only read ',symcnt-1,' of ',totalsyms,' symbols');
-   end;
-end;
-
-
-{****************************************************************************
-                         Read defintions Part
-****************************************************************************}
-
-procedure readdefinitions(start_read : boolean);
-type
-  tsettype  = (normset,smallset,varset);
-  tbasetype = (
-    uauto,uvoid,uchar,
-    u8bit,u16bit,u32bit,
-    s8bit,s16bit,s32bit,
-    bool8bit,bool16bit,bool32bit,
-    u64bit,s64bit,uwidechar
-  );
-  tobjectdeftype = (odt_none,
-    odt_class,
-    odt_object,
-    odt_interfacecom,
-    odt_interfacecorba,
-    odt_cppclass
-  );
-var
-  b : byte;
-  oldread_member : boolean;
-  totaldefs,l,j,
-  defcnt : longint;
-begin
-  defcnt:=0;
-  with ppufile^ do
-   begin
-     if space<>'' then
-      Writeln(space,'-----------------------------');
-     if not start_read then
-       if readentry=ibstartdefs then
-         begin
-           totaldefs:=getlongint;
-           Writeln(space,'Number of definitions: ',totaldefs);
-         end
-       else
-         begin
-           totaldefs:=-1;
-           Writeln('!! ibstartdef not found');
-         end;
-     repeat
-       b:=readentry;
-       if not (b in [iberror,ibenddefs]) then
-        inc(defcnt);
-       case b of
-
-         ibpointerdef :
-           begin
-             readcommondef('Pointer definition');
-             write  (space,'     Pointed Type : ');
-             readtype;
-             writeln(space,'           Is Far : ',(getbyte<>0));
-           end;
-
-         iborddef :
-           begin
-             readcommondef('Ordinal definition');
-             write  (space,'        Base type : ');
-             b:=getbyte;
-             case tbasetype(b) of
-               uauto     : writeln('uauto');
-               uvoid     : writeln('uvoid');
-               uchar     : writeln('uchar');
-               u8bit     : writeln('u8bit');
-               u16bit    : writeln('u16bit');
-               u32bit    : writeln('s32bit');
-               s8bit     : writeln('s8bit');
-               s16bit    : writeln('s16bit');
-               s32bit    : writeln('s32bit');
-               bool8bit  : writeln('bool8bit');
-               bool16bit : writeln('bool16bit');
-               bool32bit : writeln('bool32bit');
-               u64bit    : writeln('u64bit');
-               s64bit    : writeln('s64bit');
-               uwidechar : writeln('uwidechar');
-               else        writeln('!! Warning: Invalid base type ',b);
-             end;
-             writeln(space,'            Range : ',getlongint,' to ',getlongint);
-           end;
-
-         ibfloatdef :
-           begin
-             readcommondef('Float definition');
-             writeln(space,'       Float type : ',getbyte);
-           end;
-
-         ibarraydef :
-           begin
-             readcommondef('Array definition');
-             write  (space,'     Element type : ');
-             readtype;
-             write  (space,'       Range Type : ');
-             readtype;
-             writeln(space,'            Range : ',getlongint,' to ',getlongint);
-             writeln(space,'   Is Constructor : ',(getbyte<>0));
-           end;
-
-         ibprocdef :
-           begin
-             readcommondef('Procedure definition');
-             read_abstract_proc_def;
-             writeln(space,'    Used Register : ',getbyte);
-             writeln(space,'     Mangled name : ',getstring);
-             writeln(space,'           Number : ',getlongint);
-             write  (space,'             Next : ');
-             readdefref;
-             write  (space,'            Class : ');
-             readdefref;
-             write  (space,'         File Pos : ');
-             readposinfo;
-             space:='    '+space;
-             { parast }
-             readdefinitions(false);
-             readsymbols;
-             { localst }
-             {readdefinitions(false);
-             readsymbols;}
-             delete(space,1,4);
-           end;
-
-         ibprocvardef :
-           begin
-             readcommondef('Procedural type (ProcVar) definition');
-             read_abstract_proc_def;
-           end;
-
-         ibshortstringdef :
-           begin
-             readcommondef('ShortString definition');
-             writeln(space,'           Length : ',getbyte);
-           end;
-
-         ibwidestringdef :
-           begin
-             readcommondef('WideString definition');
-             writeln(space,'           Length : ',getlongint);
-           end;
-
-         ibansistringdef :
-           begin
-             readcommondef('AnsiString definition');
-             writeln(space,'           Length : ',getlongint);
-           end;
-
-         iblongstringdef :
-           begin
-             readcommondef('Longstring definition');
-             writeln(space,'           Length : ',getlongint);
-           end;
-
-         ibrecorddef :
-           begin
-             readcommondef('Record definition');
-             writeln(space,'             Size : ',getlongint);
-             {read the record definitions and symbols}
-             space:='    '+space;
-             oldread_member:=read_member;
-             read_member:=true;
-             readdefinitions(false);
-             readsymbols;
-             read_member:=oldread_member;
-             Delete(space,1,4);
-           end;
-
-         ibobjectdef :
-           begin
-             readcommondef('Object/Class definition');
-             b:=getbyte;
-             write  (space,'             Type : ');
-             case tobjectdeftype(b) of
-               odt_class          : writeln('class');
-               odt_object         : writeln('object');
-               odt_interfacecom   : writeln('interfacecom');
-               odt_interfacecorba : writeln('interfacecorba');
-               odt_cppclass       : writeln('cppclass');
-               else                 writeln('!! Warning: Invalid object type ',b);
-             end;
-             writeln(space,'             Size : ',getlongint);
-             writeln(space,'       Vmt offset : ',getlongint);
-             writeln(space,'    Name of Class : ',getstring);
-             write(space,  '   Ancestor Class : ');
-             readdefref;
-             writeln(space,'          Options : ',getlongint);
-             writeln(space,'         Has RTTI : ',(getbyte<>0));
-
-             if tobjectdeftype(b) in [odt_interfacecom,odt_interfacecorba] then
-               begin
-                  writeln(space,'       GUID Valid : ',(getbyte<>0));
-                  { IIDGUID }
-                  for j:=1to 16 do
-                   getbyte;
-                  writeln(space,'       IID String : ',getstring);
-                  writeln(space,'  Last VTable idx : ',getlongint);
-               end;
-
-             if tobjectdeftype(b) in [odt_class,odt_interfacecorba] then
-              begin
-                l:=getlongint;
-                writeln(space,'  Impl Intf Count : ',l);
-                for j:=1 to l do
-                 begin
-                   write  (space,'  - Definition : ');
-                   readdefref;
-                   writeln(space,'       IOffset : ',getlongint);
-                 end;
-              end;
-
-           {read the record definitions and symbols}
-             space:='    '+space;
-             oldread_member:=read_member;
-             read_member:=true;
-             readdefinitions(false);
-             readsymbols;
-             read_member:=oldread_member;
-             Delete(space,1,4);
-           end;
-
-         ibfiledef :
-           begin
-             ReadCommonDef('File definition');
-             write  (space,'             Type : ');
-             case getbyte of
-              0 : writeln('Text');
-              1 : begin
-                    writeln('Typed');
-                    write  (space,'      File of Type : ');
-                    Readtype;
-                  end;
-              2 : writeln('Untyped');
-             end;
-           end;
-
-         ibformaldef :
-           readcommondef('Generic Definition (void-typ)');
-
-         ibenumdef :
-           begin
-             readcommondef('Enumeration type definition');
-             write(space,'Base enumeration type : ');
-             readdefref;
-             writeln(space,' Smallest element : ',getlongint);
-             writeln(space,'  Largest element : ',getlongint);
-             writeln(space,'             Size : ',getlongint);
-           end;
-
-         ibclassrefdef :
-           begin
-             readcommondef('Class reference definition');
-             write  (space,'    Pointed Type : ');
-             readtype;
-           end;
-
-         ibsetdef :
-           begin
-             readcommondef('Set definition');
-             write  (space,'     Element type : ');
-             readtype;
-             b:=getbyte;
-             case tsettype(b) of
-               smallset : writeln(space,'  Set with 32 Elements');
-               normset  : writeln(space,'  Set with 256 Elements');
-               varset   : writeln(space,'  Set with ',getlongint,' Elements');
-               else       writeln('!! Warning: Invalid set type ',b);
-             end;
-           end;
-
-
-         ibvariantdef :
-           begin
-             readcommondef('Variant definition');
-           end;
-
-         iberror :
-           begin
-             Writeln('!! Error in PPU');
-             exit;
-           end;
-
-         ibenddefs :
-           break;
-
-         else
-           WriteLn('!! Skipping unsupported PPU Entry in definitions: ',b);
-       end;
-       if not EndOfEntry then
-        Writeln('!! Entry has more information stored');
-     until false;
-     if (totaldefs<>-1) and (defcnt<>totaldefs) then
-      Writeln('!! Only read ',defcnt,' of ',totaldefs,' definitions');
-   end;
-end;
-
-
-{****************************************************************************
-                           Read General Part
-****************************************************************************}
-
-procedure readinterface;
-var
-  b : byte;
-  sourcenumber,
-  unitnumber : word;
-  ucrc,uintfcrc : longint;
-begin
-  with ppufile^ do
-   begin
-     repeat
-       b:=readentry;
-       case b of
-
-         ibmodulename :
-           Writeln('Module Name: ',getstring);
-
-         ibsourcefiles :
-           begin
-             sourcenumber:=1;
-             while not EndOfEntry do
-              begin
-                Writeln('Source file ',sourcenumber,' : ',getstring);
-                inc(sourcenumber);
-              end;
-           end;
-
-         ibusedmacros :
-           begin
-             while not EndOfEntry do
-              begin
-                Write('Conditional ',getstring);
-                b:=getbyte;
-                if boolean(b)=true then
-                  write(' defined at startup')
-                else
-                  write(' not defined at startup');
-                b:=getbyte;
-                if boolean(b)=true then
-                  writeln(' was used')
-                else
-                  writeln;
-              end;
-           end;
-         ibloadunit :
-           begin
-             unitnumber:=1;
-             while not EndOfEntry do
-              begin
-                write('Uses unit: ',getstring,' (Number: ',unitnumber,')');
-                ucrc:=getlongint;
-                uintfcrc:=getlongint;
-                write(' (Crc: ',ucrc,', IntfcCrc: ',uintfcrc,')');
-                if getbyte<>0 then
-                 writeln(' (interface)')
-                else
-                 writeln(' (implementation)');
-                inc(unitnumber);
-              end;
-           end;
-
-         iblinkunitofiles :
-           ReadLinkContainer('Link unit object file: ');
-
-         iblinkunitstaticlibs :
-           ReadLinkContainer('Link unit static lib: ');
-
-         iblinkunitsharedlibs :
-           ReadLinkContainer('Link unit shared lib: ');
-
-         iblinkotherofiles :
-           ReadLinkContainer('Link other object file: ');
-
-         iblinkotherstaticlibs :
-           ReadLinkContainer('Link other static lib: ');
-
-         iblinkothersharedlibs :
-           ReadLinkContainer('Link other shared lib: ');
-
-         iberror :
-           begin
-             Writeln('Error in PPU');
-             exit;
-           end;
-
-         ibendinterface :
-           break;
-
-         else
-           WriteLn('!! Skipping unsupported PPU Entry in General Part: ',b);
-       end;
-     until false;
-   end;
-end;
-
-
-
-{****************************************************************************
-                        Read Implementation Part
-****************************************************************************}
-
-procedure readimplementation;
-var
-  b : byte;
-begin
-  with ppufile^ do
-   begin
-     repeat
-       b:=readentry;
-       case b of
-         iberror :
-           begin
-             Writeln('Error in PPU');
-             exit;
-           end;
-         ibendimplementation :
-           break;
-         else
-           WriteLn('!! Skipping unsupported PPU Entry in Implementation: ',b);
-       end;
-     until false;
-   end;
-end;
-
-
-{****************************************************************************
-                            Read Browser Part
-****************************************************************************}
-
-procedure readbrowser;
-var
-  b : byte;
-const indent : string = '';
-begin
-  Writeln(indent,'Start of symtable browser');
-  indent:=indent+'**';
-  with ppufile^ do
-   begin
-     repeat
-       b:=readentry;
-       case b of
-        ibbeginsymtablebrowser :
-                         { here we must read object and record symtables !! }
-                    begin
-                      indent:=indent+'  ';
-                      Writeln(indent,'Record/Object symtable');
-                      readbrowser;
-                      Indent:=Copy(Indent,1,Length(Indent)-2);
-                    end;
-            ibsymref : begin
-                         readsymref;
-                         readref;
-                       end;
-            ibdefref : begin
-                         readdefref;
-                         readref;
-                         if (ppufile^.header.flags and uf_local_browser)<>0 then
-                           begin
-                             { parast and localst }
-                             indent:=indent+'  ';
-                             Writeln(indent,'Parasymtable for function');
-                             readdefinitions(false);
-                             readsymbols;
-                             b:=ppufile^.readentry;
-                             if b=ibbeginsymtablebrowser then
-                               readbrowser;
-                             Writeln(indent,'Localsymtable for function');
-                             readdefinitions(false);
-                             readsymbols;
-                             b:=ppufile^.readentry;
-                             if b=ibbeginsymtablebrowser then
-                               readbrowser;
-                             Indent:=Copy(Indent,1,Length(Indent)-2);
-                           end;
-                       end;
-             iberror : begin
-                         Writeln('Error in PPU');
-                         exit;
-                       end;
-        ibendsymtablebrowser : break;
-       else
-        begin
-        WriteLn('!! Skipping unsupported PPU Entry in Browser: ',b);
-        Halt;
-        end;
-       end;
-     until false;
-   end;
-  Indent:=Copy(Indent,1,Length(Indent)-2);
-  Writeln(Indent,'End of symtable browser');
-end;
-
-
-
-
-procedure dofile (filename : string);
-var
-  b,unitindex : byte;
-begin
-{ reset }
-  space:='';
-{ fix filename }
-  if pos('.',filename)=0 then
-   filename:=filename+'.ppu';
-  ppufile:=new(pppufile,Init(filename));
-  if not ppufile^.open then
-   begin
-     writeln ('IO-Error when opening : ',filename,', Skipping');
-     exit;
-   end;
-{ PPU File is open, check for PPU Id }
-  if not ppufile^.CheckPPUID then
-   begin
-     writeln(Filename,' : Not a valid PPU file, Skipping');
-     exit;
-   end;
-{ Check PPU Version }
-  Writeln('Analyzing ',filename,' (v',ppufile^.GetPPUVersion,')');
-  if ppufile^.GetPPUVersion<16 then
-   begin
-     writeln(Filename,' : Old PPU Formats (<v16) are not supported, Skipping');
-     exit;
-   end;
-{ Write PPU Header Information }
-  if (verbose and v_header)<>0 then
-   begin
-     Writeln;
-     Writeln('Header');
-     Writeln('-------');
-     with ppufile^.header do
-      begin
-        Writeln('Compiler version        : ',hi(ppufile^.header.compiler and $ff),'.',lo(ppufile^.header.compiler));
-        WriteLn('Target processor        : ',Cpu2Str(cpu));
-        WriteLn('Target operating system : ',Target2Str(target));
-        Writeln('Unit flags              : ',PPUFlags2Str(flags));
-        Writeln('FileSize (w/o header)   : ',size);
-        Writeln('Checksum                : ',checksum);
-        Writeln('Interface Checksum      : ',interface_checksum);
-      end;
-   end;
-{read the general stuff}
-  if (verbose and v_interface)<>0 then
-   begin
-     Writeln;
-     Writeln('Interface section');
-     Writeln('------------------');
-     readinterface;
-   end
-  else
-   ppufile^.skipuntilentry(ibendinterface);
-{read the definitions}
-  if (verbose and v_defs)<>0 then
-   begin
-     Writeln;
-     Writeln('Interface definitions');
-     Writeln('----------------------');
-     readdefinitions(false);
-   end
-  else
-   ppufile^.skipuntilentry(ibenddefs);
-{read the symbols}
-  if (verbose and v_syms)<>0 then
-   begin
-     Writeln;
-     Writeln('Interface Symbols');
-     Writeln('------------------');
-     readsymbols;
-   end
-  else
-   ppufile^.skipuntilentry(ibendsyms);
-{read the implementation stuff}
-{ Not used at the moment (PFV)
-  if (verbose and v_implementation)<>0 then
-   begin
-     Writeln;
-     Writeln('Implementation section');
-     Writeln('-----------------------');
-     readimplementation;
-   end
-  else}
-   ppufile^.skipuntilentry(ibendimplementation);
-{read the static browser units stuff}
-  if (ppufile^.header.flags and uf_local_browser)<>0 then
-   begin
-     if (verbose and v_defs)<>0 then
-      begin
-        Writeln;
-        Writeln('Static definitions');
-        Writeln('----------------------');
-        readdefinitions(false);
-      end
-     else
-      ppufile^.skipuntilentry(ibenddefs);
-   {read the symbols}
-     if (verbose and v_syms)<>0 then
-      begin
-        Writeln;
-        Writeln('Static Symbols');
-        Writeln('------------------');
-        readsymbols;
-      end;
-   end;
-{read the browser units stuff}
-  if (ppufile^.header.flags and uf_has_browser)<>0 then
-   begin
-     if (verbose and v_browser)<>0 then
-      begin
-        Writeln;
-        Writeln('Browser section');
-        Writeln('---------------');
-        UnitIndex:=0;
-        repeat
-          b:=ppufile^.readentry;
-          if b = ibendbrowser then break;
-          if b=ibbeginsymtablebrowser then
-            begin
-               Writeln('Unit ',UnitIndex);
-               readbrowser;
-               Inc(UnitIndex);
-            end
-          else
-            Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
-        until false;
-      end;
-   end;
-{read the static browser units stuff}
-  if (ppufile^.header.flags and uf_local_browser)<>0 then
-   begin
-     if (verbose and v_browser)<>0 then
-      begin
-        Writeln;
-        Writeln('Static browser section');
-        Writeln('---------------');
-        b:=ppufile^.readentry;
-        if b=ibbeginsymtablebrowser then
-          begin
-             Writeln('Unit ',UnitIndex);
-             readbrowser;
-             Inc(UnitIndex);
-          end
-        else
-          Writeln('Wrong end browser entry ',b,' should be ',ibendbrowser);
-      end;
-   end;
-{shutdown ppufile}
-  ppufile^.close;
-  dispose(ppufile,done);
-  Writeln;
-end;
-
-
-
-procedure help;
-begin
-  writeln('usage: ppudump [options] <filename1> <filename2>...');
-  writeln;
-  writeln('[options] can be:');
-  writeln('    -V<verbose>  Set verbosity to <verbose>');
-  writeln('                   H - Show header info');
-  writeln('                   I - Show interface');
-  writeln('                   M - Show implementation');
-  writeln('                   S - Show interface symbols');
-  writeln('                   D - Show interface definitions');
-  writeln('                   B - Show browser info');
-  writeln('                   A - Show all');
-  writeln('    -?           This helpscreen');
-  halt;
-end;
-
-var
-  startpara,
-  nrfile,i  : longint;
-  para      : string;
-begin
-  writeln(Title+' '+Version);
-  writeln(Copyright);
-  writeln;
-  if paramcount<1 then
-   begin
-     writeln('usage: dumpppu [options] <filename1> <filename2>...');
-     halt(1);
-   end;
-{ turn verbose on by default }
-  verbose:=v_all;
-{ read options }
-  startpara:=1;
-  while copy(paramstr(startpara),1,1)='-' do
-   begin
-     para:=paramstr(startpara);
-     case upcase(para[2]) of
-      'V' : begin
-              verbose:=0;
-              for i:=3to length(para) do
-               case upcase(para[i]) of
-                'H' : verbose:=verbose or v_header;
-                'I' : verbose:=verbose or v_interface;
-                'M' : verbose:=verbose or v_implementation;
-                'D' : verbose:=verbose or v_defs;
-                'S' : verbose:=verbose or v_syms;
-                'B' : verbose:=verbose or v_browser;
-                'A' : verbose:=verbose or v_all;
-               end;
-            end;
-      '?' : help;
-     end;
-     inc(startpara);
-   end;
-{ process files }
-  for nrfile:=startpara to paramcount do
-   dofile (paramstr(nrfile));
-  if has_errors then
-    Halt(1);
-end.
-{
-  $Log$
-  Revision 1.5  2001-04-10 21:21:41  peter
-    * variantdef support
-    * propertysym fixed
-
-  Revision 1.4  2001/04/04 22:42:59  peter
-    * updated for new objectdef with interfaces
-
-  Revision 1.3  2000/09/09 19:46:40  peter
-    * show dataalignment
-
-  Revision 1.2  2000/08/13 12:58:06  peter
-    * updated for ppu additions
-
-  Revision 1.1  2000/07/13 10:16:22  michael
-  + Initial import
-
-  Revision 1.15  2000/07/04 19:05:54  peter
-    * be optimistic: version 1.00 for some utils
-
-  Revision 1.14  2000/02/09 16:44:14  peter
-    * log truncated
-
-  Revision 1.13  2000/01/23 16:34:36  peter
-    * updated for new aktlocalindex
-
-  Revision 1.12  2000/01/07 16:46:03  daniel
-    * copyright 2000
-
-  Revision 1.11  1999/11/30 10:35:37  peter
-    * support new readtype
-
-  Revision 1.10  1999/11/08 14:06:45  florian
-    + indexref of propertysym is handle too now
-
-  Revision 1.9  1999/08/31 16:07:37  pierre
-   + support for writeusedmacros
-
-  Revision 1.8  1999/08/15 10:47:14  peter
-    * updates for new options
-
-  Revision 1.7  1999/08/13 21:25:35  peter
-    * updated flags
-
-  Revision 1.6  1999/07/27 23:45:29  peter
-    * updated for typesym writing
-
-}

+ 0 - 277
utils/ppufiles.pp

@@ -1,277 +0,0 @@
-{
-    $Id$
-    Copyright (c) 1999-2000 by Peter Vreman
-
-    List files needed by PPU
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************}
-Program ppufiles;
-
-uses
-  dos,
-  ppu;
-
-const
-  Version   = 'Version 1.00';
-  Title     = 'PPU-Files';
-  Copyright = 'Copyright (c) 1999-2000 by the Free Pascal Development Team';
-
-  PPUExt = 'ppu';
-
-type
-  poutfile = ^toutfile;
-  toutfile = record
-    name : string;
-    next : poutfile;
-  end;
-
-var
-  skipdup,
-  showstatic,
-  showshared,
-  showobjects : boolean;
-
-  OutFiles    : poutfile;
-
-
-{*****************************************************************************
-                                 Helpers
-*****************************************************************************}
-
-Procedure Error(const s:string;stop:boolean);
-{
-  Write an error message to stderr
-}
-begin
-{$ifdef FPC}
-  writeln(stderr,s);
-{$else}
-  writeln(s);
-{$endif}
-  if stop then
-   halt(1);
-end;
-
-
-Function AddExtension(Const HStr,ext:String):String;
-{
-  Return a filename which will have extension ext added if no
-  extension is found
-}
-var
-  j : longint;
-begin
-  j:=length(Hstr);
-  while (j>0) and (Hstr[j]<>'.') do
-   dec(j);
-  if j=0 then
-   AddExtension:=Hstr+'.'+Ext
-  else
-   AddExtension:=HStr;
-end;
-
-
-Function SplitPath(Const HStr:String):String;
-var
-  i : longint;
-begin
-  i:=Length(Hstr);
-  while (i>0) and not(Hstr[i] in ['\','/']) do
-   dec(i);
-  SplitPath:=Copy(Hstr,1,i);
-end;
-
-
-Procedure AddFile(const s:string);
-var
-  p : poutfile;
-begin
-  p:=nil;
-  if skipdup then
-   begin
-     p:=outfiles;
-     while assigned(p) do
-      begin
-        if s=p^.name then
-         break;
-        p:=p^.next;
-      end;
-   end;
-  if not assigned(p) then
-   begin
-     new(p);
-     p^.name:=s;
-     p^.next:=outfiles;
-     outfiles:=p;
-   end;
-end;
-
-
-Function DoPPU(const PPUFn:String):Boolean;
-{
-  Convert one file (in Filename) to library format.
-  Return true if successful, false otherwise.
-}
-Var
-  inppu  : pppufile;
-  b      : byte;
-
-  procedure showfiles;
-  begin
-    while not inppu^.endofentry do
-     begin
-       AddFile(inppu^.getstring);
-       inppu^.getlongint;
-     end;
-  end;
-
-begin
-  DoPPU:=false;
-  inppu:=new(pppufile,init(PPUFn));
-  if not inppu^.open then
-   begin
-     dispose(inppu,done);
-     Error('Error: Could not open : '+PPUFn,false);
-     Exit;
-   end;
-{ Check the ppufile }
-  if not inppu^.CheckPPUId then
-   begin
-     dispose(inppu,done);
-     Error('Error: Not a PPU File : '+PPUFn,false);
-     Exit;
-   end;
-  if inppu^.GetPPUVersion<CurrentPPUVersion then
-   begin
-     dispose(inppu,done);
-     Error('Error: Wrong PPU Version : '+PPUFn,false);
-     Exit;
-   end;
-{ read until the object files are found }
-  repeat
-    b:=inppu^.readentry;
-    case b of
-      ibendinterface,
-      ibend :
-        break;
-      iblinkunitstaticlibs :
-        if showstatic then
-         showfiles;
-      iblinkunitsharedlibs :
-        if showshared then
-         showfiles;
-      iblinkunitofiles :
-        if showobjects then
-         showfiles;
-    end;
-  until false;
-  dispose(inppu,done);
-  DoPPU:=True;
-end;
-
-
-
-var
-  i,parafile : longint;
-  dir        : SearchRec;
-  s,InFile   : String;
-  p          : poutfile;
-begin
-{ defaults }
-  skipdup:=true;
-{ options }
-  i:=1;
-  while (i<=paramcount) do
-   begin
-     s:=paramstr(i);
-     if s[1]<>'-' then
-      break;
-     case upcase(s[2]) of
-      'L' : showshared:=true;
-      'S' : showstatic:=true;
-      'O' : showobjects:=true;
-      'A' : skipdup:=false;
-      '?','H' :
-        begin
-          writeln('usage: ppufiles [options] <files>');
-          writeln('options:');
-          writeln('  -A  Show all files (don''t remove duplicates)');
-          writeln('  -L  Show only shared libraries');
-          writeln('  -S  Show only static libraries');
-          writeln('  -O  Show only object files');
-          writeln('  -H  This helpscreen');
-        end;
-     end;
-     inc(i);
-   end;
-  { default shows everything }
-  if i=1 then
-   begin
-     showshared:=true;
-     showstatic:=true;
-     showobjects:=true;
-   end;
-{ files }
-  parafile:=i;
-  for i:=parafile to ParamCount do
-   begin
-     InFile:=AddExtension(ParamStr(i),PPUExt);
-     FindFirst(InFile,$20,Dir);
-     while (DosError=0) do
-      begin
-        DoPPU(SplitPath(InFile)+Dir.Name);
-        FindNext(Dir);
-      end;
-{$ifdef fpc}
-     FindClose(Dir);
-{$endif}
-   end;
-{ Display the files }
-  while assigned(outfiles) do
-   begin
-     p:=outfiles;
-     write(outfiles^.name);
-     outfiles:=outfiles^.next;
-     dispose(p);
-     if assigned(outfiles) then
-      write(' ');
-   end;
-end.
-{
-  $Log$
-  Revision 1.2  2000-11-06 13:16:19  michael
-  + merged fixes from Peter
-
-  Revision 1.1.2.1  2000/11/06 13:14:48  michael
-  + Fixes from Peter for slashes in filenames
-
-  Revision 1.1  2000/07/13 10:16:22  michael
-  + Initial import
-
-  Revision 1.4  2000/07/04 19:05:54  peter
-    * be optimistic: version 1.00 for some utils
-
-  Revision 1.3  2000/01/24 12:32:22  daniel
-    * use a linkedlist instead of ansistring
-
-  Revision 1.2  2000/01/07 16:46:04  daniel
-    * copyright 2000
-
-  Revision 1.1  1999/11/23 09:44:41  peter
-    * initial version
-
-}

+ 0 - 644
utils/ppumove.pp

@@ -1,644 +0,0 @@
-{
-    $Id$
-    Copyright (c) 1999-2000 by the FPC Development Team
-
-    Add multiple FPC units into a static/shared library
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************}
-{$ifndef TP}
-  {$H+}
-{$endif}
-Program ppumove;
-uses
-{$ifdef unix}
-  unix,
-{$else unix}
-  dos,
-{$endif unix}
-  ppu,
-  getopts;
-
-const
-  Version   = 'Version 1.00';
-  Title     = 'PPU-Mover';
-  Copyright = 'Copyright (c) 1998-2000 by the Free Pascal Development Team';
-
-  ShortOpts = 'o:e:d:qhsvbw';
-  BufSize = 4096;
-  PPUExt = 'ppu';
-  ObjExt = 'o';
-  StaticLibExt ='a';
-{$ifdef unix}
-  SharedLibExt ='so';
-  BatchExt     ='.sh';
-{$else}
-  SharedLibExt ='dll';
-  BatchExt     ='.bat';
-{$endif unix}
-
-  { link options }
-  link_none    = $0;
-  link_allways = $1;
-  link_static  = $2;
-  link_smart   = $4;
-  link_shared  = $8;
-
-Type
-  PLinkOEnt = ^TLinkOEnt;
-  TLinkOEnt = record
-    Name : string;
-    Next : PLinkOEnt;
-  end;
-
-Var
-  ArBin,LDBin,StripBin,
-  OutputFile,
-  OutputFileForLink,  { the name of the output file needed when linking }
-  DestPath,
-  PPLExt,
-  LibExt      : string;
-  Batch,
-  Quiet,
-  MakeStatic  : boolean;
-  Buffer      : Pointer;
-  ObjFiles    : PLinkOEnt;
-  BatchFile   : Text;
-
-{*****************************************************************************
-                                 Helpers
-*****************************************************************************}
-
-Procedure Error(const s:string;stop:boolean);
-{
-  Write an error message to stderr
-}
-begin
-{$ifdef FPC}
-  writeln(stderr,s);
-{$else}
-  writeln(s);
-{$endif}
-  if stop then
-   halt(1);
-end;
-
-
-function Shell(const s:string):longint;
-{
-  Run a shell commnad and return the exitcode
-}
-begin
-  if Batch then
-   begin
-     Writeln(BatchFile,s);
-     Shell:=0;
-     exit;
-   end;
-{$ifdef unix}
-  Shell:=unix.shell(s);
-{$else}
-  exec(getenv('COMSPEC'),'/C '+s);
-  Shell:=DosExitCode;
-{$endif}
-end;
-
-
-Function FileExists (Const F : String) : Boolean;
-{
-  Returns True if the file exists, False if not.
-}
-Var
-{$ifdef unix}
-  info : Stat;
-{$else}
-  info : searchrec;
-{$endif}
-begin
-{$ifdef unix}
-  FileExists:=FStat (F,Info);
-{$else}
-  FindFirst (F,anyfile,Info);
-  FileExists:=DosError=0;
-{$endif}
-end;
-
-
-Function AddExtension(Const HStr,ext:String):String;
-{
-  Return a filename which will have extension ext added if no
-  extension is found
-}
-var
-  j : longint;
-begin
-  j:=length(Hstr);
-  while (j>0) and (Hstr[j]<>'.') do
-   dec(j);
-  if j=0 then
-   AddExtension:=Hstr+'.'+Ext
-  else
-   AddExtension:=HStr;
-end;
-
-
-Function ForceExtension(Const HStr,ext:String):String;
-{
-  Return a filename which certainly has the extension ext
-}
-var
-  j : longint;
-begin
-  j:=length(Hstr);
-  while (j>0) and (Hstr[j]<>'.') do
-   dec(j);
-  if j=0 then
-   j:=255;
-  ForceExtension:=Copy(Hstr,1,j-1)+'.'+Ext;
-end;
-
-
-Procedure AddToLinkFiles(const S : String);
-{
-  Adds a filename to a list of object files to link to.
-  No duplicates allowed.
-}
-Var
-  P : PLinKOEnt;
-begin
-  P:=ObjFiles;
-  { Don't add files twice }
-  While (P<>nil) and (p^.name<>s) do
-    p:=p^.next;
-  if p=nil then
-   begin
-     new(p);
-     p^.next:=ObjFiles;
-     p^.name:=s;
-     ObjFiles:=P;
-   end;
-end;
-
-
-Function ExtractLib(const libfn:string):string;
-{
-  Extract a static library libfn and return the files with a
-  wildcard
-}
-var
-  n : namestr;
-  d : dirstr;
-  e : extstr;
-begin
-{ create the temp dir first }
-  fsplit(libfn,d,n,e);
-  {$I-}
-   mkdir(n+'.sl');
-  {$I+}
-  if ioresult<>0 then;
-{ Extract }
-  if Shell(arbin+' x '+libfn)<>0 then
-   Error('Fatal: Error running '+arbin,true);
-{ Remove the lib file, it's extracted so it can be created with ease }
-  if PPLExt=PPUExt then
-   Shell('rm '+libfn);
-{$ifdef unix}
-  ExtractLib:=n+'.sl/*';
-{$else}
-  ExtractLib:=n+'.sl\*';
-{$endif}
-end;
-
-
-Function DoPPU(const PPUFn,PPLFn:String):Boolean;
-{
-  Convert one file (in Filename) to library format.
-  Return true if successful, false otherwise.
-}
-Var
-  inppu,
-  outppu : pppufile;
-  b,
-  untilb : byte;
-  l,m    : longint;
-  f      : file;
-  s      : string;
-begin
-  DoPPU:=false;
-  If Not Quiet then
-   Write ('Processing ',PPUFn,'...');
-  inppu:=new(pppufile,init(PPUFn));
-  if not inppu^.open then
-   begin
-     dispose(inppu,done);
-     Error('Error: Could not open : '+PPUFn,false);
-     Exit;
-   end;
-{ Check the ppufile }
-  if not inppu^.CheckPPUId then
-   begin
-     dispose(inppu,done);
-     Error('Error: Not a PPU File : '+PPUFn,false);
-     Exit;
-   end;
-  if inppu^.GetPPUVersion<CurrentPPUVersion then
-   begin
-     dispose(inppu,done);
-     Error('Error: Wrong PPU Version : '+PPUFn,false);
-     Exit;
-   end;
-{ No .o file generated for this ppu, just skip }
-  if (inppu^.header.flags and uf_no_link)<>0 then
-   begin
-     dispose(inppu,done);
-     If Not Quiet then
-      Writeln (' No files.');
-     DoPPU:=true;
-     Exit;
-   end;
-{ Already a lib? }
-  if (inppu^.header.flags and uf_in_library)<>0 then
-   begin
-     dispose(inppu,done);
-     Error('Error: PPU is already in a library : '+PPUFn,false);
-     Exit;
-   end;
-{ We need a static linked unit }
-  if (inppu^.header.flags and uf_static_linked)=0 then
-   begin
-     dispose(inppu,done);
-     Error('Error: PPU is not static linked : '+PPUFn,false);
-     Exit;
-   end;
-{ Create the new ppu }
-  if PPUFn=PPLFn then
-   outppu:=new(pppufile,init('ppumove.$$$'))
-  else
-   outppu:=new(pppufile,init(PPLFn));
-  outppu^.create;
-{ Create new header, with the new flags }
-  outppu^.header:=inppu^.header;
-  outppu^.header.flags:=outppu^.header.flags or uf_in_library;
-  if MakeStatic then
-   outppu^.header.flags:=outppu^.header.flags or uf_static_linked
-  else
-   outppu^.header.flags:=outppu^.header.flags or uf_shared_linked;
-{ read until the object files are found }
-  untilb:=iblinkunitofiles;
-  repeat
-    b:=inppu^.readentry;
-    if b in [ibendinterface,ibend] then
-     begin
-       dispose(inppu,done);
-       dispose(outppu,done);
-       Error('Error: No files to be linked found : '+PPUFn,false);
-       Exit;
-     end;
-    if b<>untilb then
-     begin
-       repeat
-         inppu^.getdatabuf(buffer^,bufsize,l);
-         outppu^.putdata(buffer^,l);
-       until l<bufsize;
-       outppu^.writeentry(b);
-     end;
-  until (b=untilb);
-{ we have now reached the section for the files which need to be added,
-  now add them to the list }
-  case b of
-    iblinkunitofiles :
-      begin
-        { add all o files, and save the entry when not creating a static
-          library to keep staticlinking possible }
-        while not inppu^.endofentry do
-         begin
-           s:=inppu^.getstring;
-           m:=inppu^.getlongint;
-           if not MakeStatic then
-            begin
-              outppu^.putstring(s);
-              outppu^.putlongint(m);
-            end;
-           AddToLinkFiles(s);
-         end;
-        if not MakeStatic then
-         outppu^.writeentry(b);
-      end;
-{    iblinkunitstaticlibs :
-      begin
-        AddToLinkFiles(ExtractLib(inppu^.getstring));
-        if not inppu^.endofentry then
-         begin
-           repeat
-             inppu^.getdatabuf(buffer^,bufsize,l);
-             outppu^.putdata(buffer^,l);
-           until l<bufsize;
-           outppu^.writeentry(b);
-         end;
-       end; }
-  end;
-{ just add a new entry with the new lib }
-  if MakeStatic then
-   begin
-     outppu^.putstring(outputfileforlink);
-     outppu^.putlongint(link_static);
-     outppu^.writeentry(iblinkunitstaticlibs)
-   end
-  else
-   begin
-     outppu^.putstring(outputfileforlink);
-     outppu^.putlongint(link_shared);
-     outppu^.writeentry(iblinkunitsharedlibs);
-   end;
-{ read all entries until the end and write them also to the new ppu }
-  repeat
-    b:=inppu^.readentry;
-  { don't write ibend, that's written automaticly }
-    if b<>ibend then
-     begin
-       repeat
-         inppu^.getdatabuf(buffer^,bufsize,l);
-         outppu^.putdata(buffer^,l);
-       until l<bufsize;
-       outppu^.writeentry(b);
-     end;
-  until b=ibend;
-{ write the last stuff and close }
-  outppu^.flush;
-  outppu^.writeheader;
-  dispose(outppu,done);
-  dispose(inppu,done);
-{ rename }
-  if PPUFn=PPLFn then
-   begin
-     {$I-}
-      assign(f,PPUFn);
-      erase(f);
-      assign(f,'ppumove.$$$');
-      rename(f,PPUFn);
-     {$I+}
-     if ioresult<>0 then;
-   end;
-{ the end }
-  If Not Quiet then
-   Writeln (' Done.');
-  DoPPU:=True;
-end;
-
-
-Function DoFile(const FileName:String):Boolean;
-{
-  Process a file, mainly here for wildcard support under Dos
-}
-{$ifndef unix}
-var
-  dir : searchrec;
-{$endif}
-begin
-{$ifdef unix}
-  DoFile:=DoPPU(FileName,ForceExtension(FileName,PPLExt));
-{$else}
-  DoFile:=false;
-  findfirst(filename,$20,dir);
-  while doserror=0 do
-   begin
-     if not DoPPU(Dir.Name,ForceExtension(Dir.Name,PPLExt)) then
-      exit;
-     findnext(dir);
-   end;
-  findclose(dir);
-  DoFile:=true;
-{$endif}
-end;
-
-
-Procedure DoLink;
-{
-  Link the object files together to form a (shared) library, the only
-  problem here is the 255 char limit of Names
-}
-Var
-  Names : String;
-  f     : file;
-  Err   : boolean;
-  P     : PLinkOEnt;
-begin
-  if not Quiet then
-   Write ('Linking ');
-  P:=ObjFiles;
-  names:='';
-  While p<>nil do
-   begin
-     if Names<>'' then
-      Names:=Names+' '+P^.name
-     else
-      Names:=p^.Name;
-     p:=p^.next;
-   end;
-  if Names='' then
-   begin
-     If not Quiet then
-      Writeln('Error: no files found to be linked');
-     exit;
-   end;
-  If not Quiet then
-   WriteLn(names);
-{ Run ar or ld to create the lib }
-  If MakeStatic then
-   Err:=Shell(arbin+' rs '+outputfile+' '+names)<>0
-  else
-   begin
-     Err:=Shell(ldbin+' -shared -o '+OutputFile+' '+names)<>0;
-     if not Err then
-      Shell(stripbin+' --strip-unneeded '+OutputFile);
-   end;
-  If Err then
-   Error('Fatal: Library building stage failed.',true);
-{ fix permission to 644, so it's not 755 }
-{$ifdef unix}
-  ChMod(OutputFile,420);
-{$endif}
-{ Rename to the destpath }
-  if DestPath<>'' then
-   begin
-     Assign(F, OutputFile);
-     Rename(F,DestPath+'/'+OutputFile);
-   end;
-end;
-
-
-Procedure usage;
-{
-  Print usage and exit.
-}
-begin
-  Writeln(paramstr(0),': [-qhwvbs] [-e ext] [-o name] [-d path] file [file ...]');
-  Halt(0);
-end;
-
-
-
-Procedure processopts;
-{
-  Process command line opions, and checks if command line options OK.
-}
-var
-  C : char;
-begin
-  if paramcount=0 then
-   usage;
-{ Reset }
-  ObjFiles:=Nil;
-  Quiet:=False;
-  Batch:=False;
-  OutputFile:='';
-  PPLExt:='ppu';
-  ArBin:='ar';
-  LdBin:='ld';
-  StripBin:='strip';
-  repeat
-    c:=Getopt (ShortOpts);
-    Case C of
-      EndOfOptions : break;
-      's' : MakeStatic:=True;
-      'o' : OutputFile:=OptArg;
-      'd' : DestPath:=OptArg;
-      'e' : PPLext:=OptArg;
-      'q' : Quiet:=True;
-      'w' : begin
-              ArBin:='arw';
-              LdBin:='ldw';
-            end;
-      'b' : Batch:=true;
-      '?' : Usage;
-      'h' : Usage;
-    end;
-  until false;
-{ Test filenames on the commandline }
-  if (OptInd>Paramcount) then
-   Error('Error: no input files',true);
-  if (OptInd<ParamCount) and (OutputFile='') then
-   Error('Error: when moving multiple units, specify an output name.',true);
-{ alloc a buffer }
-  GetMem (Buffer,Bufsize);
-  If Buffer=Nil then
-   Error('Error: could not allocate memory for buffer.',true);
-end;
-
-
-var
-  i : longint;
-begin
-  ProcessOpts;
-{ Write Header }
-  if not Quiet then
-   begin
-     Writeln(Title+' '+Version);
-     Writeln(Copyright);
-     Writeln;
-   end;
-{ Check if shared is allowed }
-{$ifndef unix}
-  if arbin<>'arw' then
-   begin
-     Writeln('Warning: shared library not supported for Go32, switching to static library');
-     MakeStatic:=true;
-   end;
-{$endif}
-{ fix the libext and outputfilename }
-  if Makestatic then
-   LibExt:=StaticLibExt
-  else
-   LibExt:=SharedLibExt;
-  if OutputFile='' then
-   OutPutFile:=Paramstr(OptInd);
-{ fix filename }
-{$ifdef unix}
-  if Copy(OutputFile,1,3)<>'lib' then
-   OutputFile:='lib'+OutputFile;
-  { For unix skip replacing the extension if a full .so.X.X if specified }
-  i:=pos('.so.',Outputfile);
-  if i<>0 then
-   OutputFileForLink:=Copy(Outputfile,4,i-4)
-  else
-   begin
-     OutputFile:=ForceExtension(OutputFile,LibExt);
-     OutputFileForLink:=Copy(Outputfile,4,length(Outputfile)-length(LibExt)-4);
-   end;
-{$else}
-  OutputFile:=ForceExtension(OutputFile,LibExt);
-  OutputFileForLink:=OutputFile;
-{$endif}
-{ Open BatchFile }
-  if Batch then
-   begin
-     Assign(BatchFile,'pmove'+BatchExt);
-     Rewrite(BatchFile);
-   end;
-{ Process Files }
-  i:=OptInd;
-  While (i<=ParamCount) and Dofile(AddExtension(Paramstr(i),PPUExt)) do
-   Inc(i);
-{ Do Linking stage }
-  DoLink;
-{ Close BatchFile }
-  if Batch then
-   begin
-     if Not Quiet then
-      Writeln('Writing pmove'+BatchExt);
-     Close(BatchFile);
-{$ifdef unix}
-     ChMod('pmove'+BatchExt,493);
-{$endif}
-   end;
-{ The End }
-  if Not Quiet then
-   Writeln('Done.');
-end.
-{
-  $Log$
-  Revision 1.2  2001-01-29 21:48:26  peter
-    * linux -> unix
-
-  Revision 1.1  2000/07/13 10:16:22  michael
-  + Initial import
-
-  Revision 1.11  2000/07/04 19:05:54  peter
-    * be optimistic: version 1.00 for some utils
-
-  Revision 1.10  2000/05/17 18:30:57  peter
-    * libname fixes for unix
-
-  Revision 1.9  2000/02/09 16:44:15  peter
-    * log truncated
-
-  Revision 1.8  2000/01/07 16:46:04  daniel
-    * copyright 2000
-
-  Revision 1.7  1999/11/25 00:00:39  peter
-    * strip created .so file with strip --strip-unneeded
-
-  Revision 1.6  1999/11/23 09:44:15  peter
-    * updated
-
-  Revision 1.5  1999/07/29 01:40:21  peter
-    * fsplit var type fixes
-
-  Revision 1.4  1999/07/28 16:53:58  peter
-    * updated for new linking, but still doesn't work because ld-unix.so.2
-      requires some more crt*.o files
-
-}