/* */
/* */
/* */
-/* (C) 2000-2001 Ullrich von Bassewitz */
+/* (C) 2000-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
+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;
+ }
+ }
+}
+
+
/* */
/* */
/* */
-/* (C) 2000-2001 Ullrich von Bassewitz */
+/* (C) 2000-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
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 */
/* */
/* */
/* */
-/* (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 */
#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 */
/* */
/* */
/* */
-/* (C) 2000-2001 Ullrich von Bassewitz */
+/* (C) 2000-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
"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"
" --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);
+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 */
if (What & D_LINEINFO) {
DumpObjLineInfo (F, 0);
}
+ if (What & D_SEGSIZE) {
+ DumpObjSegSize (F, 0);
+ }
}
/* Close the file */
{ "--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;
OptDumpHeader (Arg, 0);
break;
+ case 'S':
+ OptDumpSegSize (Arg, 0);
+ break;
+
case 'V':
OptVersion (Arg, 0);
break;