]> git.sur5r.net Git - cc65/blobdiff - src/ld65/config.c
Add support for INITAD to the Atari binary format.
[cc65] / src / ld65 / config.c
index fafbed290bf06c18cb4d9a5b57ebc9c212d8ab1f..f8bff2ac050fa5b5008e9d5b8b4be4d359f2fd55 100644 (file)
@@ -1007,6 +1007,7 @@ static void ParseXex (void)
 {
     static const IdentTok Attributes [] = {
         {   "RUNAD",    CFGTOK_RUNAD            },
+        {   "INITAD",   CFGTOK_INITAD           },
     };
 
     /* Remember the attributes read */
@@ -1017,6 +1018,8 @@ static void ParseXex (void)
     };
     unsigned AttrFlags = atNone;
     Import *RunAd = 0;
+    Import *InitAd;
+    MemoryArea *InitMem;
 
     /* Read the attributes */
     while (CfgTok == CFGTOK_IDENT) {
@@ -1046,6 +1049,24 @@ static void ParseXex (void)
                 CfgNextTok ();
                 break;
 
+            case CFGTOK_INITAD:
+                /* We expect a memory area followed by a colon and an identifier */
+                CfgAssureIdent ();
+                InitMem = CfgGetMemory (GetStrBufId (&CfgSVal));
+                CfgNextTok ();
+                CfgConsumeColon ();
+                CfgAssureIdent ();
+                /* Generate an import for the symbol */
+                InitAd = InsertImport (GenImport (GetStrBufId (&CfgSVal), ADDR_SIZE_ABS));
+                /* Remember the file position */
+                CollAppend (&InitAd->RefLines, GenLineInfo (&CfgErrorPos));
+                /* Eat the identifier token */
+                CfgNextTok ();
+                /* Add to XEX */
+                if (XexAddInitAd (XexFmtDesc, InitMem, InitAd))
+                    CfgError (&CfgErrorPos, "INITAD already given for memory area");
+                break;
+
             default:
                 FAIL ("Unexpected attribute token");