Add capability to dump just the segment sizes
git-svn-id: svn://svn.cc65.org/cc65/trunk@1647 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000-2001 Ullrich von Bassewitz */
|
/* (C) 2000-2002 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Wacholderweg 14 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70597 Stuttgart */
|
||||||
/* EMail: uz@cc65.org */
|
/* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000-2001 Ullrich von Bassewitz */
|
/* (C) 2000-2002 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Wacholderweg 14 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70597 Stuttgart */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@@ -72,6 +72,9 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset);
|
|||||||
void DumpObjLineInfo (FILE* F, unsigned long Offset);
|
void DumpObjLineInfo (FILE* F, unsigned long Offset);
|
||||||
/* Dump the line infos from an object file */
|
/* 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 */
|
/* End of dump.h */
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000 Ullrich von Bassewitz */
|
/* (C) 2000-2002 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Wacholderweg 14 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70597 Stuttgart */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@musoftware.de */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
#define D_EXPORTS 0x0020U /* Dump exported symbols */
|
#define D_EXPORTS 0x0020U /* Dump exported symbols */
|
||||||
#define D_DBGSYMS 0x0040U /* Dump debug symbols */
|
#define D_DBGSYMS 0x0040U /* Dump debug symbols */
|
||||||
#define D_LINEINFO 0x0080U /* Dump line infos */
|
#define D_LINEINFO 0x0080U /* Dump line infos */
|
||||||
|
#define D_SEGSIZE 0x0100U /* Dump segment sizes */
|
||||||
#define D_ALL 0xFFFFU /* Dump anything */
|
#define D_ALL 0xFFFFU /* Dump anything */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000-2001 Ullrich von Bassewitz */
|
/* (C) 2000-2002 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Wacholderweg 14 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70597 Stuttgart */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@@ -74,6 +74,8 @@ static void Usage (void)
|
|||||||
"Usage: %s [options] file [options] [file]\n"
|
"Usage: %s [options] file [options] [file]\n"
|
||||||
"Short options:\n"
|
"Short options:\n"
|
||||||
" -h\t\t\tHelp (this text)\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"
|
" -V\t\t\tPrint the version number and exit\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Long options:\n"
|
"Long options:\n"
|
||||||
@@ -86,6 +88,7 @@ static void Usage (void)
|
|||||||
" --dump-lineinfo\tDump line information\n"
|
" --dump-lineinfo\tDump line information\n"
|
||||||
" --dump-options\tDump object file options\n"
|
" --dump-options\tDump object file options\n"
|
||||||
" --dump-segments\tDump the segments in the file\n"
|
" --dump-segments\tDump the segments in the file\n"
|
||||||
|
" --dump-segsize\tDump segments sizes\n"
|
||||||
" --help\t\tHelp (this text)\n"
|
" --help\t\tHelp (this text)\n"
|
||||||
" --version\t\tPrint the version number and exit\n",
|
" --version\t\tPrint the version number and exit\n",
|
||||||
ProgName);
|
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)),
|
static void OptHelp (const char* Opt attribute ((unused)),
|
||||||
const char* Arg attribute ((unused)))
|
const char* Arg attribute ((unused)))
|
||||||
/* Print usage information and exit */
|
/* Print usage information and exit */
|
||||||
@@ -250,6 +262,9 @@ static void DumpFile (const char* Name)
|
|||||||
if (What & D_LINEINFO) {
|
if (What & D_LINEINFO) {
|
||||||
DumpObjLineInfo (F, 0);
|
DumpObjLineInfo (F, 0);
|
||||||
}
|
}
|
||||||
|
if (What & D_SEGSIZE) {
|
||||||
|
DumpObjSegSize (F, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the file */
|
/* Close the file */
|
||||||
@@ -272,8 +287,9 @@ int main (int argc, char* argv [])
|
|||||||
{ "--dump-lineinfo", 0, OptDumpLineInfo },
|
{ "--dump-lineinfo", 0, OptDumpLineInfo },
|
||||||
{ "--dump-options", 0, OptDumpOptions },
|
{ "--dump-options", 0, OptDumpOptions },
|
||||||
{ "--dump-segments", 0, OptDumpSegments },
|
{ "--dump-segments", 0, OptDumpSegments },
|
||||||
{ "--help", 0, OptHelp },
|
{ "--dump-segsize", 0, OptDumpSegSize },
|
||||||
{ "--version", 0, OptVersion },
|
{ "--help", 0, OptHelp },
|
||||||
|
{ "--version", 0, OptVersion },
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned I;
|
unsigned I;
|
||||||
@@ -304,6 +320,10 @@ int main (int argc, char* argv [])
|
|||||||
OptDumpHeader (Arg, 0);
|
OptDumpHeader (Arg, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'S':
|
||||||
|
OptDumpSegSize (Arg, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
OptVersion (Arg, 0);
|
OptVersion (Arg, 0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user