]> 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 c01bbcbe780a99c6e715579023ee29137c5510f6..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       */
@@ -172,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]);
@@ -323,7 +329,7 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
            case OPT_ARGSTR:
                ArgStr = GetString (&StrPool, Val);
                ArgLen = strlen (ArgStr);
-               printf ("      Data:%*s\"%s\"\n", 24-ArgLen, "", ArgStr);
+               printf ("      Data:%*s\"%s\"\n", (int)(24-ArgLen), "", ArgStr);
                break;
 
            case OPT_ARGNUM:
@@ -380,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 */
@@ -446,7 +449,7 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
        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 ("      Address size:%14s0x%02X  (%s)\n", "", AddrSize,
@@ -493,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 */
@@ -554,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 {
@@ -579,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);
        }
@@ -629,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 {
@@ -653,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);
        }
@@ -762,7 +757,7 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
         (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);
 
         /* Seek to the end of the segment data (start of next) */
         FileSetPos (F, NextSeg);