Removed (pretty inconsistently used) tab chars from source code base.
This commit is contained in:
416
src/od65/dump.c
416
src/od65/dump.c
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* dump.c */
|
||||
/* dump.c */
|
||||
/* */
|
||||
/* Dump subroutines for the od65 object file dump utility */
|
||||
/* Dump subroutines for the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ static const char* GetString (const Collection* C, unsigned Index)
|
||||
|
||||
|
||||
static void DumpObjHeaderSection (const char* Name,
|
||||
unsigned long Offset,
|
||||
unsigned long Size)
|
||||
unsigned long Offset,
|
||||
unsigned long Size)
|
||||
/* Dump a header section */
|
||||
{
|
||||
printf (" %s:\n", Name);
|
||||
@@ -112,7 +112,7 @@ static char* TimeToStr (unsigned long Time)
|
||||
/* Remove the trailing newline */
|
||||
unsigned Len = strlen (S);
|
||||
if (Len > 0 && S[Len-1] == '\n') {
|
||||
S[Len-1 ] = '\0';
|
||||
S[Len-1 ] = '\0';
|
||||
}
|
||||
|
||||
/* Return the time string */
|
||||
@@ -155,38 +155,38 @@ static void SkipExpr (FILE* F)
|
||||
/* Read the node tag and handle NULL nodes */
|
||||
unsigned char Op = Read8 (F);
|
||||
if (Op == EXPR_NULL) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check the tag and handle the different expression types */
|
||||
if (EXPR_IS_LEAF (Op)) {
|
||||
switch (Op) {
|
||||
switch (Op) {
|
||||
|
||||
case EXPR_LITERAL:
|
||||
(void) Read32Signed (F);
|
||||
break;
|
||||
case EXPR_LITERAL:
|
||||
(void) Read32Signed (F);
|
||||
break;
|
||||
|
||||
case EXPR_SYMBOL:
|
||||
/* Read the import number */
|
||||
(void) ReadVar (F);
|
||||
break;
|
||||
case EXPR_SYMBOL:
|
||||
/* Read the import number */
|
||||
(void) ReadVar (F);
|
||||
break;
|
||||
|
||||
case EXPR_SECTION:
|
||||
case EXPR_SECTION:
|
||||
case EXPR_BANK:
|
||||
/* Read the segment number */
|
||||
(void) ReadVar (F);
|
||||
break;
|
||||
/* Read the segment number */
|
||||
(void) ReadVar (F);
|
||||
break;
|
||||
|
||||
default:
|
||||
Error ("Invalid expression op: %02X", Op);
|
||||
default:
|
||||
Error ("Invalid expression op: %02X", Op);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* Not a leaf node */
|
||||
SkipExpr (F);
|
||||
SkipExpr (F);
|
||||
/* Not a leaf node */
|
||||
SkipExpr (F);
|
||||
SkipExpr (F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,20 +205,20 @@ static const char* GetExportFlags (unsigned Flags, const unsigned char* ConDes)
|
||||
/* Symbol type */
|
||||
TypeDesc[0] = '\0';
|
||||
switch (Flags & SYM_MASK_TYPE) {
|
||||
case SYM_STD: strcat (TypeDesc, "SYM_STD"); break;
|
||||
case SYM_CHEAP_LOCAL: strcat (TypeDesc, "SYM_CHEAP_LOCAL"); break;
|
||||
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;
|
||||
case SYM_EQUATE: strcat (TypeDesc, ",SYM_EQUATE"); break;
|
||||
case SYM_LABEL: strcat (TypeDesc, ",SYM_LABEL"); break;
|
||||
}
|
||||
|
||||
/* Type of expression */
|
||||
switch (Flags & SYM_MASK_VAL) {
|
||||
case SYM_CONST: strcat (TypeDesc, ",SYM_CONST"); break;
|
||||
case SYM_EXPR: strcat (TypeDesc, ",SYM_EXPR"); break;
|
||||
case SYM_CONST: strcat (TypeDesc, ",SYM_CONST"); break;
|
||||
case SYM_EXPR: strcat (TypeDesc, ",SYM_EXPR"); break;
|
||||
}
|
||||
|
||||
/* Size available? */
|
||||
@@ -231,15 +231,15 @@ static const char* GetExportFlags (unsigned Flags, const unsigned char* ConDes)
|
||||
T = TypeDesc + strlen (TypeDesc);
|
||||
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]);
|
||||
if (I > 0) {
|
||||
*T++ = ',';
|
||||
}
|
||||
T += sprintf (T, "[%u,%u]", Type, Prio);
|
||||
}
|
||||
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]);
|
||||
if (I > 0) {
|
||||
*T++ = ',';
|
||||
}
|
||||
T += sprintf (T, "[%u,%u]", Type, Prio);
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the result */
|
||||
@@ -289,7 +289,7 @@ void DumpObjHeader (FILE* F, unsigned long Offset)
|
||||
/* Flags */
|
||||
printf (" Flags:%21s0x%04X (", "", H.Flags);
|
||||
if (H.Flags & OBJ_FLAGS_DBGINFO) {
|
||||
printf ("OBJ_FLAGS_DBGINFO");
|
||||
printf ("OBJ_FLAGS_DBGINFO");
|
||||
}
|
||||
printf (")\n");
|
||||
|
||||
@@ -355,57 +355,57 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
|
||||
/* Read and print all options */
|
||||
for (I = 0; I < Count; ++I) {
|
||||
|
||||
const char* ArgStr;
|
||||
unsigned ArgLen;
|
||||
const char* ArgStr;
|
||||
unsigned ArgLen;
|
||||
|
||||
/* Read the type of the option and the value */
|
||||
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;
|
||||
/* Get the type of the argument */
|
||||
unsigned char ArgType = Type & OPT_ARGMASK;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
/* 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 header */
|
||||
printf (" Index:%27u\n", I);
|
||||
|
||||
/* Print the data */
|
||||
printf (" Type:%22s0x%02X (%s)\n", "", Type, TypeDesc);
|
||||
switch (ArgType) {
|
||||
/* 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_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;
|
||||
case OPT_ARGNUM:
|
||||
printf (" Data:%26lu", Val);
|
||||
if (Type == OPT_DATETIME) {
|
||||
/* Print the time as a string */
|
||||
printf (" (%s)", TimeToStr (Val));
|
||||
}
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Unknown argument type. This means that we cannot determine
|
||||
* the option length, so we cannot proceed.
|
||||
*/
|
||||
Error ("Unknown option type: 0x%02X", Type);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Unknown argument type. This means that we cannot determine
|
||||
* the option length, so we cannot proceed.
|
||||
*/
|
||||
Error ("Unknown option type: 0x%02X", Type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Destroy the string pool */
|
||||
@@ -443,19 +443,19 @@ void DumpObjFiles (FILE* F, unsigned long Offset)
|
||||
/* Read and print all files */
|
||||
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 = ReadVar (F);
|
||||
unsigned Len = strlen (Name);
|
||||
/* Read the data for one file */
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned long MTime = Read32 (F);
|
||||
unsigned long Size = ReadVar (F);
|
||||
unsigned Len = strlen (Name);
|
||||
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
|
||||
/* Print the data */
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
printf (" Size:%26lu\n", Size);
|
||||
printf (" Modification time:%13lu (%s)\n", MTime, TimeToStr (MTime));
|
||||
/* Print the data */
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
printf (" Size:%26lu\n", Size);
|
||||
printf (" Modification time:%13lu (%s)\n", MTime, TimeToStr (MTime));
|
||||
}
|
||||
|
||||
/* Destroy the string pool */
|
||||
@@ -493,28 +493,28 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
|
||||
/* Read and print all segments */
|
||||
for (I = 0; I < Count; ++I) {
|
||||
|
||||
/* Read the data for one segments */
|
||||
/* Read the data for one segments */
|
||||
unsigned long DataSize = Read32 (F);
|
||||
unsigned long NextSeg = ftell (F) + DataSize;
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned Len = strlen (Name);
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned Len = strlen (Name);
|
||||
unsigned Flags = ReadVar (F);
|
||||
unsigned long Size = ReadVar (F);
|
||||
unsigned long Align = ReadVar (F);
|
||||
unsigned char AddrSize = Read8 (F);
|
||||
unsigned long Size = ReadVar (F);
|
||||
unsigned long Align = ReadVar (F);
|
||||
unsigned char AddrSize = Read8 (F);
|
||||
unsigned long FragCount = ReadVar (F);
|
||||
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
|
||||
/* Print the data */
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
/* Print the data */
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
printf (" Flags:%25u\n", Flags);
|
||||
printf (" Size:%26lu\n", Size);
|
||||
printf (" Alignment:%21lu\n", Align);
|
||||
printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize,
|
||||
printf (" Size:%26lu\n", Size);
|
||||
printf (" Alignment:%21lu\n", Align);
|
||||
printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize,
|
||||
AddrSizeToStr (AddrSize));
|
||||
printf (" Fragment count:%16lu\n", FragCount);
|
||||
printf (" Fragment count:%16lu\n", FragCount);
|
||||
|
||||
/* Seek to the end of the segment data (start of next) */
|
||||
FileSetPos (F, NextSeg);
|
||||
@@ -555,22 +555,22 @@ void DumpObjImports (FILE* F, unsigned long Offset)
|
||||
/* Read and print all imports */
|
||||
for (I = 0; I < Count; ++I) {
|
||||
|
||||
/* Read the data for one import */
|
||||
unsigned char AddrSize = Read8 (F);
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned Len = strlen (Name);
|
||||
/* Read the data for one import */
|
||||
unsigned char AddrSize = Read8 (F);
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned Len = strlen (Name);
|
||||
|
||||
/* Skip both line info lists */
|
||||
SkipLineInfoList (F);
|
||||
SkipLineInfoList (F);
|
||||
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
|
||||
/* Print the data */
|
||||
printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize,
|
||||
/* Print the data */
|
||||
printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize,
|
||||
AddrSizeToStr (AddrSize));
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
}
|
||||
|
||||
/* Destroy the string pool */
|
||||
@@ -582,10 +582,10 @@ void DumpObjImports (FILE* F, unsigned long Offset)
|
||||
void DumpObjExports (FILE* F, unsigned long Offset)
|
||||
/* Dump the exports in the object file */
|
||||
{
|
||||
ObjHeader H;
|
||||
ObjHeader H;
|
||||
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||
unsigned Count;
|
||||
unsigned I;
|
||||
unsigned Count;
|
||||
unsigned I;
|
||||
|
||||
/* Seek to the header position and read the header */
|
||||
FileSetPos (F, Offset);
|
||||
@@ -608,24 +608,24 @@ void DumpObjExports (FILE* F, unsigned long Offset)
|
||||
/* Read and print all exports */
|
||||
for (I = 0; I < Count; ++I) {
|
||||
|
||||
unsigned long Value = 0;
|
||||
unsigned long Value = 0;
|
||||
unsigned long Size = 0;
|
||||
unsigned char ConDes[CD_TYPE_COUNT];
|
||||
const char* Name;
|
||||
unsigned Len;
|
||||
unsigned char ConDes[CD_TYPE_COUNT];
|
||||
const char* Name;
|
||||
unsigned Len;
|
||||
|
||||
|
||||
/* Read the data for one export */
|
||||
unsigned Type = ReadVar (F);
|
||||
/* Read the data for one export */
|
||||
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 (SYM_IS_CONST (Type)) {
|
||||
Value = Read32 (F);
|
||||
} else {
|
||||
SkipExpr (F);
|
||||
}
|
||||
ReadData (F, ConDes, SYM_GET_CONDES_COUNT (Type));
|
||||
Name = GetString (&StrPool, ReadVar (F));
|
||||
Len = strlen (Name);
|
||||
if (SYM_IS_CONST (Type)) {
|
||||
Value = Read32 (F);
|
||||
} else {
|
||||
SkipExpr (F);
|
||||
}
|
||||
if (SYM_HAS_SIZE (Type)) {
|
||||
Size = ReadVar (F);
|
||||
}
|
||||
@@ -634,20 +634,20 @@ void DumpObjExports (FILE* F, unsigned long Offset)
|
||||
SkipLineInfoList (F);
|
||||
SkipLineInfoList (F);
|
||||
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
|
||||
/* Print the data */
|
||||
printf (" Type:%22s0x%02X (%s)\n", "", Type, GetExportFlags (Type, ConDes));
|
||||
printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize,
|
||||
/* Print the data */
|
||||
printf (" Type:%22s0x%02X (%s)\n", "", Type, GetExportFlags (Type, ConDes));
|
||||
printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize,
|
||||
AddrSizeToStr (AddrSize));
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
if (SYM_IS_CONST (Type)) {
|
||||
printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value);
|
||||
}
|
||||
if (SYM_HAS_SIZE (Type)) {
|
||||
printf (" Size:%16s0x%04lX (%lu)\n", "", Size, Size);
|
||||
}
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
if (SYM_IS_CONST (Type)) {
|
||||
printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value);
|
||||
}
|
||||
if (SYM_HAS_SIZE (Type)) {
|
||||
printf (" Size:%16s0x%04lX (%lu)\n", "", Size, Size);
|
||||
}
|
||||
}
|
||||
|
||||
/* Destroy the string pool */
|
||||
@@ -680,9 +680,9 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
|
||||
|
||||
/* Check if the object file was compiled with debug info */
|
||||
if ((H.Flags & OBJ_FLAGS_DBGINFO) == 0) {
|
||||
/* Print that there no debug symbols and bail out */
|
||||
printf (" Count:%27u\n", 0);
|
||||
return;
|
||||
/* Print that there no debug symbols and bail out */
|
||||
printf (" Count:%27u\n", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read the number of exports and print it */
|
||||
@@ -692,22 +692,22 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
|
||||
/* Read and print all debug symbols */
|
||||
for (I = 0; I < Count; ++I) {
|
||||
|
||||
unsigned long Value = 0;
|
||||
unsigned long Value = 0;
|
||||
unsigned long Size = 0;
|
||||
unsigned ImportId = 0;
|
||||
unsigned ExportId = 0;
|
||||
|
||||
/* Read the data for one symbol */
|
||||
unsigned Type = ReadVar (F);
|
||||
/* Read the data for one symbol */
|
||||
unsigned Type = ReadVar (F);
|
||||
unsigned char AddrSize = Read8 (F);
|
||||
unsigned long Owner = ReadVar (F);
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned Len = strlen (Name);
|
||||
if (SYM_IS_CONST (Type)) {
|
||||
Value = Read32 (F);
|
||||
} else {
|
||||
SkipExpr (F);
|
||||
}
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned Len = strlen (Name);
|
||||
if (SYM_IS_CONST (Type)) {
|
||||
Value = Read32 (F);
|
||||
} else {
|
||||
SkipExpr (F);
|
||||
}
|
||||
if (SYM_HAS_SIZE (Type)) {
|
||||
Size = ReadVar (F);
|
||||
}
|
||||
@@ -722,27 +722,27 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
|
||||
SkipLineInfoList (F);
|
||||
SkipLineInfoList (F);
|
||||
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
|
||||
/* Print the data */
|
||||
printf (" Type:%22s0x%02X (%s)\n", "", Type, GetExportFlags (Type, 0));
|
||||
printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize,
|
||||
/* Print the data */
|
||||
printf (" Type:%22s0x%02X (%s)\n", "", Type, GetExportFlags (Type, 0));
|
||||
printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize,
|
||||
AddrSizeToStr (AddrSize));
|
||||
printf (" Owner:%25lu\n", Owner);
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
if (SYM_IS_CONST (Type)) {
|
||||
printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value);
|
||||
}
|
||||
if (SYM_HAS_SIZE (Type)) {
|
||||
printf (" Size:%20s0x%04lX (%lu)\n", "", Size, Size);
|
||||
}
|
||||
if (SYM_IS_IMPORT (Type)) {
|
||||
printf (" Import:%24u\n", ImportId);
|
||||
}
|
||||
if (SYM_IS_EXPORT (Type)) {
|
||||
printf (" Export:%24u\n", ExportId);
|
||||
}
|
||||
printf (" Owner:%25lu\n", Owner);
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
if (SYM_IS_CONST (Type)) {
|
||||
printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value);
|
||||
}
|
||||
if (SYM_HAS_SIZE (Type)) {
|
||||
printf (" Size:%20s0x%04lX (%lu)\n", "", Size, Size);
|
||||
}
|
||||
if (SYM_IS_IMPORT (Type)) {
|
||||
printf (" Import:%24u\n", ImportId);
|
||||
}
|
||||
if (SYM_IS_EXPORT (Type)) {
|
||||
printf (" Export:%24u\n", ExportId);
|
||||
}
|
||||
}
|
||||
|
||||
/* Destroy the string pool */
|
||||
@@ -775,9 +775,9 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
|
||||
|
||||
/* Check if the object file was compiled with debug info */
|
||||
if ((H.Flags & OBJ_FLAGS_DBGINFO) == 0) {
|
||||
/* Print that there no line infos and bail out */
|
||||
printf (" Count:%27u\n", 0);
|
||||
return;
|
||||
/* Print that there no line infos and bail out */
|
||||
printf (" Count:%27u\n", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read the number of line infos and print it */
|
||||
@@ -787,11 +787,11 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
|
||||
/* Read and print all line infos */
|
||||
for (I = 0; I < Count; ++I) {
|
||||
|
||||
FilePos Pos;
|
||||
FilePos Pos;
|
||||
unsigned Type;
|
||||
|
||||
/* File position of line info */
|
||||
ReadFilePos (F, &Pos);
|
||||
/* File position of line info */
|
||||
ReadFilePos (F, &Pos);
|
||||
|
||||
/* Type of line info */
|
||||
Type = ReadVar (F);
|
||||
@@ -799,15 +799,15 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
|
||||
/* Skip the spans */
|
||||
SkipSpanList (F);
|
||||
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
|
||||
/* Print the data */
|
||||
/* Print the data */
|
||||
printf (" Type:%26u\n", LI_GET_TYPE (Type));
|
||||
printf (" Count:%25u\n", LI_GET_COUNT (Type));
|
||||
printf (" Line:%26u\n", Pos.Line);
|
||||
printf (" Col:%27u\n", Pos.Col);
|
||||
printf (" Name:%26u\n", Pos.Name);
|
||||
printf (" Line:%26u\n", Pos.Line);
|
||||
printf (" Col:%27u\n", Pos.Col);
|
||||
printf (" Name:%26u\n", Pos.Name);
|
||||
}
|
||||
|
||||
/* Destroy the string pool */
|
||||
@@ -840,9 +840,9 @@ void DumpObjScopes (FILE* F, unsigned long Offset)
|
||||
|
||||
/* Check if the object file was compiled with debug info */
|
||||
if ((H.Flags & OBJ_FLAGS_DBGINFO) == 0) {
|
||||
/* Print that there no scopes and bail out */
|
||||
printf (" Count:%27u\n", 0);
|
||||
return;
|
||||
/* Print that there no scopes and bail out */
|
||||
printf (" Count:%27u\n", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read the number of scopes and print it */
|
||||
@@ -861,25 +861,25 @@ void DumpObjScopes (FILE* F, unsigned long Offset)
|
||||
unsigned Flags = ReadVar (F);
|
||||
const char* ScopeType = GetScopeType (ReadVar (F));
|
||||
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
/* Print the header */
|
||||
printf (" Index:%27u\n", I);
|
||||
|
||||
/* Print the data */
|
||||
/* Print the data */
|
||||
printf (" Parent id:%21u\n", ParentId);
|
||||
printf (" Lexical level:%17u\n", LexicalLevel);
|
||||
printf (" Flags:%21s0x%02X\n", "", Flags);
|
||||
printf (" Flags:%21s0x%02X\n", "", Flags);
|
||||
printf (" Type:%26s\n", ScopeType);
|
||||
|
||||
/* Resolve and print the name */
|
||||
Name = GetString (&StrPool, ReadVar (F));
|
||||
Len = strlen (Name);
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
Name = GetString (&StrPool, ReadVar (F));
|
||||
Len = strlen (Name);
|
||||
printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
|
||||
|
||||
/* Size */
|
||||
if (SCOPE_HAS_SIZE (Flags)) {
|
||||
if (SCOPE_HAS_SIZE (Flags)) {
|
||||
unsigned long Size = ReadVar (F);
|
||||
printf (" Size:%20s0x%04lX (%lu)\n", "", Size, Size);
|
||||
}
|
||||
printf (" Size:%20s0x%04lX (%lu)\n", "", Size, Size);
|
||||
}
|
||||
|
||||
/* Label */
|
||||
if (SCOPE_HAS_LABEL (Flags)) {
|
||||
@@ -926,11 +926,11 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
|
||||
|
||||
unsigned long Size;
|
||||
|
||||
/* Read the data for one segment */
|
||||
/* Read the data for one segment */
|
||||
unsigned long DataSize = Read32 (F);
|
||||
unsigned long NextSeg = ftell (F) + DataSize;
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned Len = strlen (Name);
|
||||
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||
unsigned Len = strlen (Name);
|
||||
|
||||
/* Skip segment flags, read size */
|
||||
(void) ReadVar (F);
|
||||
@@ -941,8 +941,8 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
|
||||
(void) Read8 (F);
|
||||
(void) ReadVar (F);
|
||||
|
||||
/* Print the size for this segment */
|
||||
printf (" %s:%*s%6lu\n", Name, (int)(24-Len), "", Size);
|
||||
/* Print the size for this segment */
|
||||
printf (" %s:%*s%6lu\n", Name, (int)(24-Len), "", Size);
|
||||
|
||||
/* Seek to the end of the segment data (start of next) */
|
||||
FileSetPos (F, NextSeg);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* dump.h */
|
||||
/* dump.h */
|
||||
/* */
|
||||
/* Dump subroutines for the od65 object file dump utility */
|
||||
/* Dump subroutines for the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* error.c */
|
||||
/* error.c */
|
||||
/* */
|
||||
/* Error handling for the od65 object file dump utility */
|
||||
/* Error handling for the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* global.h */
|
||||
/* global.h */
|
||||
/* */
|
||||
/* Error handling for the od65 object file dump utility */
|
||||
/* Error handling for the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* fileio.c */
|
||||
/* fileio.c */
|
||||
/* */
|
||||
/* File I/O for the od65 object file dump utility */
|
||||
/* File I/O for the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ void FileSetPos (FILE* F, unsigned long Pos)
|
||||
/* Seek to the given absolute position, fail on errors */
|
||||
{
|
||||
if (fseek (F, Pos, SEEK_SET) != 0) {
|
||||
Error ("Cannot seek: %s", strerror (errno));
|
||||
Error ("Cannot seek: %s", strerror (errno));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ unsigned long FileGetPos (FILE* F)
|
||||
{
|
||||
long Pos = ftell (F);
|
||||
if (Pos < 0) {
|
||||
Error ("Error in ftell: %s", strerror (errno));
|
||||
Error ("Error in ftell: %s", strerror (errno));
|
||||
}
|
||||
return Pos;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ unsigned Read8 (FILE* F)
|
||||
{
|
||||
int C = getc (F);
|
||||
if (C == EOF) {
|
||||
Error ("Read error (file corrupt?)");
|
||||
Error ("Read error (file corrupt?)");
|
||||
}
|
||||
return C;
|
||||
}
|
||||
@@ -123,8 +123,8 @@ long Read32Signed (FILE* F)
|
||||
|
||||
/* Sign extend the value */
|
||||
if (V & 0x80000000UL) {
|
||||
/* Signed value */
|
||||
V |= ~0xFFFFFFFFUL;
|
||||
/* Signed value */
|
||||
V |= ~0xFFFFFFFFUL;
|
||||
}
|
||||
|
||||
/* Return it as a long */
|
||||
@@ -143,12 +143,12 @@ unsigned long ReadVar (FILE* F)
|
||||
unsigned long V = 0;
|
||||
unsigned Shift = 0;
|
||||
do {
|
||||
/* Read one byte */
|
||||
C = Read8 (F);
|
||||
/* Encode it into the target value */
|
||||
V |= ((unsigned long)(C & 0x7F)) << Shift;
|
||||
/* Next value */
|
||||
Shift += 7;
|
||||
/* Read one byte */
|
||||
C = Read8 (F);
|
||||
/* Encode it into the target value */
|
||||
V |= ((unsigned long)(C & 0x7F)) << Shift;
|
||||
/* Next value */
|
||||
Shift += 7;
|
||||
} while (C & 0x80);
|
||||
|
||||
/* Return the value read */
|
||||
@@ -180,7 +180,7 @@ FilePos* ReadFilePos (FILE* F, FilePos* Pos)
|
||||
/* Read a file position from the file */
|
||||
{
|
||||
/* Read the data fields */
|
||||
Pos->Line = ReadVar (F);
|
||||
Pos->Line = ReadVar (F);
|
||||
Pos->Col = ReadVar (F);
|
||||
Pos->Name = ReadVar (F);
|
||||
return Pos;
|
||||
@@ -193,9 +193,9 @@ void* ReadData (FILE* F, void* Data, unsigned Size)
|
||||
{
|
||||
/* Accept zero sized reads */
|
||||
if (Size > 0) {
|
||||
if (fread (Data, 1, Size, F) != Size) {
|
||||
Error ("Read error (file corrupt?)");
|
||||
}
|
||||
if (fread (Data, 1, Size, F) != Size) {
|
||||
Error ("Read error (file corrupt?)");
|
||||
}
|
||||
}
|
||||
return Data;
|
||||
}
|
||||
@@ -206,15 +206,15 @@ void ReadObjHeader (FILE* F, ObjHeader* H)
|
||||
/* Read an object file header from the file */
|
||||
{
|
||||
/* Read all fields */
|
||||
H->Magic = Read32 (F);
|
||||
H->Version = Read16 (F);
|
||||
H->Flags = Read16 (F);
|
||||
H->Magic = Read32 (F);
|
||||
H->Version = Read16 (F);
|
||||
H->Flags = Read16 (F);
|
||||
H->OptionOffs = Read32 (F);
|
||||
H->OptionSize = Read32 (F);
|
||||
H->FileOffs = Read32 (F);
|
||||
H->FileSize = Read32 (F);
|
||||
H->SegOffs = Read32 (F);
|
||||
H->SegSize = Read32 (F);
|
||||
H->FileOffs = Read32 (F);
|
||||
H->FileSize = Read32 (F);
|
||||
H->SegOffs = Read32 (F);
|
||||
H->SegSize = Read32 (F);
|
||||
H->ImportOffs = Read32 (F);
|
||||
H->ImportSize = Read32 (F);
|
||||
H->ExportOffs = Read32 (F);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* fileio.h */
|
||||
/* fileio.h */
|
||||
/* */
|
||||
/* File I/O for the od65 object file dump utility */
|
||||
/* File I/O for the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* global.c */
|
||||
/* global.c */
|
||||
/* */
|
||||
/* Global variables for the od65 object file dump utility */
|
||||
/* Global variables for the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -38,12 +38,12 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
unsigned What = 0; /* What should get dumped? */
|
||||
unsigned What = 0; /* What should get dumped? */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* global.h */
|
||||
/* global.h */
|
||||
/* */
|
||||
/* Global variables for the od65 object file dump utility */
|
||||
/* Global variables for the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -39,26 +39,26 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#define D_HEADER 0x0001U /* Dump the header */
|
||||
#define D_OPTIONS 0x0002U /* Dump the options */
|
||||
#define D_FILES 0x0004U /* Dump source file info */
|
||||
#define D_SEGMENTS 0x0008U /* Dump segment info */
|
||||
#define D_IMPORTS 0x0010U /* Dump imported symbols */
|
||||
#define D_EXPORTS 0x0020U /* Dump exported symbols */
|
||||
#define D_DBGSYMS 0x0040U /* Dump debug symbols */
|
||||
#define D_HEADER 0x0001U /* Dump the header */
|
||||
#define D_OPTIONS 0x0002U /* Dump the options */
|
||||
#define D_FILES 0x0004U /* Dump source file info */
|
||||
#define D_SEGMENTS 0x0008U /* Dump segment info */
|
||||
#define D_IMPORTS 0x0010U /* Dump imported symbols */
|
||||
#define D_EXPORTS 0x0020U /* Dump exported symbols */
|
||||
#define D_DBGSYMS 0x0040U /* Dump debug symbols */
|
||||
#define D_LINEINFO 0x0080U /* Dump line infos */
|
||||
#define D_SCOPES 0x0100U /* Dump scopes */
|
||||
#define D_SEGSIZE 0x0200U /* Dump segment sizes */
|
||||
#define D_ALL 0xFFFFU /* Dump anything */
|
||||
#define D_ALL 0xFFFFU /* Dump anything */
|
||||
|
||||
|
||||
|
||||
extern unsigned What; /* What should get dumped? */
|
||||
extern unsigned What; /* What should get dumped? */
|
||||
|
||||
|
||||
|
||||
|
||||
236
src/od65/main.c
236
src/od65/main.c
@@ -1,8 +1,8 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* main.c */
|
||||
/* main.c */
|
||||
/* */
|
||||
/* Main program of the od65 object file dump utility */
|
||||
/* Main program of the od65 object file dump utility */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ static unsigned FilesProcessed = 0;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
@@ -71,32 +71,32 @@ static void Usage (void)
|
||||
/* Print usage information and exit */
|
||||
{
|
||||
printf ("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-all\t\tDump all object file information\n"
|
||||
" --dump-dbgsyms\tDump debug symbols\n"
|
||||
" --dump-exports\tDump exported symbols\n"
|
||||
" --dump-files\t\tDump the source files\n"
|
||||
" --dump-header\t\tDump the object file header\n"
|
||||
" --dump-imports\tDump imported symbols\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);
|
||||
"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-all\t\tDump all object file information\n"
|
||||
" --dump-dbgsyms\tDump debug symbols\n"
|
||||
" --dump-exports\tDump exported symbols\n"
|
||||
" --dump-files\t\tDump the source files\n"
|
||||
" --dump-header\t\tDump the object file header\n"
|
||||
" --dump-imports\tDump imported symbols\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 OptDumpAll (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump all object file information */
|
||||
{
|
||||
What |= D_ALL;
|
||||
@@ -105,7 +105,7 @@ static void OptDumpAll (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpDbgSyms (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump debug symbols contained in the object file */
|
||||
{
|
||||
What |= D_DBGSYMS;
|
||||
@@ -114,7 +114,7 @@ static void OptDumpDbgSyms (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpExports (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the exported symbols */
|
||||
{
|
||||
What |= D_EXPORTS;
|
||||
@@ -123,7 +123,7 @@ static void OptDumpExports (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpFiles (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the source files */
|
||||
{
|
||||
What |= D_FILES;
|
||||
@@ -132,7 +132,7 @@ static void OptDumpFiles (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpHeader (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the object file header */
|
||||
{
|
||||
What |= D_HEADER;
|
||||
@@ -141,7 +141,7 @@ static void OptDumpHeader (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpImports (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the imported symbols */
|
||||
{
|
||||
What |= D_IMPORTS;
|
||||
@@ -150,7 +150,7 @@ static void OptDumpImports (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpLineInfo (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the line infos */
|
||||
{
|
||||
What |= D_LINEINFO;
|
||||
@@ -159,7 +159,7 @@ static void OptDumpLineInfo (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpOptions (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the object file options */
|
||||
{
|
||||
What |= D_OPTIONS;
|
||||
@@ -168,7 +168,7 @@ static void OptDumpOptions (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpScopes (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the scopes in the object file */
|
||||
{
|
||||
What |= D_SCOPES;
|
||||
@@ -177,7 +177,7 @@ static void OptDumpScopes (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpSegments (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the segments in the object file */
|
||||
{
|
||||
What |= D_SEGMENTS;
|
||||
@@ -186,7 +186,7 @@ static void OptDumpSegments (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptDumpSegSize (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Dump the segments in the object file */
|
||||
{
|
||||
What |= D_SEGSIZE;
|
||||
@@ -195,7 +195,7 @@ static void OptDumpSegSize (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 */
|
||||
{
|
||||
Usage ();
|
||||
@@ -205,7 +205,7 @@ static void OptHelp (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
static void OptVersion (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Print the assembler version */
|
||||
{
|
||||
fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
|
||||
@@ -221,7 +221,7 @@ static void DumpFile (const char* Name)
|
||||
/* Try to open the file */
|
||||
FILE* F = fopen (Name, "rb");
|
||||
if (F == 0) {
|
||||
Error ("Cannot open `%s': %s", Name, strerror (errno));
|
||||
Error ("Cannot open `%s': %s", Name, strerror (errno));
|
||||
}
|
||||
|
||||
/* Read the magic word */
|
||||
@@ -230,50 +230,50 @@ static void DumpFile (const char* Name)
|
||||
/* Do we know this type of file? */
|
||||
if (Magic != OBJ_MAGIC) {
|
||||
|
||||
/* Unknown format */
|
||||
printf ("%s: (no xo65 object file)\n", Name);
|
||||
/* Unknown format */
|
||||
printf ("%s: (no xo65 object file)\n", Name);
|
||||
|
||||
} else if (What == 0) {
|
||||
|
||||
/* Special handling if no info was requested */
|
||||
printf ("%s: (no information requested)\n", Name);
|
||||
/* Special handling if no info was requested */
|
||||
printf ("%s: (no information requested)\n", Name);
|
||||
|
||||
} else {
|
||||
|
||||
/* Print the filename */
|
||||
printf ("%s:\n", Name);
|
||||
/* Print the filename */
|
||||
printf ("%s:\n", Name);
|
||||
|
||||
/* Check what to dump */
|
||||
if (What & D_HEADER) {
|
||||
DumpObjHeader (F, 0);
|
||||
}
|
||||
if (What & D_OPTIONS) {
|
||||
DumpObjOptions (F, 0);
|
||||
}
|
||||
if (What & D_FILES) {
|
||||
DumpObjFiles (F, 0);
|
||||
}
|
||||
if (What & D_SEGMENTS) {
|
||||
DumpObjSegments (F, 0);
|
||||
}
|
||||
if (What & D_IMPORTS) {
|
||||
DumpObjImports (F, 0);
|
||||
}
|
||||
if (What & D_EXPORTS) {
|
||||
DumpObjExports (F, 0);
|
||||
}
|
||||
if (What & D_DBGSYMS) {
|
||||
DumpObjDbgSyms (F, 0);
|
||||
}
|
||||
if (What & D_LINEINFO) {
|
||||
DumpObjLineInfo (F, 0);
|
||||
}
|
||||
if (What & D_SCOPES) {
|
||||
DumpObjScopes (F, 0);
|
||||
}
|
||||
if (What & D_SEGSIZE) {
|
||||
DumpObjSegSize (F, 0);
|
||||
}
|
||||
/* Check what to dump */
|
||||
if (What & D_HEADER) {
|
||||
DumpObjHeader (F, 0);
|
||||
}
|
||||
if (What & D_OPTIONS) {
|
||||
DumpObjOptions (F, 0);
|
||||
}
|
||||
if (What & D_FILES) {
|
||||
DumpObjFiles (F, 0);
|
||||
}
|
||||
if (What & D_SEGMENTS) {
|
||||
DumpObjSegments (F, 0);
|
||||
}
|
||||
if (What & D_IMPORTS) {
|
||||
DumpObjImports (F, 0);
|
||||
}
|
||||
if (What & D_EXPORTS) {
|
||||
DumpObjExports (F, 0);
|
||||
}
|
||||
if (What & D_DBGSYMS) {
|
||||
DumpObjDbgSyms (F, 0);
|
||||
}
|
||||
if (What & D_LINEINFO) {
|
||||
DumpObjLineInfo (F, 0);
|
||||
}
|
||||
if (What & D_SCOPES) {
|
||||
DumpObjScopes (F, 0);
|
||||
}
|
||||
if (What & D_SEGSIZE) {
|
||||
DumpObjSegSize (F, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
@@ -287,19 +287,19 @@ int main (int argc, char* argv [])
|
||||
{
|
||||
/* Program long options */
|
||||
static const LongOpt OptTab[] = {
|
||||
{ "--dump-all", 0, OptDumpAll },
|
||||
{ "--dump-dbgsyms", 0, OptDumpDbgSyms },
|
||||
{ "--dump-exports", 0, OptDumpExports },
|
||||
{ "--dump-files", 0, OptDumpFiles },
|
||||
{ "--dump-header", 0, OptDumpHeader },
|
||||
{ "--dump-imports", 0, OptDumpImports },
|
||||
{ "--dump-all", 0, OptDumpAll },
|
||||
{ "--dump-dbgsyms", 0, OptDumpDbgSyms },
|
||||
{ "--dump-exports", 0, OptDumpExports },
|
||||
{ "--dump-files", 0, OptDumpFiles },
|
||||
{ "--dump-header", 0, OptDumpHeader },
|
||||
{ "--dump-imports", 0, OptDumpImports },
|
||||
{ "--dump-lineinfo", 0, OptDumpLineInfo },
|
||||
{ "--dump-options", 0, OptDumpOptions },
|
||||
{ "--dump-options", 0, OptDumpOptions },
|
||||
{ "--dump-scopes", 0, OptDumpScopes },
|
||||
{ "--dump-segments", 0, OptDumpSegments },
|
||||
{ "--dump-segsize", 0, OptDumpSegSize },
|
||||
{ "--help", 0, OptHelp },
|
||||
{ "--version", 0, OptVersion },
|
||||
{ "--dump-segments", 0, OptDumpSegments },
|
||||
{ "--dump-segsize", 0, OptDumpSegSize },
|
||||
{ "--help", 0, OptHelp },
|
||||
{ "--version", 0, OptVersion },
|
||||
};
|
||||
|
||||
unsigned I;
|
||||
@@ -311,51 +311,51 @@ int main (int argc, char* argv [])
|
||||
I = 1;
|
||||
while (I < ArgCount) {
|
||||
|
||||
/* Get the argument */
|
||||
const char* Arg = ArgVec[I];
|
||||
/* Get the argument */
|
||||
const char* Arg = ArgVec[I];
|
||||
|
||||
/* Check for an option */
|
||||
if (Arg [0] == '-') {
|
||||
switch (Arg [1]) {
|
||||
/* Check for an option */
|
||||
if (Arg [0] == '-') {
|
||||
switch (Arg [1]) {
|
||||
|
||||
case '-':
|
||||
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
|
||||
break;
|
||||
case '-':
|
||||
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
OptHelp (Arg, 0);
|
||||
break;
|
||||
case 'h':
|
||||
OptHelp (Arg, 0);
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
OptDumpHeader (Arg, 0);
|
||||
break;
|
||||
case 'H':
|
||||
OptDumpHeader (Arg, 0);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
OptDumpSegSize (Arg, 0);
|
||||
break;
|
||||
case 'S':
|
||||
OptDumpSegSize (Arg, 0);
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
OptVersion (Arg, 0);
|
||||
break;
|
||||
case 'V':
|
||||
OptVersion (Arg, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
UnknownOption (Arg);
|
||||
break;
|
||||
default:
|
||||
UnknownOption (Arg);
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
/* Filename. Dump it. */
|
||||
DumpFile (Arg);
|
||||
++FilesProcessed;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Filename. Dump it. */
|
||||
DumpFile (Arg);
|
||||
++FilesProcessed;
|
||||
}
|
||||
|
||||
/* Next argument */
|
||||
++I;
|
||||
/* Next argument */
|
||||
++I;
|
||||
}
|
||||
|
||||
/* Print a message if we did not process any files */
|
||||
if (FilesProcessed == 0) {
|
||||
fprintf (stderr, "%s: No input files\n", ProgName);
|
||||
fprintf (stderr, "%s: No input files\n", ProgName);
|
||||
}
|
||||
|
||||
/* Success */
|
||||
|
||||
Reference in New Issue
Block a user