]> git.sur5r.net Git - cc65/blobdiff - src/od65/dump.c
Changed the startup module and the linker config for the C16 to use the common
[cc65] / src / od65 / dump.c
index 366ca82c5ce197104d358e44bdb9b130b7c21925..26b0c38e998161bcc2cd3aaea3c5201bbd03cfca 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2002-2003 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2002-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -37,6 +37,7 @@
 #include <time.h>
 
 /* common */
+#include "addrsize.h"
 #include "cddefs.h"
 #include "coll.h"
 #include "exprdefs.h"
@@ -156,91 +157,11 @@ static void SkipExpr (FILE* F)
        /* Not a leaf node */
                SkipExpr (F);
        SkipExpr (F);
-
     }
 }
 
 
 
-static unsigned SkipFragment (FILE* F)
-/* Skip a fragment from the given file and return the size */
-{
-    FilePos Pos;
-    unsigned long Size;
-
-    /* Read the fragment type */
-    unsigned char Type = Read8 (F);
-
-    /* Extract the check mask */
-    unsigned char Check = Type & FRAG_CHECKMASK;
-    Type &= ~FRAG_CHECKMASK;
-
-    /* Handle the different fragment types */
-    switch (Type) {
-
-       case FRAG_LITERAL:
-                   Size = ReadVar (F);
-           break;
-
-       case FRAG_EXPR8:
-       case FRAG_EXPR16:
-       case FRAG_EXPR24:
-       case FRAG_EXPR32:
-       case FRAG_SEXPR8:
-       case FRAG_SEXPR16:
-       case FRAG_SEXPR24:
-       case FRAG_SEXPR32:
-           Size = Type & FRAG_BYTEMASK;
-           break;
-
-       case FRAG_FILL:
-           Size = ReadVar (F);
-           break;
-
-       default:
-           Error ("Unknown fragment type: 0x%02X", Type);
-           /* NOTREACHED */
-           return 0;
-    }
-
-
-
-    /* Now read the fragment data */
-    switch (Type & FRAG_TYPEMASK) {
-
-       case FRAG_LITERAL:
-           /* Literal data */
-           FileSeek (F, ftell (F) + Size);
-           break;
-
-       case FRAG_EXPR:
-       case FRAG_SEXPR:
-           /* An expression */
-           SkipExpr (F);
-           break;
-
-    }
-
-    /* Skip the check expression if we have one */
-    if (Check & FRAG_CHECK_WARN) {
-        SkipExpr (F);
-    }
-    if (Check & FRAG_CHECK_ERROR) {
-        SkipExpr (F);
-    }
-
-    /* Skip the file position of the fragment */
-    ReadFilePos (F, &Pos);
-
-    /* Skip the        additional line info */
-    (void) ReadVar (F);
-
-    /* Return the size */
-    return Size;
-}
-
-
-
 static const char* GetExportFlags (unsigned Flags, const unsigned char* ConDes)
 /* Get the export flags as a (static) string */
 {
@@ -251,24 +172,30 @@ static const char* GetExportFlags (unsigned Flags, const unsigned char* ConDes)
     unsigned Count;
     unsigned I;
 
-    /* Adressing mode */
+    /* Symbol type */
     TypeDesc[0] = '\0';
-    switch (Flags & EXP_MASK_SIZE) {
-               case EXP_ABS:   strcat (TypeDesc, "EXP_ABS");           break;
-               case EXP_ZP:    strcat (TypeDesc, "EXP_ZP");            break;
+    switch (Flags & SYM_MASK_TYPE) {
+               case SYM_STD:         strcat (TypeDesc, "SYM_STD");         break;
+               case SYM_CHEAP_LOCAL: strcat (TypeDesc, "SYM_CHEAP_LOCAL"); break;
+    }
+
+    /* Symbol usage */
+    switch (Flags & SYM_MASK_LABEL) {       
+               case SYM_EQUATE: strcat (TypeDesc, ",SYM_EQUATE"); break;
+               case SYM_LABEL:  strcat (TypeDesc, ",SYM_LABEL");  break;
     }
 
     /* Type of expression */
-    switch (Flags & EXP_MASK_VAL) {
-               case EXP_CONST: strcat (TypeDesc, ",EXP_CONST");        break;
-               case EXP_EXPR:  strcat (TypeDesc, ",EXP_EXPR");         break;
+    switch (Flags & SYM_MASK_VAL) {
+               case SYM_CONST: strcat (TypeDesc, ",SYM_CONST"); break;
+               case SYM_EXPR:  strcat (TypeDesc, ",SYM_EXPR");   break;
     }
 
     /* Constructor/destructor declarations */
     T = TypeDesc + strlen (TypeDesc);
-    Count = GET_EXP_CONDES_COUNT (Flags);
-    if (Count > 0) {
-       T += sprintf (T, ",EXP_CONDES=");
+    Count = SYM_GET_CONDES_COUNT (Flags);
+    if (Count > 0 && ConDes) {
+       T += sprintf (T, ",SYM_CONDES=");
        for (I = 0; I < Count; ++I) {
            unsigned Type = CD_GET_TYPE (ConDes[I]);
            unsigned Prio = CD_GET_PRIO (ConDes[I]);
@@ -291,7 +218,7 @@ void DumpObjHeader (FILE* F, unsigned long Offset)
     ObjHeader H;
 
     /* Seek to the header position */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
 
     /* Read the header */
     ReadObjHeader (F, &H);
@@ -350,15 +277,15 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
     unsigned   I;
 
     /* Seek to the header position and read the header */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
     ReadObjHeader (F, &H);
 
     /* Seek to the start of the string pool and read it */
-    FileSeek (F, Offset + H.StrPoolOffs);
+    FileSetPos (F, Offset + H.StrPoolOffs);
     ReadStrPool (F, &StrPool);
 
     /* Seek to the start of the options */
-    FileSeek (F, Offset + H.OptionOffs);
+    FileSetPos (F, Offset + H.OptionOffs);
 
     /* Output a header */
     printf ("  Options:\n");
@@ -370,49 +297,47 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
     /* Read and print all options */
     for (I = 0; I < Count; ++I) {
 
-       unsigned long ArgNum;
-       char*         ArgStr;
-       unsigned      ArgLen;
+       const char*   ArgStr;
+       unsigned      ArgLen;
 
-       /* Read the type of the option */
-       unsigned char Type = Read8 (F);
+       /* Read the type of the option and the value */
+       unsigned char Type = Read8 (F);
+        unsigned long Val  = ReadVar (F);
 
                /* Get the type of the argument */
-       unsigned char ArgType = Type & OPT_ARGMASK;
+       unsigned char ArgType = Type & OPT_ARGMASK;
 
-       /* Determine which option follows */
-       const char* TypeDesc;
-       switch (Type) {
+       /* Determine which option follows */
+       const char* TypeDesc;
+       switch (Type) {
                    case OPT_COMMENT:   TypeDesc = "OPT_COMMENT";       break;
-           case OPT_AUTHOR:    TypeDesc = "OPT_AUTHOR";        break;
-           case OPT_TRANSLATOR:TypeDesc = "OPT_TRANSLATOR";    break;
-           case OPT_COMPILER:  TypeDesc = "OPT_COMPILER";      break;
-           case OPT_OS:        TypeDesc = "OPT_OS";            break;
-           case OPT_DATETIME:  TypeDesc = "OPT_DATETIME";      break;
-           default:            TypeDesc = "OPT_UNKNOWN";       break;
-       }
-
-       /* Print the header */
-       printf ("    Index:%27u\n", I);
-
-       /* Print the data */
-       printf ("      Type:%22s0x%02X  (%s)\n", "", Type, TypeDesc);
-       switch (ArgType) {
-
-           case OPT_ARGSTR:
-               ArgStr = ReadStr (F);
-               ArgLen = strlen (ArgStr);
-               printf ("      Data:%*s\"%s\"\n", 24-ArgLen, "", ArgStr);
-               xfree (ArgStr);
-               break;
-
-           case OPT_ARGNUM:
-               ArgNum = Read32 (F);
-               printf ("      Data:%26lu", ArgNum);
-               if (Type == OPT_DATETIME) {
-                   /* Print the time as a string */
-                   printf ("  (%s)", TimeToStr (ArgNum));
-               }
+           case OPT_AUTHOR:    TypeDesc = "OPT_AUTHOR";        break;
+           case OPT_TRANSLATOR:TypeDesc = "OPT_TRANSLATOR";    break;
+           case OPT_COMPILER:  TypeDesc = "OPT_COMPILER";      break;
+           case OPT_OS:        TypeDesc = "OPT_OS";            break;
+           case OPT_DATETIME:  TypeDesc = "OPT_DATETIME";      break;
+           default:            TypeDesc = "OPT_UNKNOWN";       break;
+       }
+
+       /* Print the header */
+       printf ("    Index:%27u\n", I);
+
+       /* Print the data */
+       printf ("      Type:%22s0x%02X  (%s)\n", "", Type, TypeDesc);
+       switch (ArgType) {
+
+           case OPT_ARGSTR:
+               ArgStr = GetString (&StrPool, Val);
+               ArgLen = strlen (ArgStr);
+               printf ("      Data:%*s\"%s\"\n", (int)(24-ArgLen), "", ArgStr);
+               break;
+
+           case OPT_ARGNUM:
+               printf ("      Data:%26lu", Val);
+               if (Type == OPT_DATETIME) {
+                   /* Print the time as a string */
+                   printf ("  (%s)", TimeToStr (Val));
+               }
                printf ("\n");
                break;
 
@@ -440,15 +365,15 @@ void DumpObjFiles (FILE* F, unsigned long Offset)
     unsigned   I;
 
     /* Seek to the header position and read the header */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
     ReadObjHeader (F, &H);
 
     /* Seek to the start of the string pool and read it */
-    FileSeek (F, Offset + H.StrPoolOffs);
+    FileSetPos (F, Offset + H.StrPoolOffs);
     ReadStrPool (F, &StrPool);
 
     /* Seek to the start of the source files */
-    FileSeek (F, Offset + H.FileOffs);
+    FileSetPos (F, Offset + H.FileOffs);
 
     /* Output a header */
     printf ("  Files:\n");
@@ -461,21 +386,18 @@ void DumpObjFiles (FILE* F, unsigned long Offset)
     for (I = 0; I < Count; ++I) {
 
        /* Read the data for one file */
+               const char*   Name  = GetString (&StrPool, ReadVar (F));
        unsigned long MTime = Read32 (F);
        unsigned long Size  = Read32 (F);
-       char*         Name  = ReadStr (F);
        unsigned      Len   = strlen (Name);
 
        /* Print the header */
        printf ("    Index:%27u\n", I);
 
        /* Print the data */
-       printf ("      Name:%*s\"%s\"\n", 24-Len, "", Name);
+       printf ("      Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
                printf ("      Size:%26lu\n", Size);
        printf ("      Modification time:%13lu  (%s)\n", MTime, TimeToStr (MTime));
-
-       /* Free the Name */
-       xfree (Name);
     }
 
     /* Destroy the string pool */
@@ -491,18 +413,17 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
     Collection StrPool = AUTO_COLLECTION_INITIALIZER;
     unsigned   Count;
     unsigned   I;
-    unsigned   FragCount;
 
     /* Seek to the header position and read the header */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
     ReadObjHeader (F, &H);
 
     /* Seek to the start of the string pool and read it */
-    FileSeek (F, Offset + H.StrPoolOffs);
+    FileSetPos (F, Offset + H.StrPoolOffs);
     ReadStrPool (F, &StrPool);
 
     /* Seek to the start of the segments */
-    FileSeek (F, Offset + H.SegOffs);
+    FileSetPos (F, Offset + H.SegOffs);
 
     /* Output a header */
     printf ("  Segments:\n");
@@ -513,50 +434,30 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
 
     /* Read and print all segments */
     for (I = 0; I < Count; ++I) {
-                                    
+
        /* Read the data for one segments */
-       char*         Name  = ReadStr (F);
-       unsigned      Len   = strlen (Name);
-       unsigned long Size  = Read32 (F);
-       unsigned      Align = (1U << Read8 (F));
-       unsigned char Type  = Read8 (F);
-
-       /* Get the description for the type */
-       const char* TypeDesc;
-       switch (Type) {
-           case SEGTYPE_DEFAULT:       TypeDesc = "SEGTYPE_DEFAULT";   break;
-           case SEGTYPE_ABS:           TypeDesc = "SEGTYPE_ABS";       break;
-           case SEGTYPE_ZP:            TypeDesc = "SEGTYPE_ZP";        break;
-           case SEGTYPE_FAR:           TypeDesc = "SEGTYPE_FAR";       break;
-           default:                    TypeDesc = "SEGTYPE_UNKNOWN";   break;
-       }
+        unsigned long DataSize  = Read32 (F);
+        unsigned long NextSeg   = ftell (F) + DataSize;
+               const char*   Name      = GetString (&StrPool, ReadVar (F));
+       unsigned      Len       = strlen (Name);
+       unsigned long Size      = Read32 (F);
+       unsigned      Align     = (1U << Read8 (F));
+               unsigned char AddrSize  = Read8 (F);
+        unsigned long FragCount = ReadVar (F);
 
        /* Print the header */
        printf ("    Index:%27u\n", I);
 
        /* Print the data */
-       printf ("      Name:%*s\"%s\"\n", 24-Len, "", Name);
+       printf ("      Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
                printf ("      Size:%26lu\n", Size);
        printf ("      Alignment:%21u\n", Align);
-       printf ("      Type:%22s0x%02X  (%s)\n", "", Type, TypeDesc);
-
-       /* Free the Name */
-       xfree (Name);
-
-       /* Skip the fragments for this segment, counting them */
-       FragCount = 0;
-       while (Size > 0) {
-           unsigned FragSize = SkipFragment (F);
-           if (FragSize > Size) {
-               /* OOPS - file data invalid */
-               Error ("Invalid fragment data - file corrupt!");
-           }
-           Size -= FragSize;
-           ++FragCount;
-       }
+       printf ("      Address size:%14s0x%02X  (%s)\n", "", AddrSize,
+                AddrSizeToStr (AddrSize));
+               printf ("      Fragment count:%16lu\n", FragCount);
 
-       /* Print the fragment count */
-               printf ("      Fragment count:%16u\n", FragCount);
+        /* Seek to the end of the segment data (start of next) */
+        FileSetPos (F, NextSeg);
     }
 
     /* Destroy the string pool */
@@ -575,15 +476,15 @@ void DumpObjImports (FILE* F, unsigned long Offset)
     FilePos    Pos;
 
     /* Seek to the header position and read the header */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
     ReadObjHeader (F, &H);
 
     /* Seek to the start of the string pool and read it */
-    FileSeek (F, Offset + H.StrPoolOffs);
+    FileSetPos (F, Offset + H.StrPoolOffs);
     ReadStrPool (F, &StrPool);
 
     /* Seek to the start of the imports */
-    FileSeek (F, Offset + H.ImportOffs);
+    FileSetPos (F, Offset + H.ImportOffs);
 
     /* Output a header */
     printf ("  Imports:\n");
@@ -595,27 +496,19 @@ void DumpObjImports (FILE* F, unsigned long Offset)
     /* Read and print all imports */
     for (I = 0; I < Count; ++I) {
 
-       const char* TypeDesc;
-
                /* Read the data for one import */
-               unsigned char Type  = Read8 (F);
-               const char*   Name  = GetString (&StrPool, ReadVar (F));
-       unsigned      Len   = strlen (Name);
+               unsigned char AddrSize = Read8 (F);
+               const char*   Name     = GetString (&StrPool, ReadVar (F));
+       unsigned      Len      = strlen (Name);
        ReadFilePos (F, &Pos);
 
-       /* Get a description for the type */
-       switch (Type) {
-           case IMP_ZP:        TypeDesc = "IMP_ZP";            break;
-           case IMP_ABS:       TypeDesc = "IMP_ABS";           break;
-           default:            TypeDesc = "IMP_UNKNOWN";       break;
-       }
-
        /* Print the header */
        printf ("    Index:%27u\n", I);
 
        /* Print the data */
-               printf ("      Type:%22s0x%02X  (%s)\n", "", Type, TypeDesc);
-       printf ("      Name:%*s\"%s\"\n", 24-Len, "", Name);
+       printf ("      Address size:%14s0x%02X  (%s)\n", "", AddrSize,
+                AddrSizeToStr (AddrSize));
+       printf ("      Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
     }
 
     /* Destroy the string pool */
@@ -634,15 +527,15 @@ void DumpObjExports (FILE* F, unsigned long Offset)
     FilePos            Pos;
 
     /* Seek to the header position and read the header */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
     ReadObjHeader (F, &H);
 
     /* Seek to the start of the string pool and read it */
-    FileSeek (F, Offset + H.StrPoolOffs);
+    FileSetPos (F, Offset + H.StrPoolOffs);
     ReadStrPool (F, &StrPool);
 
     /* Seek to the start of the exports */
-    FileSeek (F, Offset + H.ExportOffs);
+    FileSetPos (F, Offset + H.ExportOffs);
 
     /* Output a header */
     printf ("  Exports:\n");
@@ -656,18 +549,18 @@ void DumpObjExports (FILE* F, unsigned long Offset)
 
        unsigned long   Value = 0;
        int             HaveValue;
-       unsigned char   Type;
        unsigned char   ConDes [CD_TYPE_COUNT];
                const char*     Name;
        unsigned        Len;
 
 
                /* Read the data for one export */
-               Type  = Read8 (F);
-       ReadData (F, ConDes, GET_EXP_CONDES_COUNT (Type));
+               unsigned Type          = ReadVar (F);
+        unsigned char AddrSize = Read8 (F);
+       ReadData (F, ConDes, SYM_GET_CONDES_COUNT (Type));
                Name  = GetString (&StrPool, ReadVar (F));
        Len   = strlen (Name);
-               if (IS_EXP_EXPR (Type)) {
+               if (SYM_IS_EXPR (Type)) {
            SkipExpr (F);
            HaveValue = 0;
        } else {
@@ -681,7 +574,9 @@ void DumpObjExports (FILE* F, unsigned long Offset)
 
        /* Print the data */
                printf ("      Type:%22s0x%02X  (%s)\n", "", Type, GetExportFlags (Type, ConDes));
-       printf ("      Name:%*s\"%s\"\n", 24-Len, "", Name);
+       printf ("      Address size:%14s0x%02X  (%s)\n", "", AddrSize,
+                AddrSizeToStr (AddrSize));
+       printf ("      Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
        if (HaveValue) {
            printf ("      Value:%15s0x%08lX  (%lu)\n", "", Value, Value);
        }
@@ -703,15 +598,15 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
     FilePos     Pos;
 
     /* Seek to the header position and read the header */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
     ReadObjHeader (F, &H);
 
     /* Seek to the start of the string pool and read it */
-    FileSeek (F, Offset + H.StrPoolOffs);
+    FileSetPos (F, Offset + H.StrPoolOffs);
     ReadStrPool (F, &StrPool);
 
     /* Seek to the start of the debug syms */
-    FileSeek (F, Offset + H.DbgSymOffs);
+    FileSetPos (F, Offset + H.DbgSymOffs);
 
     /* Output a header */
     printf ("  Debug symbols:\n");
@@ -731,18 +626,14 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
     for (I = 0; I < Count; ++I) {
 
        unsigned long   Value = 0;
-       int             HaveValue;
-       unsigned char   Type;
-       unsigned char   ConDes [CD_TYPE_COUNT];
-               const char*     Name;
-       unsigned        Len;
+       int             HaveValue;
 
                /* Read the data for one symbol */
-               Type  = Read8 (F);
-       ReadData (F, ConDes, GET_EXP_CONDES_COUNT (Type));
-       Name  = GetString (&StrPool, ReadVar (F));
-       Len   = strlen (Name);
-       if (IS_EXP_EXPR (Type)) {
+               unsigned Type          = ReadVar (F);
+        unsigned char AddrSize = Read8 (F);
+               const char*   Name     = GetString (&StrPool, ReadVar (F));
+       unsigned      Len      = strlen (Name);
+       if (SYM_IS_EXPR (Type)) {
            SkipExpr (F);
            HaveValue = 0;
        } else {
@@ -755,8 +646,10 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
        printf ("    Index:%27u\n", I);
 
        /* Print the data */
-               printf ("      Type:%22s0x%02X  (%s)\n", "", Type, GetExportFlags (Type, ConDes));
-       printf ("      Name:%*s\"%s\"\n", 24-Len, "", Name);
+               printf ("      Type:%22s0x%02X  (%s)\n", "", Type, GetExportFlags (Type, 0));
+       printf ("      Address size:%14s0x%02X  (%s)\n", "", AddrSize,
+                AddrSizeToStr (AddrSize));
+       printf ("      Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
        if (HaveValue) {
            printf ("      Value:%15s0x%08lX  (%lu)\n", "", Value, Value);
        }
@@ -777,15 +670,15 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
     unsigned    I;
 
     /* Seek to the header position and read the header */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
     ReadObjHeader (F, &H);
 
     /* Seek to the start of the string pool and read it */
-    FileSeek (F, Offset + H.StrPoolOffs);
+    FileSetPos (F, Offset + H.StrPoolOffs);
     ReadStrPool (F, &StrPool);
 
     /* Seek to the start of line infos */
-    FileSeek (F, Offset + H.LineInfoOffs);
+    FileSetPos (F, Offset + H.LineInfoOffs);
 
     /* Output a header */
     printf ("  Line info:\n");
@@ -832,15 +725,15 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
     unsigned    Count;
 
     /* Seek to the header position and read the header */
-    FileSeek (F, Offset);
+    FileSetPos (F, Offset);
     ReadObjHeader (F, &H);
 
     /* Seek to the start of the string pool and read it */
-    FileSeek (F, Offset + H.StrPoolOffs);
+    FileSetPos (F, Offset + H.StrPoolOffs);
     ReadStrPool (F, &StrPool);
 
     /* Seek to the start of the segments */
-    FileSeek (F, Offset + H.SegOffs);
+    FileSetPos (F, Offset + H.SegOffs);
 
     /* Output a header */
     printf ("  Segment sizes:\n");
@@ -852,29 +745,22 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
     while (Count--) {
 
                /* Read the data for one segments */
-       char*         Name  = ReadStr (F);
-       unsigned      Len   = strlen (Name);
-       unsigned long Size  = Read32 (F);
+        unsigned long DataSize = Read32 (F);
+        unsigned long NextSeg  = ftell (F) + DataSize;
+       const char*   Name     = GetString (&StrPool, ReadVar (F));
+       unsigned      Len      = strlen (Name);
+       unsigned long Size     = Read32 (F);
 
-        /* Skip alignment and type */
+        /* Skip alignment, type and fragment count */
         (void) Read8 (F);
         (void) Read8 (F);
+        (void) ReadVar (F);
 
        /* Print the size for this segment */
-       printf ("    %s:%*s%6lu\n", Name, 24-Len, "", Size);
+       printf ("    %s:%*s%6lu\n", Name, (int)(24-Len), "", Size);
 
-       /* Free the Name */
-       xfree (Name);
-
-       /* Skip the fragments for this segment, counting them */
-       while (Size > 0) {
-           unsigned FragSize = SkipFragment (F);
-           if (FragSize > Size) {
-               /* OOPS - file data invalid */
-               Error ("Invalid fragment data - file corrupt!");
-           }
-           Size -= FragSize;
-       }
+        /* Seek to the end of the segment data (start of next) */
+        FileSetPos (F, NextSeg);
     }
 
     /* Destroy the string pool */