]> git.sur5r.net Git - cc65/commitdiff
Add capability to dump just the segment sizes
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 25 Nov 2002 17:32:16 +0000 (17:32 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 25 Nov 2002 17:32:16 +0000 (17:32 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1647 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/od65/dump.c
src/od65/dump.h
src/od65/global.h
src/od65/main.c

index 431ced5275cbc83ff3e5eceb90c9c7cf2edc0777..0d2dadaeb99614dfeae7844ba84940001356acbd 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2001 Ullrich von Bassewitz                                       */
+/* (C) 2000-2002 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
 /* EMail:        uz@cc65.org                                                 */
@@ -744,4 +744,56 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
 
 
 
+void DumpObjSegSize (FILE* F, unsigned long Offset)
+/* Dump the sizes of the segment in the object file */
+{
+    ObjHeader H;
+    unsigned Count;
+
+    /* Seek to the header position */
+    FileSeek (F, Offset);
+
+    /* Read the header */
+    ReadObjHeader (F, &H);
+
+    /* Seek to the start of the segments */
+    FileSeek (F, Offset + H.SegOffs);
+
+    /* Output a header */
+    printf ("  Segment sizes:\n");
+
+    /* Read the number of segments */
+    Count = ReadVar (F);
+
+    /* Read and print the sizes of all segments */
+    while (Count--) {
+
+               /* Read the data for one segments */
+       char*         Name  = ReadStr (F);
+       unsigned      Len   = strlen (Name);
+       unsigned long Size  = Read32 (F);
+
+        /* Skip alignment and type */
+        (void) Read8 (F);
+        (void) Read8 (F);
+
+       /* Print the size for this segment */
+       printf ("    %s:%*s%6lu\n", Name, 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;
+       }
+    }
+}
+
+
 
index 96a65f725a2d75674cabc94696eb9c5e0e1a8243..43d96a7e14a2ab2a8f289ad9f575e68134040fc2 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2001 Ullrich von Bassewitz                                       */
+/* (C) 2000-2002 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
 /* EMail:        uz@cc65.org                                                 */
@@ -72,6 +72,9 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset);
 void DumpObjLineInfo (FILE* F, unsigned long Offset);
 /* Dump the line infos from an object file */
 
+void DumpObjSegSize (FILE* F, unsigned long Offset);
+/* Dump the sizes of the segment in the object file */
+
 
 
 /* End of dump.h */
index 702e5691ab528f09fcbb97521e578aaa53950ab2..09eab2c110f7100b785e57ee1e226ee2351e045b 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 2000-2002 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -52,6 +52,7 @@
 #define D_EXPORTS              0x0020U         /* Dump exported symbols */
 #define D_DBGSYMS              0x0040U         /* Dump debug symbols */
 #define D_LINEINFO      0x0080U         /* Dump line infos */
+#define D_SEGSIZE       0x0100U         /* Dump segment sizes */
 #define D_ALL                  0xFFFFU         /* Dump anything */
 
 
index d3171f776a0d4cb3349019844c0eb802c746777d..a79bc0bd0a5a042a2509457f6657167e8abd57c6 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2001 Ullrich von Bassewitz                                       */
+/* (C) 2000-2002 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
 /* EMail:        uz@cc65.org                                                 */
@@ -74,6 +74,8 @@ static void Usage (void)
             "Usage: %s [options] file [options] [file]\n"
             "Short options:\n"
                     "  -h\t\t\tHelp (this text)\n"
+                    "  -H\t\t\tDump the object file header\n"
+                    "  -S\t\t\tDump segments sizes\n"
                     "  -V\t\t\tPrint the version number and exit\n"
             "\n"
             "Long options:\n"
@@ -86,6 +88,7 @@ static void Usage (void)
             "  --dump-lineinfo\tDump line information\n"
             "  --dump-options\tDump object file options\n"
             "  --dump-segments\tDump the segments in the file\n"
+                    "  --dump-segsize\tDump segments sizes\n"
             "  --help\t\tHelp (this text)\n"
                     "  --version\t\tPrint the version number and exit\n",
             ProgName);
@@ -174,6 +177,15 @@ static void OptDumpSegments (const char* Opt attribute ((unused)),
 
 
 
+static void OptDumpSegSize (const char* Opt attribute ((unused)),
+                           const char* Arg attribute ((unused)))
+/* Dump the segments in the object file */
+{
+    What |= D_SEGSIZE;
+}
+
+
+
 static void OptHelp (const char* Opt attribute ((unused)),
                     const char* Arg attribute ((unused)))
 /* Print usage information and exit */
@@ -250,6 +262,9 @@ static void DumpFile (const char* Name)
        if (What & D_LINEINFO) {
            DumpObjLineInfo (F, 0);
        }
+       if (What & D_SEGSIZE) {
+                   DumpObjSegSize (F, 0);
+       }
     }
 
     /* Close the file */
@@ -272,8 +287,9 @@ int main (int argc, char* argv [])
         { "--dump-lineinfo",    0,      OptDumpLineInfo         },
        { "--dump-options",     0,      OptDumpOptions          },
        { "--dump-segments",    0,      OptDumpSegments         },
-       { "--help",             0,      OptHelp                 },
-       { "--version",          0,      OptVersion              },
+               { "--dump-segsize",     0,      OptDumpSegSize          },
+       { "--help",             0,      OptHelp                 },
+       { "--version",          0,      OptVersion              },
     };
 
     unsigned I;
@@ -304,6 +320,10 @@ int main (int argc, char* argv [])
                    OptDumpHeader (Arg, 0);
                    break;
 
+               case 'S':
+                   OptDumpSegSize (Arg, 0);
+                   break;
+
                        case 'V':
                    OptVersion (Arg, 0);
                            break;